]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Add restapi container deployment 292/head
authorleseb <seb@redhat.com>
Mon, 29 Jun 2015 12:15:07 +0000 (14:15 +0200)
committerleseb <seb@redhat.com>
Mon, 29 Jun 2015 12:19:47 +0000 (14:19 +0200)
Signed-off-by: leseb <seb@redhat.com>
roles/ceph-restapi/defaults/main.yml [new file with mode: 0644]
roles/ceph-restapi/tasks/docker.yml [new file with mode: 0644]
roles/ceph-restapi/tasks/main.yml
roles/ceph-restapi/tasks/start_restapi.yml [new file with mode: 0644]

diff --git a/roles/ceph-restapi/defaults/main.yml b/roles/ceph-restapi/defaults/main.yml
new file mode 100644 (file)
index 0000000..ce86fa6
--- /dev/null
@@ -0,0 +1,10 @@
+---
+##########
+# DOCKER #
+##########
+
+ceph_containerized_deployment: false
+ceph_restapi_docker_interface: eth0
+ceph_restapi_port: 5000
+ceph_restapi_docker_username: ceph
+ceph_restapi_docker_imagename: daemon
diff --git a/roles/ceph-restapi/tasks/docker.yml b/roles/ceph-restapi/tasks/docker.yml
new file mode 100644 (file)
index 0000000..fc3006c
--- /dev/null
@@ -0,0 +1,48 @@
+---
+- name: set config and keys paths
+  set_fact:
+    ceph_config_keys:
+      - /etc/ceph/ceph.client.admin.keyring
+      - /etc/ceph/ceph.conf
+
+- name: install docker-py
+  pip: >
+    name=docker-py
+    version=1.1.0 # https://github.com/ansible/ansible-modules-core/issues/1227
+
+- name: stat for Ceph config and keys
+  stat: >
+    path={{ item }}
+  with_items: ceph_config_keys
+  ignore_errors: true
+  register: statconfig
+
+- name: try to fetch Ceph config and keys
+  copy: >
+    src=fetch/docker_mon_files/"{{ item }}"
+    dest=/etc/ceph/
+    owner=root
+    group=root
+    mode=600
+  with_together:
+    - ceph_config_keys
+    - statconfig.results
+  when: item.1.stat.exists == False
+
+- name: run the Ceph REST API docker image
+  docker: >
+    image="{{ ceph_restapi_docker_username }}/{{ ceph_restapi_docker_imagename }}"
+    name={{ ansible_hostname }}-ceph-restapi
+    net=host
+    expose={{ ceph_restapi_port }}
+    state=running
+    env="RESTAPI_IP={{ hostvars[inventory_hostname]['ansible_' + ceph_restapi_docker_interface]['ipv4']['address'] }},CEPH_DAEMON=RESTAPI"
+    volumes="/etc/ceph:/etc/ceph"
+
+- name: ensure Ceph REST API service is running
+  docker: >
+    image="{{ ceph_restapi_docker_username }}/{{ ceph_restapi_docker_imagename }}"
+    name="ceph-{{ ansible_hostname }}"
+    ports={{ ceph_restapi_port }}:{{ ceph_restapi_port }}
+    detach=yes
+    state=running
index 6d8ebc18f62beeff4cdfaa7f484999ff7f2189ef..68ae0ca80e27a0126ce3c264c9423341686f6c25 100644 (file)
@@ -1,12 +1,9 @@
 ---
 - include: pre_requisite.yml
+  when: not ceph_containerized_deployment
 
-- name: check if Ceph REST API is already started
-  shell: "pgrep ceph-rest-api"
-  ignore_errors: true
-  register: restapi_status
+- include: start_restapi.yml
+  when: not ceph_containerized_deployment
 
-- name: start Ceph REST API
-  shell: "nohup ceph-rest-api &"
-  changed_when: false
-  when: restapi_status.rc != 0
+- include: docker.yml
+  when: ceph_containerized_deployment
diff --git a/roles/ceph-restapi/tasks/start_restapi.yml b/roles/ceph-restapi/tasks/start_restapi.yml
new file mode 100644 (file)
index 0000000..cbe4735
--- /dev/null
@@ -0,0 +1,10 @@
+---
+- name: check if Ceph REST API is already started
+  shell: "pgrep ceph-rest-api"
+  ignore_errors: true
+  register: restapi_status
+
+- name: start Ceph REST API
+  shell: "nohup ceph-rest-api &"
+  changed_when: false
+  when: restapi_status.rc != 0