From e50d18e4fbe92685b710ba54d56ee227809d346e Mon Sep 17 00:00:00 2001 From: caoyuan Date: Fri, 13 Apr 2018 08:48:53 +0800 Subject: [PATCH] Provide support for freezer 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: wu.chunyang Change-Id: Ia3112a0d297ac777e1f25d3ddecced7746ca6418 --- ansible/roles/freezer/defaults/main.yml | 11 +++++++++++ ansible/roles/freezer/handlers/main.yml | 2 +- ansible/roles/freezer/tasks/bootstrap_service.yml | 2 +- ansible/roles/freezer/tasks/clone.yml | 12 ++++++++++++ ansible/roles/freezer/tasks/config.yml | 2 +- ansible/roles/freezer/tasks/deploy.yml | 3 +++ 6 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 ansible/roles/freezer/tasks/clone.yml diff --git a/ansible/roles/freezer/defaults/main.yml b/ansible/roles/freezer/defaults/main.yml index f5eacf6f29..b7a046ed86 100644 --- a/ansible/roles/freezer/defaults/main.yml +++ b/ansible/roles/freezer/defaults/main.yml @@ -12,6 +12,7 @@ freezer_services: - "/etc/localtime:/etc/localtime:ro" - "freezer:/var/lib/freezer/" - "kolla_logs:/var/log/kolla/" + - "{{ kolla_dev_repos_directory ~ '/freezer-api/freezer_api:/var/lib/kolla/venv/lib/python2.7/site-packages/freezer_api' if freezer_dev_mode | bool else '' }}" dimensions: "{{ freezer_api_dimensions }}" freezer-scheduler: container_name: freezer_scheduler @@ -23,6 +24,7 @@ freezer_services: - "/etc/localtime:/etc/localtime:ro" - "freezer:/var/lib/freezer/" - "kolla_logs:/var/log/kolla/" + - "{{ kolla_dev_repos_directory ~ '/freezer/freezer:/var/lib/kolla/venv/lib/python2.7/site-packages/freezer' if freezer_dev_mode | bool else '' }}" dimensions: "{{ freezer_scheduler_dimensions }}" @@ -55,3 +57,12 @@ freezer_logging_debug: "{{ openstack_logging_debug }}" freezer_keystone_user: "freezer" openstack_freezer_auth: "{{ openstack_auth }}" + + +#################### +# Kolla +#################### +freezer_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}" +freezer_api_git_repository: "{{ kolla_dev_repos_git }}/freezer-api" +freezer_dev_repos_pull: "{{ kolla_dev_repos_pull }}" +freezer_dev_mode: "{{ kolla_dev_mode }}" diff --git a/ansible/roles/freezer/handlers/main.yml b/ansible/roles/freezer/handlers/main.yml index 91c9acdf8e..3a5be2c0b0 100644 --- a/ansible/roles/freezer/handlers/main.yml +++ b/ansible/roles/freezer/handlers/main.yml @@ -39,7 +39,7 @@ common_options: "{{ docker_common_options }}" name: "{{ service.container_name }}" image: "{{ service.image }}" - volumes: "{{ service.volumes }}" + volumes: "{{ service.volumes | reject('equalto', '')|list }}" dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" diff --git a/ansible/roles/freezer/tasks/bootstrap_service.yml b/ansible/roles/freezer/tasks/bootstrap_service.yml index 8bd008423e..d926c35c32 100644 --- a/ansible/roles/freezer/tasks/bootstrap_service.yml +++ b/ansible/roles/freezer/tasks/bootstrap_service.yml @@ -15,6 +15,6 @@ BOOTSTRAP: name: "bootstrap_freezer" restart_policy: "never" - volumes: "{{ freezer_api.volumes }}" + volumes: "{{ freezer_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[freezer_api.group][0] }}" diff --git a/ansible/roles/freezer/tasks/clone.yml b/ansible/roles/freezer/tasks/clone.yml new file mode 100644 index 0000000000..f51504a34c --- /dev/null +++ b/ansible/roles/freezer/tasks/clone.yml @@ -0,0 +1,12 @@ +--- +- name: Cloning freezer source repository for development + git: + repo: "{{ freezer_git_repository }}" + dest: "{{ kolla_dev_repos_directory }}/{{ project_name }}" + update: "{{ freezer_dev_repos_pull }}" + +- name: Cloning freezer-api source repository for development + git: + repo: "{{ freezer_api_git_repository }}" + dest: "{{ kolla_dev_repos_directory }}/freezer-api" + update: "{{ freezer_dev_repos_pull }}" diff --git a/ansible/roles/freezer/tasks/config.yml b/ansible/roles/freezer/tasks/config.yml index 1edbd7b21c..e716ab1c3c 100644 --- a/ansible/roles/freezer/tasks/config.yml +++ b/ansible/roles/freezer/tasks/config.yml @@ -101,7 +101,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 }}" dimensions: "{{ item.value.dimensions }}" register: check_freezer_containers when: diff --git a/ansible/roles/freezer/tasks/deploy.yml b/ansible/roles/freezer/tasks/deploy.yml index 8fb607c92e..a4c9f89359 100644 --- a/ansible/roles/freezer/tasks/deploy.yml +++ b/ansible/roles/freezer/tasks/deploy.yml @@ -9,5 +9,8 @@ - include_tasks: bootstrap_service.yml when: inventory_hostname in groups['freezer-api'] +- include_tasks: clone.yml + when: freezer_dev_mode | bool + - name: Flush handlers meta: flush_handlers