From 0025aac92eab57c6bc502209acaebe94430966b6 Mon Sep 17 00:00:00 2001 From: caoyuan Date: Thu, 12 Apr 2018 23:07:23 +0800 Subject: [PATCH] dev mode: Add support for aodh Provide support fot kolla dev mode in aodh. When 'kolla_dev_mode' or 'aodh_dev_mode' variables are enabled, source code of aodh project is cloned and bindmounted. Partially implements: blueprint mount-sources Co-Authored-By: wu.chunyang Change-Id: I1235013ab2ff887c4311126cbff7367775f66347 --- ansible/roles/aodh/defaults/main.yml | 12 ++++++++++++ ansible/roles/aodh/handlers/main.yml | 8 ++++---- ansible/roles/aodh/tasks/bootstrap_service.yml | 2 +- ansible/roles/aodh/tasks/clone.yml | 6 ++++++ ansible/roles/aodh/tasks/config.yml | 2 +- ansible/roles/aodh/tasks/deploy.yml | 3 +++ 6 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 ansible/roles/aodh/tasks/clone.yml diff --git a/ansible/roles/aodh/defaults/main.yml b/ansible/roles/aodh/defaults/main.yml index b1646e28b1..9ecc4cb3f0 100644 --- a/ansible/roles/aodh/defaults/main.yml +++ b/ansible/roles/aodh/defaults/main.yml @@ -12,6 +12,7 @@ aodh_services: - "/etc/localtime:/etc/localtime:ro" - "aodh:/var/lib/aodh/" - "kolla_logs:/var/log/kolla/" + - "{{ kolla_dev_repos_directory ~ '/aodh/aodh:/var/lib/kolla/venv/lib/python2.7/site-packages/aodh' if aodh_dev_mode | bool else '' }}" aodh-evaluator: container_name: aodh_evaluator group: aodh-evaluator @@ -21,6 +22,7 @@ aodh_services: - "{{ node_config_directory }}/aodh-evaluator/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" + - "{{ kolla_dev_repos_directory ~ '/aodh/aodh:/var/lib/kolla/venv/lib/python2.7/site-packages/aodh' if aodh_dev_mode | bool else '' }}" aodh-listener: container_name: aodh_listener group: aodh-listener @@ -30,6 +32,7 @@ aodh_services: - "{{ node_config_directory }}/aodh-listener/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" + - "{{ kolla_dev_repos_directory ~ '/aodh/aodh:/var/lib/kolla/venv/lib/python2.7/site-packages/aodh' if aodh_dev_mode | bool else '' }}" aodh-notifier: container_name: aodh_notifier group: aodh-notifier @@ -39,6 +42,7 @@ aodh_services: - "{{ node_config_directory }}/aodh-notifier/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" + - "{{ kolla_dev_repos_directory ~ '/aodh/aodh:/var/lib/kolla/venv/lib/python2.7/site-packages/aodh' if aodh_dev_mode | bool else '' }}" #################### @@ -83,3 +87,11 @@ aodh_logging_debug: "{{ openstack_logging_debug }}" aodh_keystone_user: "aodh" openstack_aodh_auth: "{{ openstack_auth }}" + + +#################### +# Kolla +#################### +aodh_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}" +aodh_dev_repos_pull: "{{ kolla_dev_repos_pull }}" +aodh_dev_mode: "{{ kolla_dev_mode }}" diff --git a/ansible/roles/aodh/handlers/main.yml b/ansible/roles/aodh/handlers/main.yml index 1f12b7f87f..154258b86a 100644 --- a/ansible/roles/aodh/handlers/main.yml +++ b/ansible/roles/aodh/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: - action != "config" - inventory_hostname in groups[service.group] @@ -36,7 +36,7 @@ common_options: "{{ docker_common_options }}" name: "{{ service.container_name }}" image: "{{ service.image }}" - volumes: "{{ service.volumes }}" + volumes: "{{ service.volumes|reject('equalto', '')|list }}" when: - action != "config" - inventory_hostname in groups[service.group] @@ -59,7 +59,7 @@ common_options: "{{ docker_common_options }}" name: "{{ service.container_name }}" image: "{{ service.image }}" - volumes: "{{ service.volumes }}" + volumes: "{{ service.volumes|reject('equalto', '')|list }}" when: - action != "config" - inventory_hostname in groups[service.group] @@ -82,7 +82,7 @@ common_options: "{{ docker_common_options }}" name: "{{ service.container_name }}" image: "{{ service.image }}" - volumes: "{{ service.volumes }}" + volumes: "{{ service.volumes|reject('equalto', '')|list }}" when: - action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/aodh/tasks/bootstrap_service.yml b/ansible/roles/aodh/tasks/bootstrap_service.yml index 5ad824cfb4..1ab7b7dceb 100644 --- a/ansible/roles/aodh/tasks/bootstrap_service.yml +++ b/ansible/roles/aodh/tasks/bootstrap_service.yml @@ -14,6 +14,6 @@ BOOTSTRAP: name: "bootstrap_aodh" restart_policy: "never" - volumes: "{{ aodh_api.volumes }}" + volumes: "{{ aodh_api.volumes|reject('equalto', '')|list }}" run_once: True delegate_to: "{{ groups[aodh_api.group][0] }}" diff --git a/ansible/roles/aodh/tasks/clone.yml b/ansible/roles/aodh/tasks/clone.yml new file mode 100644 index 0000000000..ddffef3a37 --- /dev/null +++ b/ansible/roles/aodh/tasks/clone.yml @@ -0,0 +1,6 @@ +--- +- name: Cloning aodh source repository for development + git: + repo: "{{ aodh_git_repository }}" + dest: "{{ kolla_dev_repos_directory }}/{{ project_name }}" + update: "{{ aodh_dev_repos_pull }}" diff --git a/ansible/roles/aodh/tasks/config.yml b/ansible/roles/aodh/tasks/config.yml index a6fed5eae1..b4dde7d3ba 100644 --- a/ansible/roles/aodh/tasks/config.yml +++ b/ansible/roles/aodh/tasks/config.yml @@ -109,7 +109,7 @@ common_options: "{{ docker_common_options }}" name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" - volumes: "{{ item.value.volumes }}" + volumes: "{{ item.value.volumes|reject('equalto', '')|list }}" register: check_aodh_containers when: - action != "config" diff --git a/ansible/roles/aodh/tasks/deploy.yml b/ansible/roles/aodh/tasks/deploy.yml index 7e6598017b..a1fdd905a6 100644 --- a/ansible/roles/aodh/tasks/deploy.yml +++ b/ansible/roles/aodh/tasks/deploy.yml @@ -8,6 +8,9 @@ inventory_hostname in groups['aodh-listener'] or inventory_hostname in groups['aodh-notifier'] +- include: clone.yml + when: aodh_dev_mode | bool + - include: bootstrap.yml when: inventory_hostname in groups['aodh-api']