From f6c0acc7fe7e4571fc923d85422d7781b6d35151 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Mon, 15 Feb 2021 14:38:13 -0700 Subject: [PATCH] Reduce fact gathering We've seen that large amount of facts for hosts have a direct impact on task execution as part of the deployment. This change reduces the amount of data that we are collecting when we use facts and leverages more targeted methods to collect the required information. Change-Id: I49e6ca02c2b4791641fb27ebf258ef6c9d52dd9e Related-Bug: #1915761 --- .../roles/tripleo_kernel/tasks/reboot.yaml | 17 +++++++++++++++-- .../roles/tripleo_lvmfilter/tasks/main.yml | 11 +++++++---- .../tripleo_nodes_validation/tasks/main.yml | 5 +++-- .../tasks/tripleo_podman_install.yml | 3 ++- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/tripleo_ansible/roles/tripleo_kernel/tasks/reboot.yaml b/tripleo_ansible/roles/tripleo_kernel/tasks/reboot.yaml index 1c82a6b6b..51c3107da 100644 --- a/tripleo_ansible/roles/tripleo_kernel/tasks/reboot.yaml +++ b/tripleo_ansible/roles/tripleo_kernel/tasks/reboot.yaml @@ -29,12 +29,25 @@ block: - name: Update facts before attempting to disable interfaces setup: - - name: Find the ifcg files + - name: Find the ifcfg files find: paths: /etc/sysconfig/network-scripts/ patterns: ifcfg-* register: ifcfg_files - + # NOTE(mwhahaha): On computes collecting all the network facts is a huge + # performance issue. So let's only get the ansible facts for the ifcfg + # files which will avoid all the tap interfaces. This takes a while but + # results in less memory utilization for the rest of the deployment. + - name: Get ifcfg facts + setup: + gather_subset: + - '!all' + - '!min' + - network + filter: "{{ 'ansible_' + item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_') }}" + loop: "{{ ifcfg_files.files |flatten(levels=1)}}" + loop_control: + label: "{{ item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_') }}" - name: Replace BOOTPROTO to none for interfaces which does not have IP replace: dest: "{{ item.path }}" diff --git a/tripleo_ansible/roles/tripleo_lvmfilter/tasks/main.yml b/tripleo_ansible/roles/tripleo_lvmfilter/tasks/main.yml index f0b8d45cf..662f9baed 100644 --- a/tripleo_ansible/roles/tripleo_lvmfilter/tasks/main.yml +++ b/tripleo_ansible/roles/tripleo_lvmfilter/tasks/main.yml @@ -15,12 +15,15 @@ # under the License. -- name: gather package facts - package_facts: - manager: auto +- name: Check if lvm2 is installed + shell: rpm -q lvm2 + become: true + failed_when: false + register: lvm_pkg_check - name: gather allowed block devices list when: - - "'lvm2' in ansible_facts.packages" + - lvm_pkg_check.rc is defined + - lvm_pkg_check.rc == 0 - tripleo_tripleo_lvmfilter_enabled or tripleo_tripleo_lvmfilter_dry_run block: - name: collect in-use lvm2 devices list diff --git a/tripleo_ansible/roles/tripleo_nodes_validation/tasks/main.yml b/tripleo_ansible/roles/tripleo_nodes_validation/tasks/main.yml index 306fcac95..c04c83203 100644 --- a/tripleo_ansible/roles/tripleo_nodes_validation/tasks/main.yml +++ b/tripleo_ansible/roles/tripleo_nodes_validation/tasks/main.yml @@ -14,12 +14,13 @@ # License for the specific language governing permissions and limitations # under the License. -- name: Collect Network Facts +- name: Collect default network fact setup: gather_subset: - '!all' - - '!any' + - '!min' - network + filter: 'ansible_default_ipv4' - name: Check Default IPv4 Gateway availability command: "ping -w 10 -c 1 {{ ansible_facts.default_ipv4.gateway }}" diff --git a/tripleo_ansible/roles/tripleo_podman/tasks/tripleo_podman_install.yml b/tripleo_ansible/roles/tripleo_podman/tasks/tripleo_podman_install.yml index 9bd30296c..463f89c5d 100644 --- a/tripleo_ansible/roles/tripleo_podman/tasks/tripleo_podman_install.yml +++ b/tripleo_ansible/roles/tripleo_podman/tasks/tripleo_podman_install.yml @@ -33,7 +33,8 @@ gather_subset: - '!all' - '!min' - - 'interfaces' + - 'network' + filter: 'ansible_interfaces' - name: Delete legacy cni0 interface (podman < 1.6) command: ip link delete cni0