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
This commit is contained in:
Rabi Mishra 2020-12-01 16:38:50 +05:30
parent d04421d48a
commit 1879441b3c

View File

@ -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