summaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/glance/tasks
diff options
context:
space:
mode:
authorbaigk <baiguoku@huawei.com>2015-08-05 01:31:07 -0400
committerbaigk <baiguoku@huawei.com>2015-08-05 05:36:31 +0000
commit974a3c3bf5b71cd6b07c1b4b51044bc535ff4456 (patch)
tree3047960616cf8e797d86c4bd19cdca06738b122a /deploy/adapters/ansible/roles/glance/tasks
parentd05b5f04c92034eae1675dc8102247a3cc3315f7 (diff)
support deployment openstack juno with ansible for compass in ubuntu 14.04
JIRA: COMPASS-4 Change-Id: I7adc565325c2a0cbf878b2aea022b31d118748dd Signed-off-by: baigk <baiguoku@huawei.com>
Diffstat (limited to 'deploy/adapters/ansible/roles/glance/tasks')
-rw-r--r--deploy/adapters/ansible/roles/glance/tasks/glance_config.yml33
-rw-r--r--deploy/adapters/ansible/roles/glance/tasks/glance_install.yml24
-rw-r--r--deploy/adapters/ansible/roles/glance/tasks/main.yml20
-rw-r--r--deploy/adapters/ansible/roles/glance/tasks/nfs.yml42
4 files changed, 119 insertions, 0 deletions
diff --git a/deploy/adapters/ansible/roles/glance/tasks/glance_config.yml b/deploy/adapters/ansible/roles/glance/tasks/glance_config.yml
new file mode 100644
index 00000000..008595dc
--- /dev/null
+++ b/deploy/adapters/ansible/roles/glance/tasks/glance_config.yml
@@ -0,0 +1,33 @@
+---
+- name: init glance db version
+ shell: glance-manage db_version_control 0
+
+- name: sync glance db
+ shell: sleep 15; su -s /bin/sh -c "glance-manage db_sync" glance
+ register: result
+ until: result.rc == 0
+ retries: 5
+ delay: 3
+ notify:
+ - restart glance-registry
+ - restart glance-api
+
+- meta: flush_handlers
+
+- name: place image upload script
+ template: src=image_upload.sh dest=/opt/image_upload.sh mode=0744
+
+- name: get image http server
+ shell: awk -F'=' '/compass_server/ {print $2}' /etc/compass.conf
+ register: http_server
+
+- name: download cirros image file
+ get_url: url="http://{{ http_server.stdout_lines[0] }}/image/{{ build_in_image_name }}" dest=/opt/{{ build_in_image_name }}
+
+- name: wait for 9292 port to become available
+ wait_for: host={{ image_host }} port=9292 delay=5
+
+- name: run image upload
+ shell: for i in {0..5}; do /opt/image_upload.sh && touch image_upload_completed; if [ $? != 0 ] ;then sleep 5; else break;fi;done
+ args:
+ creates: image_upload_completed
diff --git a/deploy/adapters/ansible/roles/glance/tasks/glance_install.yml b/deploy/adapters/ansible/roles/glance/tasks/glance_install.yml
new file mode 100644
index 00000000..d9d15db3
--- /dev/null
+++ b/deploy/adapters/ansible/roles/glance/tasks/glance_install.yml
@@ -0,0 +1,24 @@
+---
+- include_vars: "{{ ansible_os_family }}.yml"
+
+- name: install glance packages
+ action: "{{ ansible_pkg_mgr }} name={{ item }} state=latest force=yes"
+ with_items: glance_packages
+
+- name: generate glance service list
+ shell: echo {{ item }} >> /opt/service
+ with_items: glance_services
+
+- name: update glance conf
+ template: src={{ item }} dest=/etc/glance/{{ item }}
+ backup=yes
+ with_items:
+ - glance-api.conf
+ - glance-registry.conf
+ notify:
+ - restart glance-registry
+ - restart glance-api
+
+- name: remove default sqlite db
+ shell: rm /var/lib/glance/glance.sqlite || touch glance.sqllite.db.removed
+
diff --git a/deploy/adapters/ansible/roles/glance/tasks/main.yml b/deploy/adapters/ansible/roles/glance/tasks/main.yml
new file mode 100644
index 00000000..5d7db8e9
--- /dev/null
+++ b/deploy/adapters/ansible/roles/glance/tasks/main.yml
@@ -0,0 +1,20 @@
+---
+- include_vars: "{{ ansible_os_family }}.yml"
+
+- include: glance_install.yml
+ tags:
+ - install
+ - glance_install
+ - glance
+
+- include: nfs.yml
+ tags:
+ - nfs
+
+- include: glance_config.yml
+ when: HA_CLUSTER is not defined or HA_CLUSTER[inventory_hostname] == ''
+ tags:
+ - config
+ - glance_config
+ - glance
+
diff --git a/deploy/adapters/ansible/roles/glance/tasks/nfs.yml b/deploy/adapters/ansible/roles/glance/tasks/nfs.yml
new file mode 100644
index 00000000..70ed91d5
--- /dev/null
+++ b/deploy/adapters/ansible/roles/glance/tasks/nfs.yml
@@ -0,0 +1,42 @@
+---
+- name: install packages
+ action: "{{ ansible_pkg_mgr }} name=nfs-common state=present"
+ with_items: nfs-packages
+
+- name: install nfs
+ local_action: yum name=nfs-utils state=present
+ run_once: True
+
+- name: create image directory
+ local_action: file path=/opt/images state=directory mode=0777
+ run_once: True
+
+- name: update nfs config
+ local_action: lineinfile dest=/etc/exports state=present
+ regexp="/opt/images *(rw,insecure,sync,all_squash)"
+ line="/opt/images *(rw,insecure,sync,all_squash)"
+ run_once: True
+
+- name: restart nfs service
+ local_action: service name={{ item }} state=restarted enabled=yes
+ with_items:
+ - rpcbind
+ - nfs
+ run_once: True
+
+- name: get mount info
+ command: mount
+ register: mount_info
+
+- name: get nfs server
+ shell: awk -F'=' '/compass_server/ {print $2}' /etc/compass.conf
+ register: ip_info
+
+- name: mount image directory
+ shell: |
+ mount -t nfs -onfsvers=3 {{ ip_info.stdout_lines[0] }}:/opt/images /var/lib/glance/images
+ sed -i '/\/var\/lib\/glance\/images/d' /etc/fstab
+ echo {{ ip_info.stdout_lines[0] }}:/opt/images /var/lib/glance/images/ nfs nfsvers=3 >> /etc/fstab
+ when: mount_info.stdout.find('images') == -1
+ retries: 5
+ delay: 3