From 31a6de01f314ef9f7a2429a934a76d5c1ef73331 Mon Sep 17 00:00:00 2001 From: "wu.chunyang" Date: Thu, 7 Jun 2018 13:56:07 +0000 Subject: [PATCH] dev mode: Add support for sahara Provide support fot kolla dev mode in sahara. When 'kolla_dev_mode' or 'sahara_dev_mode' variables are enabled, source code of sahara project will be cloned and mounted automatically Partially implements: blueprint mount-sources Change-Id: I496ea4443ec8ffc4dc9d0f0d3e6a4514d16ed336 Co-Authored-By: zhulingjie --- ansible/roles/sahara/defaults/main.yml | 10 ++++++++++ ansible/roles/sahara/handlers/main.yml | 4 ++-- ansible/roles/sahara/tasks/bootstrap_service.yml | 2 +- ansible/roles/sahara/tasks/clone.yml | 6 ++++++ ansible/roles/sahara/tasks/config.yml | 2 +- ansible/roles/sahara/tasks/deploy.yml | 3 +++ 6 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 ansible/roles/sahara/tasks/clone.yml diff --git a/ansible/roles/sahara/defaults/main.yml b/ansible/roles/sahara/defaults/main.yml index 929f9fc36a..426fb1a75f 100644 --- a/ansible/roles/sahara/defaults/main.yml +++ b/ansible/roles/sahara/defaults/main.yml @@ -12,6 +12,7 @@ sahara_services: - "/etc/localtime:/etc/localtime:ro" - "sahara:/var/lib/sahara/" - "kolla_logs:/var/log/kolla/" + - "{{ kolla_dev_repos_directory ~ '/sahara/sahara:/var/lib/kolla/venv/lib/python2.7/site-packages/sahara' if sahara_dev_mode | bool else '' }}" sahara-engine: container_name: sahara_engine group: sahara-engine @@ -24,6 +25,7 @@ sahara_services: - "sahara:/var/lib/sahara/" - "kolla_logs:/var/log/kolla/" - "/run:/run:shared" + - "{{ kolla_dev_repos_directory ~ '/sahara/sahara:/var/lib/kolla/venv/lib/python2.7/site-packages/sahara' if sahara_dev_mode | bool else '' }}" #################### @@ -61,3 +63,11 @@ sahara_logging_debug: "{{ openstack_logging_debug }}" sahara_keystone_user: "sahara" openstack_sahara_auth: "{{ openstack_auth }}" + + +#################### +## Kolla +##################### +sahara_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}" +sahara_dev_repos_pull: "{{ kolla_dev_repos_pull }}" +sahara_dev_mode: "{{ kolla_dev_mode }}" diff --git a/ansible/roles/sahara/handlers/main.yml b/ansible/roles/sahara/handlers/main.yml index 37a2f4a7a8..476107e5a8 100644 --- a/ansible/roles/sahara/handlers/main.yml +++ b/ansible/roles/sahara/handlers/main.yml @@ -12,7 +12,7 @@ common_options: "{{ docker_common_options }}" name: "{{ service.container_name }}" image: "{{ service.image }}" - volumes: "{{ service.volumes }}" + volumes: "{{ service.volumes|reject('equalto', '')|list }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -35,7 +35,7 @@ common_options: "{{ docker_common_options }}" name: "{{ service.container_name }}" image: "{{ service.image }}" - volumes: "{{ service.volumes }}" + volumes: "{{ service.volumes|reject('equalto', '')|list }}" privileged: "{{ service.privileged | default(False) }}" when: - kolla_action != "config" diff --git a/ansible/roles/sahara/tasks/bootstrap_service.yml b/ansible/roles/sahara/tasks/bootstrap_service.yml index f0bd0bcadf..f2d8787164 100644 --- a/ansible/roles/sahara/tasks/bootstrap_service.yml +++ b/ansible/roles/sahara/tasks/bootstrap_service.yml @@ -14,6 +14,6 @@ BOOTSTRAP: name: "bootstrap_sahara" restart_policy: "never" - volumes: "{{ sahara_api.volumes }}" + volumes: "{{ sahara_api.volumes|reject('equalto', '')|list }}" run_once: True delegate_to: "{{ groups[sahara_api.group][0] }}" diff --git a/ansible/roles/sahara/tasks/clone.yml b/ansible/roles/sahara/tasks/clone.yml new file mode 100644 index 0000000000..401c913b0b --- /dev/null +++ b/ansible/roles/sahara/tasks/clone.yml @@ -0,0 +1,6 @@ +--- +- name: Cloning sahara source repository for development + git: + repo: "{{ sahara_git_repository }}" + dest: "{{ kolla_dev_repos_directory }}/{{ project_name }}" + update: "{{ sahara_dev_repos_pull }}" diff --git a/ansible/roles/sahara/tasks/config.yml b/ansible/roles/sahara/tasks/config.yml index 14753b2a91..687ff46e34 100644 --- a/ansible/roles/sahara/tasks/config.yml +++ b/ansible/roles/sahara/tasks/config.yml @@ -89,7 +89,7 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" privileged: "{{ item.value.privileged | default(False) }}" - volumes: "{{ item.value.volumes }}" + volumes: "{{ item.value.volumes|reject('equalto', '')|list }}" register: check_sahara_containers when: - kolla_action != "config" diff --git a/ansible/roles/sahara/tasks/deploy.yml b/ansible/roles/sahara/tasks/deploy.yml index 05655b739e..c18f2f52b5 100644 --- a/ansible/roles/sahara/tasks/deploy.yml +++ b/ansible/roles/sahara/tasks/deploy.yml @@ -6,6 +6,9 @@ when: inventory_hostname in groups['sahara-api'] or inventory_hostname in groups['sahara-engine'] +- include: clone.yml + when: sahara_dev_mode | bool + - include: bootstrap.yml when: inventory_hostname in groups['sahara-api']