Do not run tasks for containers when on metal

Without this patch, ansible parses the includes for containers,
even when running on metal, and therefore even if there is no
reason to do so.

This is a problem because some of those includes rely on variables
set by our dynamic inventory, and would fail when running OSA
with a static inventory on metal.

This patch solves the problem by ensuring the task will not
run unnecessarily.

Change-Id: I101b121d3d94673597a705979c38ea207043555f
This commit is contained in:
Jean-Philippe Evrard 2018-07-05 14:21:26 +02:00
parent e7b3654051
commit ad985158b6
34 changed files with 73 additions and 20 deletions

View File

@ -23,6 +23,8 @@
- src: "/openstack/log/{{ inventory_hostname }}-ceph" - src: "/openstack/log/{{ inventory_hostname }}-ceph"
dest: "/var/log/ceph" dest: "/var/log/ceph"
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
when: not is_metal
static: no
vars: vars:
list_of_bind_mounts: "{{ ceph_container_bind_mounts }}" list_of_bind_mounts: "{{ ceph_container_bind_mounts }}"
- include: common-tasks/unbound-clients.yml - include: common-tasks/unbound-clients.yml

View File

@ -27,6 +27,8 @@
dest: "/var/log/ceph" dest: "/var/log/ceph"
- include: common-tasks/os-lxc-container-setup.yml - include: common-tasks/os-lxc-container-setup.yml
when: not is_metal
static: no
- name: Gather ceph-mon facts - name: Gather ceph-mon facts
action: setup action: setup

View File

@ -52,6 +52,7 @@
extra_container_config_no_restart: extra_container_config_no_restart:
- "lxc.start.order=39" - "lxc.start.order=39"
when: when:
- "not is_metal"
- "'cinder_volume' in group_names" - "'cinder_volume' in group_names"
- "cinder_backend_lvm_inuse | bool" - "cinder_backend_lvm_inuse | bool"
@ -59,6 +60,7 @@
include: "../common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" include: "../common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no static: no
when: when:
- "not is_metal"
- "'cinder_volume' not in group_names" - "'cinder_volume' not in group_names"
- name: Configure log directories (on metal) - name: Configure log directories (on metal)

View File

@ -35,18 +35,21 @@
- "groups['glance_api'] | length > 1" - "groups['glance_api'] | length > 1"
- name: Configure container (non-nfs) - name: Configure container (non-nfs)
static: no
include: "../common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" include: "../common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
vars: vars:
list_of_bind_mounts: "{{ glance_container_bind_mounts }}" list_of_bind_mounts: "{{ glance_container_bind_mounts }}"
static: no
when: when:
- not is_metal
- glance_default_store == "file" - glance_default_store == "file"
- (glance_nfs_client is not defined) or (glance_nfs_client | length == 0) - (glance_nfs_client is not defined) or (glance_nfs_client | length == 0)
- name: Configure container (nfs) - name: Configure container (nfs)
include: "../common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" include: "../common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no static: no
when: (glance_default_store != "file") or (glance_nfs_client is defined) when:
- not is_metal
- (glance_default_store != "file") or (glance_nfs_client is defined)
- name: Configure log directories (on metal) - name: Configure log directories (on metal)
include: ../common-tasks/os-log-dir-setup.yml include: ../common-tasks/os-log-dir-setup.yml

View File

@ -39,12 +39,15 @@
- "lxc.cgroup.devices.allow=a *:* rmw" - "lxc.cgroup.devices.allow=a *:* rmw"
extra_container_config_no_restart: extra_container_config_no_restart:
- "lxc.start.order=29" - "lxc.start.order=29"
static: no
when: when:
- "not is_metal"
- "'neutron_agent' in group_names" - "'neutron_agent' in group_names"
- name: Configure container (other services) - name: Configure container (other services)
include: "../common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" include: "../common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
when: when:
- "not is_metal"
- "'neutron_agent' not in group_names" - "'neutron_agent' not in group_names"
- name: Configure log directories (on metal) - name: Configure log directories (on metal)

View File

@ -63,6 +63,8 @@
- name: Configure container - name: Configure container
include: "../common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" include: "../common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
vars: vars:
extra_container_config_no_restart: extra_container_config_no_restart:
- "lxc.start.order=39" - "lxc.start.order=39"

View File

@ -43,8 +43,6 @@
- "{{ lxc_default_bind_mounts | default([]) }}" - "{{ lxc_default_bind_mounts | default([]) }}"
- "{{ list_of_bind_mounts | default([]) }}" - "{{ list_of_bind_mounts | default([]) }}"
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
when:
- not is_metal | bool
tags: tags:
- common-lxc - common-lxc
@ -57,8 +55,6 @@
- "{{ lxc_default_bind_mounts | default([]) }}" - "{{ lxc_default_bind_mounts | default([]) }}"
- "{{ list_of_bind_mounts | default([]) }}" - "{{ list_of_bind_mounts | default([]) }}"
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
when:
- not is_metal | bool
register: _mc register: _mc
tags: tags:
- common-lxc - common-lxc
@ -72,7 +68,6 @@
with_items: "{{ extra_container_config | default([]) }}" with_items: "{{ extra_container_config | default([]) }}"
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
register: _ec register: _ec
when: not is_metal | bool
tags: tags:
- common-lxc - common-lxc
@ -84,7 +79,6 @@
backup: "true" backup: "true"
with_items: "{{ extra_container_config_no_restart | default(['lxc.start.order=100']) }}" with_items: "{{ extra_container_config_no_restart | default(['lxc.start.order=100']) }}"
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
when: not is_metal | bool
tags: tags:
- common-lxc - common-lxc
@ -97,7 +91,6 @@
retries: 3 retries: 3
delay: 5 delay: 5
when: when:
- not is_metal | bool
- (_mc is defined and _mc | changed) or (_ec is defined and _ec | changed) - (_mc is defined and _mc | changed) or (_ec is defined and _ec | changed)
# Due to https://github.com/ansible/ansible-modules-extras/issues/2691 # Due to https://github.com/ansible/ansible-modules-extras/issues/2691
@ -118,7 +111,6 @@
- container_stop.rc not in [0, 2] - container_stop.rc not in [0, 2]
when: when:
- lxc_container_allow_restarts | default(True) | bool - lxc_container_allow_restarts | default(True) | bool
- not is_metal | bool
- (_mc is defined and _mc | changed) or (_ec is defined and _ec | changed) - (_mc is defined and _mc | changed) or (_ec is defined and _ec | changed)
- _lxc_container_state.stdout.find('RUNNING') != -1 - _lxc_container_state.stdout.find('RUNNING') != -1
tags: tags:
@ -137,7 +129,6 @@
until: container_start | success until: container_start | success
retries: 3 retries: 3
when: when:
- not is_metal | bool
- (_mc is defined and _mc | changed) or (_ec is defined and _ec | changed) - (_mc is defined and _mc | changed) or (_ec is defined and _ec | changed)
tags: tags:
- common-lxc - common-lxc
@ -150,6 +141,5 @@
timeout: "{{ lxc_container_wait_params.timeout | default(omit) }}" timeout: "{{ lxc_container_wait_params.timeout | default(omit) }}"
when: when:
- (_mc is defined and _mc | changed) or (_ec is defined and _ec | changed) - (_mc is defined and _mc | changed) or (_ec is defined and _ec | changed)
- not is_metal | bool
tags: tags:
- common-lxc - common-lxc

View File

@ -44,8 +44,6 @@
with_items: with_items:
- "{{ list_of_bind_mounts | default([]) }}" - "{{ list_of_bind_mounts | default([]) }}"
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
when:
- not is_metal | bool
tags: tags:
- common-nspawn - common-nspawn
@ -55,8 +53,6 @@
state: "directory" state: "directory"
with_items: with_items:
- "{{ list_of_bind_mounts | default([]) }}" - "{{ list_of_bind_mounts | default([]) }}"
when:
- not is_metal | bool
tags: tags:
- common-nspawn - common-nspawn
@ -71,7 +67,6 @@
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
register: _ec register: _ec
when: when:
- not is_metal | bool
- nspawn_systemd_version | int > 219 - nspawn_systemd_version | int > 219
tags: tags:
- common-nspawn - common-nspawn
@ -104,7 +99,6 @@
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
register: _ec register: _ec
when: when:
- not is_metal | bool
- list_of_bind_mounts | default([]) - list_of_bind_mounts | default([])
- nspawn_systemd_version | int < 220 - nspawn_systemd_version | int < 220
tags: tags:

View File

@ -19,6 +19,8 @@
user: root user: root
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/unbound-clients.yml - include: common-tasks/unbound-clients.yml
static: no static: no
when: when:

View File

@ -25,6 +25,8 @@
- src: "/openstack/log/{{ inventory_hostname }}-mysql_logs" - src: "/openstack/log/{{ inventory_hostname }}-mysql_logs"
dest: "/var/log/mysql_logs" dest: "/var/log/mysql_logs"
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
vars: vars:
list_of_bind_mounts: "{{ galera_container_bind_mounts }}" list_of_bind_mounts: "{{ galera_container_bind_mounts }}"
extra_container_config_no_restart: extra_container_config_no_restart:

View File

@ -20,6 +20,8 @@
user: root user: root
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/os-log-dir-setup.yml - include: common-tasks/os-log-dir-setup.yml
vars: vars:
log_dirs: log_dirs:

View File

@ -19,6 +19,8 @@
user: root user: root
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/os-log-dir-setup.yml - include: common-tasks/os-log-dir-setup.yml
vars: vars:
log_dirs: log_dirs:

View File

@ -22,6 +22,8 @@
- aodh - aodh
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/oslomsg-rpc-vhost-user.yml - include: common-tasks/oslomsg-rpc-vhost-user.yml
static: no static: no

View File

@ -22,6 +22,8 @@
- barbican - barbican
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/oslomsg-rpc-vhost-user.yml - include: common-tasks/oslomsg-rpc-vhost-user.yml
static: no static: no

View File

@ -19,6 +19,8 @@
user: root user: root
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/oslomsg-rpc-vhost-user.yml - include: common-tasks/oslomsg-rpc-vhost-user.yml
static: no static: no

View File

@ -23,6 +23,8 @@
- congress - congress
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- name: Configure log directories (on metal) - name: Configure log directories (on metal)
include: common-tasks/os-log-dir-setup.yml include: common-tasks/os-log-dir-setup.yml

View File

@ -25,6 +25,8 @@
- designate - designate
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/oslomsg-rpc-vhost-user.yml - include: common-tasks/oslomsg-rpc-vhost-user.yml
static: no static: no

View File

@ -21,14 +21,17 @@
- gnocchi - gnocchi
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
vars: vars:
list_of_bind_mounts: "{{ gnocchi_container_bind_mounts }}" list_of_bind_mounts: "{{ gnocchi_container_bind_mounts }}"
when: (gnocchi_storage_driver == "file") or (gnocchi_storage_driver is not defined) static: no
when:
- (gnocchi_storage_driver == "file") or (gnocchi_storage_driver is not defined)
- not is_metal
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no static: no
when: when:
- not is_metal
- gnocchi_storage_driver is defined - gnocchi_storage_driver is defined
- gnocchi_storage_driver != "file" - gnocchi_storage_driver != "file"

View File

@ -24,6 +24,8 @@
- defaults/repo_packages/openstack_services.yml - defaults/repo_packages/openstack_services.yml
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/oslomsg-rpc-vhost-user.yml - include: common-tasks/oslomsg-rpc-vhost-user.yml
static: no static: no

View File

@ -22,6 +22,8 @@
- horizon - horizon
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/os-log-dir-setup.yml - include: common-tasks/os-log-dir-setup.yml
vars: vars:
log_dirs: log_dirs:

View File

@ -22,6 +22,8 @@
- ironic - ironic
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/oslomsg-rpc-vhost-user.yml - include: common-tasks/oslomsg-rpc-vhost-user.yml
static: no static: no

View File

