From 3f1c6c0626bc2709ac5e7ad52ee76b1b8aca92a9 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Mon, 1 Mar 2021 12:38:35 +0000 Subject: [PATCH] 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 --- playbooks/common-playbooks/cinder.yml | 15 ++++++++++++++- playbooks/common-playbooks/neutron.yml | 19 ++++++++++++++++--- playbooks/common-playbooks/nova.yml | 17 +++++++++++++++-- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/playbooks/common-playbooks/cinder.yml b/playbooks/common-playbooks/cinder.yml index 72d1b95595..4764d369ed 100644 --- a/playbooks/common-playbooks/cinder.yml +++ b/playbooks/common-playbooks/cinder.yml @@ -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 }}" diff --git a/playbooks/common-playbooks/neutron.yml b/playbooks/common-playbooks/neutron.yml index 20f9a67b9b..94fd9bc491 100644 --- a/playbooks/common-playbooks/neutron.yml +++ b/playbooks/common-playbooks/neutron.yml @@ -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: diff --git a/playbooks/common-playbooks/nova.yml b/playbooks/common-playbooks/nova.yml index bd8f236c9d..f5aad2774e 100644 --- a/playbooks/common-playbooks/nova.yml +++ b/playbooks/common-playbooks/nova.yml @@ -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: