From 3a34dfa08399d80bbfacbead5cca31f9eb24f5e2 Mon Sep 17 00:00:00 2001 From: caoyuan Date: Fri, 13 Apr 2018 00:04:56 +0800 Subject: [PATCH] Provide support for cloudkitty dev mode in kolla Add a possibility to mount sources as volumes to containers, in "more than documentation" way. That will let us to use kolla as a replacement for devstack. Partially implements: blueprint mount-sources Co-Authored-By: ZhijunWei Change-Id: I8ccfb3c96e642d4b121809236aab0180ac49e3cc --- ansible/roles/cloudkitty/defaults/main.yml | 10 ++++++++++ ansible/roles/cloudkitty/handlers/main.yml | 4 ++-- ansible/roles/cloudkitty/tasks/bootstrap_service.yml | 2 +- ansible/roles/cloudkitty/tasks/clone.yml | 6 ++++++ ansible/roles/cloudkitty/tasks/config.yml | 2 +- ansible/roles/cloudkitty/tasks/deploy.yml | 3 +++ 6 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 ansible/roles/cloudkitty/tasks/clone.yml diff --git a/ansible/roles/cloudkitty/defaults/main.yml b/ansible/roles/cloudkitty/defaults/main.yml index aa8f3f33da..688da5a4da 100644 --- a/ansible/roles/cloudkitty/defaults/main.yml +++ b/ansible/roles/cloudkitty/defaults/main.yml @@ -11,6 +11,7 @@ cloudkitty_services: - "{{ node_config_directory }}/cloudkitty-api/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" + - "{{ kolla_dev_repos_directory ~ '/cloudkitty/cloudkitty:/var/lib/kolla/venv/lib/python2.7/site-packages/cloudkitty' if cloudkitty_dev_mode | bool else '' }}" cloudkitty-processor: container_name: "cloudkitty_processor" group: "cloudkitty-processor" @@ -20,6 +21,7 @@ cloudkitty_services: - "{{ node_config_directory }}/cloudkitty-processor/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" + - "{{ kolla_dev_repos_directory ~ '/cloudkitty/cloudkitty:/var/lib/kolla/venv/lib/python2.7/site-packages/cloudkitty' if cloudkitty_dev_mode | bool else '' }}" #################### @@ -62,3 +64,11 @@ openstack_cloudkitty_auth: "{{ openstack_auth }}" # Cloudkitty #################### cloudkitty_openstack_keystone_default_role: "rating" + + +#################### +# Kolla +#################### +cloudkitty_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}" +cloudkitty_dev_repos_pull: "{{ kolla_dev_repos_pull }}" +cloudkitty_dev_mode: "{{ kolla_dev_mode }}" diff --git a/ansible/roles/cloudkitty/handlers/main.yml b/ansible/roles/cloudkitty/handlers/main.yml index 5ed65a8d03..419b8978ef 100644 --- a/ansible/roles/cloudkitty/handlers/main.yml +++ b/ansible/roles/cloudkitty/handlers/main.yml @@ -13,7 +13,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] @@ -38,7 +38,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] diff --git a/ansible/roles/cloudkitty/tasks/bootstrap_service.yml b/ansible/roles/cloudkitty/tasks/bootstrap_service.yml index 1f401bfd5e..35305c7d13 100644 --- a/ansible/roles/cloudkitty/tasks/bootstrap_service.yml +++ b/ansible/roles/cloudkitty/tasks/bootstrap_service.yml @@ -15,6 +15,6 @@ BOOTSTRAP: name: "bootstrap_cloudkitty" restart_policy: "never" - volumes: "{{ cloudkitty_api.volumes }}" + volumes: "{{ cloudkitty_api.volumes|reject('equalto', '')|list }}" run_once: True delegate_to: "{{ groups[cloudkitty_api.group][0] }}" diff --git a/ansible/roles/cloudkitty/tasks/clone.yml b/ansible/roles/cloudkitty/tasks/clone.yml new file mode 100644 index 0000000000..906be97d92 --- /dev/null +++ b/ansible/roles/cloudkitty/tasks/clone.yml @@ -0,0 +1,6 @@ +--- +- name: Cloning cloudkitty source repository for development + git: + repo: "{{ cloudkitty_git_repository }}" + dest: "{{ kolla_dev_repos_directory }}/{{ project_name }}" + update: "{{ cloudkitty_dev_repos_pull }}" diff --git a/ansible/roles/cloudkitty/tasks/config.yml b/ansible/roles/cloudkitty/tasks/config.yml index c750bb935e..359cbadf7d 100644 --- a/ansible/roles/cloudkitty/tasks/config.yml +++ b/ansible/roles/cloudkitty/tasks/config.yml @@ -104,7 +104,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_cloudkitty_containers when: - kolla_action != "config" diff --git a/ansible/roles/cloudkitty/tasks/deploy.yml b/ansible/roles/cloudkitty/tasks/deploy.yml index f066c0dfbb..aae4a8a4d9 100644 --- a/ansible/roles/cloudkitty/tasks/deploy.yml +++ b/ansible/roles/cloudkitty/tasks/deploy.yml @@ -6,6 +6,9 @@ when: inventory_hostname in groups['cloudkitty-api'] or inventory_hostname in groups['cloudkitty-processor'] +- include: clone.yml + when: cloudkitty_dev_mode | bool + - include: bootstrap.yml when: inventory_hostname in groups['cloudkitty-api']