Gather minimal facts in common playbooks

The common playbooks for cinder, neutron and nova have an initial
facts gathering step.

This patch switches from implicit gather_facts to direct use of
the ansible setup module. The minimum set of facts are gathered,
and an additional filtered set of facts about the target processor
count is gathered. The processor count is used in many service
templates to set the number or threads/processes used.

This approach significantly reduces the size of the gathered
facts which cannot be achieved directly with a gather_subset
of '!all,min,hardware'.

In addition, all uses of ansible facts are converted to
ansible_facts[].

Change-Id: Id29f7344da7f71c9513d62c939ce2baead6ef451
This commit is contained in:
Jonathan Rosser 2021-03-01 12:38:35 +00:00
parent b5214dfd5e
commit 3f1c6c0626
3 changed files with 45 additions and 6 deletions

View File

@ -15,9 +15,22 @@
- name: Gather cinder facts
hosts: "{{ cinder_hosts }}"
gather_facts: "{{ osa_gather_facts | default(True) }}"
gather_facts: false
tags:
- always
tasks:
- name: Gather minimal facts for cinder
setup:
gather_subset:
- "!all"
- min
when: osa_gather_facts | default(True)
- name: Gather additional facts for cinder
setup:
gather_subset: "{{ cinder_gather_subset | default('processor_count') }}"
filter: "{{ cinder_gather_filter | default('ansible_processor*') }}"
when: osa_gather_facts | default(True)
- name: Install cinder services
hosts: "{{ cinder_hosts }}"

View File

@ -15,9 +15,22 @@
- name: Gather neutron facts
hosts: "{{ neutron_hosts }}"
gather_facts: "{{ osa_gather_facts | default(True) }}"
gather_facts: false
tags:
- always
tasks:
- name: Gather minimal facts for neutron
setup:
gather_subset:
- "!all"
- min
when: osa_gather_facts | default(True)
- name: Gather additional facts for neutron
setup:
gather_subset: "{{ neutron_gather_subset | default('processor_count') }}"
filter: "{{ neutron_gather_filter | default('ansible_processor*') }}"
when: osa_gather_facts | default(True)
- name: Install neutron services
hosts: "{{ neutron_hosts }}"
@ -55,8 +68,8 @@
include_tasks: "../common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
vars:
list_of_bind_mounts:
- bind_dir_path: "{{ (ansible_pkg_mgr == 'apt' and ansible_distribution_release != 'focal') | ternary('/lib/modules', '/usr/lib/modules') }}"
mount_path: "{{ (ansible_pkg_mgr == 'apt' and ansible_distribution_release != 'focal') | ternary('/lib/modules', '/usr/lib/modules') }}"
- bind_dir_path: "{{ (ansible_facts['pkg_mgr'] == 'apt' and ansible_facts['distribution_release'] != 'focal') | ternary('/lib/modules', '/usr/lib/modules') }}"
mount_path: "{{ (ansible_facts['pkg_mgr'] == 'apt' and ansible_facts['distribution_release'] != 'focal') | ternary('/lib/modules', '/usr/lib/modules') }}"
extra_container_config:
- "lxc.cgroup.devices.allow=a *:* rmw"
extra_container_config_no_restart:

View File

@ -15,14 +15,27 @@
- name: Gather nova facts
hosts: "{{ nova_hosts }}"
gather_facts: "{{ osa_gather_facts | default(True) }}"
gather_facts: false
tags:
- always
tasks:
- name: Gather minimal facts for nova
setup:
gather_subset:
- "!all"
- min
when: osa_gather_facts | default(True)
- name: Gather additional facts for nova
setup:
gather_subset: "{{ nova_gather_subset | default('processor_count') }}"
filter: "{{ nova_gather_filter | default('ansible_processor*') }}"
when: osa_gather_facts | default(True)
- name: Install nova services
hosts: "{{ nova_hosts }}"
serial: "{{ nova_serial }}"
gather_facts: "{{ osa_gather_facts | default(True) }}"
gather_facts: false
user: root
environment: "{{ deployment_environment_variables | default({}) }}"
vars_files: