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"
dest: "/var/log/ceph"
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
when: not is_metal
static: no
vars:
list_of_bind_mounts: "{{ ceph_container_bind_mounts }}"
- include: common-tasks/unbound-clients.yml

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,6 +20,8 @@
user: root
pre_tasks:
- 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
vars:
log_dirs:

View File

@ -19,6 +19,8 @@
user: root
pre_tasks:
- 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
vars:
log_dirs:

View File

@ -22,6 +22,8 @@
- aodh
pre_tasks:
- 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
static: no

View File

@ -22,6 +22,8 @@
- barbican
pre_tasks:
- 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
static: no

View File

@ -19,6 +19,8 @@
user: root
pre_tasks:
- 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
static: no

View File

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

View File

@ -25,6 +25,8 @@
- designate
pre_tasks:
- 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
static: no

View File

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

View File

@ -24,6 +24,8 @@
- defaults/repo_packages/openstack_services.yml
pre_tasks:
- 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
static: no

View File

@ -22,6 +22,8 @@
- horizon
pre_tasks:
- 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
vars:
log_dirs:

View File

@ -22,6 +22,8 @@
- ironic
pre_tasks:
- 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
static: no

View File

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

View File

@ -24,6 +24,8 @@
- magnum
pre_tasks:
- 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
vars:

View File

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

View File

@ -22,6 +22,8 @@
- octavia
pre_tasks:
- 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
static: no

View File

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

View File

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

View File

@ -22,6 +22,8 @@
- tacker
pre_tasks:
- 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
static: no

View File

@ -25,6 +25,8 @@
- trove
pre_tasks:
- 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
static: no

View File

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

View File

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

View File

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

View File

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

View File

@ -18,6 +18,8 @@
user: root
pre_tasks:
- 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
vars: