From 291c04c87ff6ff4ce519bd8f70b02f54c7de2798 Mon Sep 17 00:00:00 2001 From: "wu.chunyang" Date: Mon, 28 May 2018 15:03:18 +0000 Subject: [PATCH] dev mode: Add support for ironic Allows users to develop on ironic using Kolla. Partially implements: blueprint mount-sources Change-Id: I74540f5bcbf723f097f3dea96dcaf067834c493a --- ansible/roles/ironic/defaults/main.yml | 12 ++++++++++++ ansible/roles/ironic/handlers/main.yml | 6 +++--- ansible/roles/ironic/tasks/bootstrap_service.yml | 4 ++-- ansible/roles/ironic/tasks/clone.yml | 12 ++++++++++++ ansible/roles/ironic/tasks/config.yml | 2 +- ansible/roles/ironic/tasks/deploy.yml | 3 +++ 6 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 ansible/roles/ironic/tasks/clone.yml diff --git a/ansible/roles/ironic/defaults/main.yml b/ansible/roles/ironic/defaults/main.yml index 3b91bcce3a..64a76e13c4 100644 --- a/ansible/roles/ironic/defaults/main.yml +++ b/ansible/roles/ironic/defaults/main.yml @@ -11,6 +11,7 @@ ironic_services: - "{{ node_config_directory }}/ironic-api/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla" + - "{{ kolla_dev_repos_directory ~ '/ironic/ironic:/var/lib/kolla/venv/lib/python2.7/site-packages/ironic' if ironic_dev_mode | bool else '' }}" ironic-conductor: container_name: ironic_conductor group: ironic-conductor @@ -28,6 +29,7 @@ ironic_services: - "ironic:/var/lib/ironic" - "ironic_pxe:/tftpboot/" - "ironic_ipxe:/httpboot/" + - "{{ kolla_dev_repos_directory ~ '/ironic/ironic:/var/lib/kolla/venv/lib/python2.7/site-packages/ironic' if ironic_dev_mode | bool else '' }}" ironic-inspector: container_name: ironic_inspector group: ironic-inspector @@ -38,6 +40,7 @@ ironic_services: - "{{ node_config_directory }}/ironic-inspector/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla" + - "{{ kolla_dev_repos_directory ~ '/ironic-inspector/ironic_inspector:/var/lib/kolla/venv/lib/python2.7/site-packages/ironic_inspector' if ironic_dev_mode | bool else '' }}" ironic-pxe: container_name: ironic_pxe group: ironic-pxe @@ -140,3 +143,12 @@ ironic_dnsmasq_boot_file: "{% if enable_ironic_ipxe | bool %}undionly.kpxe{% els ironic_cleaning_network: ironic_console_serial_speed: "115200n8" ironic_ipxe_url: http://{{ api_interface_address }}:{{ ironic_ipxe_port }} + + +#################### +## Kolla +##################### +ironic_inspector_git_repository: "{{ kolla_dev_repos_git }}/ironic-inspector" +ironic_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}" +ironic_dev_repos_pull: "{{ kolla_dev_repos_pull }}" +ironic_dev_mode: "{{ kolla_dev_mode }}" diff --git a/ansible/roles/ironic/handlers/main.yml b/ansible/roles/ironic/handlers/main.yml index 49ee9132e5..903d3e44e5 100644 --- a/ansible/roles/ironic/handlers/main.yml +++ b/ansible/roles/ironic/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] @@ -36,7 +36,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" privileged: "{{ service.privileged | default(False) }}" - volumes: "{{ service.volumes }}" + volumes: "{{ service.volumes|reject('equalto', '')|list }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] @@ -59,7 +59,7 @@ name: "{{ service.container_name }}" image: "{{ service.image }}" privileged: "{{ service.privileged | default(False) }}" - volumes: "{{ service.volumes }}" + volumes: "{{ service.volumes|reject('equalto', '')|list }}" when: - kolla_action != "config" - inventory_hostname in groups[service.group] diff --git a/ansible/roles/ironic/tasks/bootstrap_service.yml b/ansible/roles/ironic/tasks/bootstrap_service.yml index 559e15c1a9..0962481bca 100644 --- a/ansible/roles/ironic/tasks/bootstrap_service.yml +++ b/ansible/roles/ironic/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ BOOTSTRAP: name: "bootstrap_ironic" restart_policy: "never" - volumes: "{{ ironic_api.volumes }}" + volumes: "{{ ironic_api.volumes|reject('equalto', '')|list }}" run_once: True delegate_to: "{{ groups[ironic_api.group][0] }}" when: inventory_hostname in groups[ironic_api.group] @@ -34,7 +34,7 @@ BOOTSTRAP: name: "bootstrap_ironic_inspector" restart_policy: "never" - volumes: "{{ ironic_inspector.volumes }}" + volumes: "{{ ironic_inspector.volumes|reject('equalto', '')|list }}" run_once: True delegate_to: "{{ groups[ironic_inspector.group][0] }}" when: inventory_hostname in groups[ironic_inspector.group] diff --git a/ansible/roles/ironic/tasks/clone.yml b/ansible/roles/ironic/tasks/clone.yml new file mode 100644 index 0000000000..6a01b8cf67 --- /dev/null +++ b/ansible/roles/ironic/tasks/clone.yml @@ -0,0 +1,12 @@ +--- +- name: Cloning ironic source repository for development + git: + repo: "{{ ironic_git_repository }}" + dest: "{{ kolla_dev_repos_directory }}/{{ project_name }}" + update: "{{ ironic_dev_repos_pull }}" + +- name: Cloning ironic-inspector source repository for development + git: + repo: "{{ ironic_inspector_git_repository }}" + dest: "{{ kolla_dev_repos_directory }}/ironic-inspector" + update: "{{ ironic_dev_repos_pull }}" diff --git a/ansible/roles/ironic/tasks/config.yml b/ansible/roles/ironic/tasks/config.yml index 99f284e23f..e821726a8f 100644 --- a/ansible/roles/ironic/tasks/config.yml +++ b/ansible/roles/ironic/tasks/config.yml @@ -258,7 +258,7 @@ image: "{{ item.value.image }}" privileged: "{{ item.value.privileged|default(False) }}" cap_add: "{{ item.value.cap_add|default([]) }}" - volumes: "{{ item.value.volumes }}" + volumes: "{{ item.value.volumes|reject('equalto', '')|list }}" register: check_ironic_containers when: - kolla_action != "config" diff --git a/ansible/roles/ironic/tasks/deploy.yml b/ansible/roles/ironic/tasks/deploy.yml index d599fbe518..898363357a 100644 --- a/ansible/roles/ironic/tasks/deploy.yml +++ b/ansible/roles/ironic/tasks/deploy.yml @@ -11,6 +11,9 @@ inventory_hostname in groups['ironic-pxe'] or inventory_hostname in groups['ironic-ipxe'] +- include: clone.yml + when: ironic_dev_mode | bool + - include: bootstrap.yml when: inventory_hostname in groups['ironic-api'] or inventory_hostname in groups['ironic-inspector'] or