]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Implement Ceph REST API 232/head
authorSébastien Han <sebastien.han@enovance.com>
Mon, 23 Mar 2015 14:08:58 +0000 (15:08 +0100)
committerSébastien Han <sebastien.han@enovance.com>
Mon, 23 Mar 2015 17:30:52 +0000 (18:30 +0100)
Now the Ceph REST API can be deployed.
Default implementation deploys it on the same nodes as the monitors
which should be fine.

Signed-off-by: Sébastien Han <sebastien.han@enovance.com>
group_vars/all
roles/ceph-common/defaults/main.yml
roles/ceph-common/templates/ceph.conf.j2
roles/ceph-mon/defaults/main.yml
roles/ceph-mon/tasks/ceph_keys.yml
roles/ceph-restapi/tasks/main.yml [new file with mode: 0644]
roles/ceph-restapi/tasks/pre_requisite.yml [new file with mode: 0644]
site.yml

index 365a450f5d91dfd7ebd9e69cc6763fa2df8f775e..71ee4ecd531e9b3efeda39fc26d6ff4f3eb9b50c 100644 (file)
@@ -111,6 +111,13 @@ dummy:
 #radosgw: false # referenced in monitor role too.
 #radosgw_dns_name: your.subdomain.tld # subdomains used by radosgw. See http://ceph.com/docs/master/radosgw/config/#enabling-subdomain-s3-calls
 
+## REST API options
+#
+#restapi: false # disable restapi configuration in ceph.conf
+#restapi_public_addr: 0.0.0.0:5000
+#restapi_base_url: /api/v0.1
+#restapi_log_level: warning
+
 ## Testing mode
 # enable this mode _only_ when you have a single node
 # if you don't want it keep the option commented
index a0ab1bc2f293f27d470a55499ca841fcff092fda..b58e08406ff4567554bf49975a6d402b5e133fb1 100644 (file)
@@ -128,6 +128,14 @@ radosgw: false # referenced in monitor role too.
 radosgw_frontend: civetweb # supported options are 'apache' or 'civetweb', also edit roles/ceph-radosgw/defaults/main.yml\r
 radosgw_civetweb_port: 80\r
 \r
+## REST API options\r
+#\r
+restapi: false # disable restapi configuration in ceph.conf\r
+restapi_interface: eth1\r
+restapi_port: 5000\r
+restapi_base_url: /api/v0.1\r
+restapi_log_level: warning # available level are: critical, error, warning, info, debug\r
+\r
 ## Testing mode\r
 # enable this mode _only_ when you have a single node\r
 # if you don't want it keep the option commented\r
index a0416525a53d54a54c1399e0bb4d5e9cf0b81302..0e0f7f391028bd10e04d79704b81e4738ec7fcce 100644 (file)
 {% endif %}
 {% endfor %}
 {% endif %}
+
+{% if restapi %}
+[client.restapi]
+  public addr = {{ hostvars[inventory_hostname]['ansible_' + restapi_interface]['ipv4']['address'] }}:{{ restapi_port }}
+  restapi base url = {{ restapi_base_url }}
+  restapi log level = {{ restapi_log_level }}
+  keyring = /var/lib/ceph/restapi/ceph-restapi/keyring
+  log file = /var/log/ceph/ceph-restapi.log
+{% endif %}
index 2240dab77974cff1077136be6906ef9c18864091..d4fc7e83da036d6af437ff11d6ea0e9092b2ae87 100644 (file)
@@ -20,6 +20,11 @@ cephfs_data: cephfs_data
 cephfs_metadata: cephfs_metadata\r
 cephfs: cephfs\r
 \r
+# Ceph REST API\r
+# referenced in common role too.\r
+restapi: false\r
+\r
+\r
 #############\r
 # OPENSTACK #\r
 #############\r
index 798dae83d6b8d64b2014b4b2edc8fc4d4e7d9093..e322209761cac78c0a100c0e0db5eeff74c8731b 100644 (file)
   with_items: groups.rgws
   changed_when: False
 
+- name: Create Ceph REST API keyring
+  command: >
+    ceph auth get-or-create client.restapi osd 'allow *' mon 'allow *' -o /etc/ceph/ceph.client.restapi.keyring
+    creates=/etc/ceph/ceph.client.restapi.keyring
+  when: cephx and restapi
+  changed_when: False
+
 - include: openstack_config.yml
   when: openstack_config and cephx
 
   register: ceph_keys
   when: cephx
 
+- name: Set keys permissions
+  file: >
+    path={{ item }}
+    mode=0600
+    owner=root
+    group=root
+  with_items:
+    - "{{ ceph_keys.stdout_lines }}"
+
 - name: Copy keys to the ansible server
   fetch: >
     src={{ item }}
diff --git a/roles/ceph-restapi/tasks/main.yml b/roles/ceph-restapi/tasks/main.yml
new file mode 100644 (file)
index 0000000..4671a87
--- /dev/null
@@ -0,0 +1,11 @@
+---
+- include: pre_requisite.yml
+
+- name: Check if Ceph REST API is already started
+  shell: "ps aux|grep [c]eph-rest-api"
+  register: restapi_status
+  ignore_errors: True
+
+- name: Start Ceph REST API
+  shell: "nohup ceph-rest-api -n client.restapi &"
+  when: restapi_status.rc != 0
diff --git a/roles/ceph-restapi/tasks/pre_requisite.yml b/roles/ceph-restapi/tasks/pre_requisite.yml
new file mode 100644 (file)
index 0000000..063af10
--- /dev/null
@@ -0,0 +1,25 @@
+---
+- name: Create Ceph REST API directory
+  file: >
+    path=/var/lib/ceph/restapi/ceph-restapi
+    state=directory
+    owner=root
+    group=root
+    mode=0644
+
+- name: Copy Ceph REST API keyring
+  copy: >
+    src=fetch/{{ fsid }}/etc/ceph/ceph.client.restapi.keyring
+    dest=/var/lib/ceph/restapi/ceph-restapi/keyring
+    owner=root
+    group=root
+    mode=600
+  when: cephx
+
+- name: Activate Ceph REST API with upstart
+  file: >
+    path=/var/lib/ceph/restapi/ceph-restapi/done
+    state=touch
+    owner=root
+    group=root
+    mode=0644
index 90469c212b4821f50fa4a7784ae50d69de85dca6..e7d10b0d7d707e76af8c4b5545b7da4fde36fe39 100644 (file)
--- a/site.yml
+++ b/site.yml
@@ -14,6 +14,7 @@
   sudo: True
   roles:
   - ceph-mon
+  - ceph-restapi
 
 - hosts: osds
   sudo: True