From 6902fcea0947a99b780254de8b8f40f467ea4a3c Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Mon, 15 Feb 2021 14:06:54 -0700 Subject: [PATCH] Drop service facts usage This change switches from using service facts to using systemctl commands to do service checks. This is done to reduce the amount of memory used as part of the deployment. Change-Id: I0cd5b24933e50680baefd055d6e68e277ab09315 Related-Bug: #1915761 (cherry picked from commit f9100964f976dd2a590973f313fa6a2449d37b3f) --- common/deploy-steps-tasks-step-0.j2.yaml | 13 ++++++++----- .../nova/nova-compute-container-puppet.yaml | 16 ++++++++++------ deployment/time/timezone-baremetal-ansible.yaml | 4 +--- .../timesync/chrony-baremetal-ansible.yaml | 11 ++++++++--- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/common/deploy-steps-tasks-step-0.j2.yaml b/common/deploy-steps-tasks-step-0.j2.yaml index 3586d20ec4..d2b37b391f 100644 --- a/common/deploy-steps-tasks-step-0.j2.yaml +++ b/common/deploy-steps-tasks-step-0.j2.yaml @@ -7,8 +7,11 @@ - name: Ensure /var/log/journal exists become: true file: path=/var/log/journal state=directory mode=0750 owner=root group=root setype=var_log_t -- name: Populate service facts - service_facts: +- name: Check cloud-init status + shell: systemctl is-active cloud-init.service || systemctl is-enabled cloud-init.service + failed_when: false + become: true + register: cloud_init_enabled - name: Wait for cloud-init to finish, if enabled cloud_init_data_facts: filter: status @@ -18,9 +21,9 @@ not res.cloud_init_data_facts.status.v1.stage retries: 50 delay: 5 - when: > - 'cloud-init.service' in ansible_facts.services and - ansible_facts.services['cloud-init.service']['status'] == 'enabled' + when: + - cloud_init_enabled.rc is defined + - cloud_init_enabled.rc == 0 - name: Create /var/lib/container-puppet become: true no_log: True diff --git a/deployment/nova/nova-compute-container-puppet.yaml b/deployment/nova/nova-compute-container-puppet.yaml index d9b5ce38bb..eb2e0247b0 100644 --- a/deployment/nova/nova-compute-container-puppet.yaml +++ b/deployment/nova/nova-compute-container-puppet.yaml @@ -1216,8 +1216,11 @@ outputs: - name: disable KSM on compute when: not compute_ksm_enabled|bool block: - - name: Populate service facts (ksm) - service_facts: # needed to make yaml happy + - name: Check for ksm + shell: systemctl is-active ksm.service || systemctl is-enabled ksm.service + become: true + failed_when: false + register: ksm_service_check - name: disable KSM services service: name: "{{ item }}" @@ -1226,7 +1229,9 @@ outputs: with_items: - ksm.service - ksmtuned.service - when: "'ksm.service' in ansible_facts.services" + when: + - ksm_service_check.rc is defined + - ksm_service_check.rc == 0 register: ksmdisabled # When KSM is disabled, any memory pages that were shared prior to # deactivating KSM are still shared. To delete all of the PageKSM @@ -1234,13 +1239,12 @@ outputs: - name: delete PageKSM after disable ksm on compute command: echo 2 >/sys/kernel/mm/ksm/run when: - - "'ksm.service' in ansible_facts.services" + - ksm_service_check.rc is defined + - ksm_service_check.rc == 0 - ksmdisabled is changed - name: enable KSM on compute when: compute_ksm_enabled|bool block: - - name: Populate service facts (ksm) - service_facts: # needed to make yaml happy # mschuppert: we can remove the CentOS/RHEL split here when CentOS8/ # RHEL8 is available and we have the same package name providing the # KSM services diff --git a/deployment/time/timezone-baremetal-ansible.yaml b/deployment/time/timezone-baremetal-ansible.yaml index e40720d581..91a3fb06f3 100644 --- a/deployment/time/timezone-baremetal-ansible.yaml +++ b/deployment/time/timezone-baremetal-ansible.yaml @@ -48,15 +48,13 @@ outputs: timezone: name: "{{ timezone }}" register: timezone_result - - name: Populate service facts - service_facts: - name: Restart services when: - timezone_result.changed - - (item + ".service") in ansible_facts.services service: name: "{{ item }}" state: restarted with_items: - rsyslog - crond + failed_when: false diff --git a/deployment/timesync/chrony-baremetal-ansible.yaml b/deployment/timesync/chrony-baremetal-ansible.yaml index 2124da77a3..c16f33de5c 100644 --- a/deployment/timesync/chrony-baremetal-ansible.yaml +++ b/deployment/timesync/chrony-baremetal-ansible.yaml @@ -108,14 +108,19 @@ outputs: proto: udp step_config: '' host_prep_tasks: - - name: Populate service facts (chrony) - service_facts: # needed to make yaml happy + - name: Check for NTP service + shell: systemctl is-active ntpd.service || systemctl is-enabled ntpd.service + failed_when: false + become: true + register: ntp_service_check - name: Disable NTP before configuring Chrony service: name: ntpd state: stopped enabled: no - when: "'ntpd.service' in ansible_facts.services" + when: + - ntp_service_check.rc is defined + - ntp_service_check.rc == 0 - name: Install, Configure and Run Chrony include_role: name: chrony