From b1bda7f47c5d9422dc638d74cd7866cae868a9e6 Mon Sep 17 00:00:00 2001 From: Rabi Mishra Date: Tue, 1 Dec 2020 16:38:50 +0530 Subject: [PATCH] Ensure cloud-init has finished before puppet run Sometimes cloud-init does not finish before we start applying configs with ansible/puppet and can lead to issues. This would ensure that cloud-init has finished before ansible/puppet configs. With os-collect-config we used to ensure that with: $ sudo cat /usr/lib/systemd/system/os-collect-config.service [Unit] Description=Collect metadata and run hook commands. After=cloud-final.service Before=crond.service With baremetal provisioning after config-drive support, this would also be useful when firstboot config is used. Change-Id: I35c7c1610af08b33497f43090761aaa55d3a9efc (cherry picked from commit 1879441b3c3e771a5754ed9689f64dde2a927efb) --- common/deploy-steps-tasks-step-0.j2.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/common/deploy-steps-tasks-step-0.j2.yaml b/common/deploy-steps-tasks-step-0.j2.yaml index 3634eb4626..3203a43ac3 100644 --- a/common/deploy-steps-tasks-step-0.j2.yaml +++ b/common/deploy-steps-tasks-step-0.j2.yaml @@ -7,6 +7,20 @@ - 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: Wait for cloud-init to finish, if enabled + cloud_init_data_facts: + filter: status + register: res + until: > + res.cloud_init_data_facts.status.v1.stage is defined and + 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' - name: Create /var/lib/container-puppet become: true no_log: True