@ -90,6 +90,8 @@
vars: vars:
extra_container_config_no_restart: extra_container_config_no_restart:
- "lxc.start.order=19" - "lxc.start.order=19"
static: no
when: not is_metal
- name: Configure log directories (on metal) - name: Configure log directories (on metal)
include: common-tasks/os-log-dir-setup.yml include: common-tasks/os-log-dir-setup.yml

View File

@ -24,6 +24,8 @@
- magnum - magnum
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/os-log-dir-setup.yml - include: common-tasks/os-log-dir-setup.yml
vars: vars:

View File

@ -22,6 +22,9 @@
vars: vars:
extra_container_config_no_restart: extra_container_config_no_restart:
- "lxc.start.order=39" - "lxc.start.order=39"
static: no
when: not is_metal
- include: common-tasks/os-log-dir-setup.yml - include: common-tasks/os-log-dir-setup.yml
vars: vars:
log_dirs: log_dirs:

View File

@ -22,6 +22,8 @@
- octavia - octavia
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/oslomsg-rpc-vhost-user.yml - include: common-tasks/oslomsg-rpc-vhost-user.yml
static: no static: no

View File

@ -20,6 +20,8 @@
- sahara - sahara
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- name: Configure oslo messaging rpc vhost/user - name: Configure oslo messaging rpc vhost/user
include: common-tasks/oslomsg-rpc-vhost-user.yml include: common-tasks/oslomsg-rpc-vhost-user.yml

View File

@ -19,9 +19,12 @@
user: root user: root
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
vars: vars:
extra_container_config_no_restart: extra_container_config_no_restart:
- "lxc.start.order=39" - "lxc.start.order=39"
when: not is_metal
- include: common-tasks/os-log-dir-setup.yml - include: common-tasks/os-log-dir-setup.yml
vars: vars:
log_dirs: log_dirs:

View File

@ -22,6 +22,8 @@
- tacker - tacker
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/oslomsg-rpc-vhost-user.yml - include: common-tasks/oslomsg-rpc-vhost-user.yml
static: no static: no

View File

@ -25,6 +25,8 @@
- trove - trove
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/oslomsg-rpc-vhost-user.yml - include: common-tasks/oslomsg-rpc-vhost-user.yml
static: no static: no

View File

@ -24,6 +24,8 @@
vars: vars:
extra_container_config_no_restart: extra_container_config_no_restart:
- "lxc.start.order=19" - "lxc.start.order=19"
when: not is_metal
- include: common-tasks/unbound-clients.yml - include: common-tasks/unbound-clients.yml
static: no static: no
when: when:

View File

@ -34,6 +34,7 @@
list_of_bind_mounts: list_of_bind_mounts:
- mount_path: "/openstack/{{ inventory_hostname }}" - mount_path: "/openstack/{{ inventory_hostname }}"
bind_dir_path: "/var/www" bind_dir_path: "/var/www"
when: not is_metal
- include: common-tasks/unbound-clients.yml - include: common-tasks/unbound-clients.yml
static: no static: no

View File

@ -25,12 +25,15 @@
- not rsyslog_server_enabled | bool - not rsyslog_server_enabled | bool
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
vars: vars:
list_of_bind_mounts: list_of_bind_mounts:
- bind_dir_path: "{{ rsyslog_server_storage_directory }}" - bind_dir_path: "{{ rsyslog_server_storage_directory }}"
mount_path: "/openstack/{{ inventory_hostname }}/log-storage" mount_path: "/openstack/{{ inventory_hostname }}/log-storage"
extra_container_config_no_restart: extra_container_config_no_restart:
- "lxc.start.order=19" - "lxc.start.order=19"
when: not is_metal
- include: common-tasks/unbound-clients.yml - include: common-tasks/unbound-clients.yml
static: no static: no
when: when:

View File

@ -21,6 +21,8 @@
pre_tasks: pre_tasks:
- include: common-tasks/os-log-dir-setup.yml - include: common-tasks/os-log-dir-setup.yml
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
roles: roles:
- role: "unbound" - role: "unbound"
tags: tags:

View File

@ -18,6 +18,8 @@
user: root user: root
pre_tasks: pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml" - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/os-log-dir-setup.yml - include: common-tasks/os-log-dir-setup.yml
vars: vars: