Problem:
During deployment cloud-init is called including the finral module. But for some reason the yum update and puppet install does not start. I have included a touch to /tmp/myfile in the provisioning template. This line is getting executed by the final module from cloud-init. The growpart, phone-home and reboot are executed also.
When we remove /var/lib/cloud and rerun cloud-init “cloud-init -d init” and run " cloud-init modules --mode config; cloud-init modules --mode final", everything works fine.
Expected outcome:
Cloud-init final module runs yum update and installs/configures puppet.
Foreman and Proxy versions:
foreman-proxy-2.1.0-1
foreman-2.1.0-1
Foreman and Proxy plugin versions:
foreman_hooks Plugin engine for Foreman that enables running custom hook scripts on Foreman events Dominic Cleal 0.3.16
Distribution and version:
CentOS 7.8.2003
Other relevant data:
Cloud init debug information from client. (Deployed server)
-- Boot Record 01 --
The total time elapsed since completing an event is printed after the "@" character.
The time the event takes is printed after the "+" character.
Starting stage: init-local
|`->no cache found @00.01600s +00.00000s
|`->no local data found from DataSourceNoCloud @00.02400s +00.20300s
Finished stage: (init-local) 00.22800 seconds
Starting stage: init-network
|`->no cache found @07.16400s +00.00000s
|`->found network data from DataSourceNoCloudNet @07.17000s +00.42500s
|`->setting up datasource @07.64500s +00.00000s
|`->reading and applying user-data @07.74000s +00.05100s
|`->reading and applying vendor-data @07.79100s +00.00000s
|`->activating datasource @07.86200s +00.00500s
|`->config-bootcmd ran successfully @07.87500s +00.00400s
|`->config-growpart ran successfully @07.87900s +00.11000s
Finished stage: (init-network) 00.88600 seconds
Starting stage: modules-config
|`->config-runcmd ran successfully @08.92100s +00.00400s
|`->config-timezone ran successfully @08.92500s +00.00200s
Finished stage: (modules-config) 00.01600 seconds
Starting stage: modules-final
|`->config-scripts-per-once ran successfully @09.18600s +00.00100s
|`->config-scripts-per-boot ran successfully @09.18700s +00.00100s
|`->config-scripts-per-instance ran successfully @09.18800s +00.00100s
|`->running config-scripts-user with frequency once-per-instance @09.18900s +00.06700s
Finished stage: (modules-final) 00.08700 seconds
Total Time: 1.21700 seconds
-- Boot Record 02 --
The total time elapsed since completing an event is printed after the "@" character.
The time the event takes is printed after the "+" character.
Starting stage: init-local
|`->cache invalid in datasource: DataSourceNoCloudNet [seed=ds_config_seedfrom,http://foreman.xxxxxxxx/userdata/][dsmode=net] @00.00700s +00.00800s
|`->no local data found from DataSourceNoCloud @00.01900s +00.18000s
Finished stage: (init-local) 00.20500 seconds
Starting stage: init-network
|`->no cache found @01.49400s +00.00000s
|`->found network data from DataSourceNoCloudNet @01.50300s +00.40600s
|`->setting up datasource @01.98000s +00.00000s
|`->reading and applying user-data @02.05300s +00.02600s
|`->reading and applying vendor-data @02.07900s +00.00000s
|`->activating datasource @02.12200s +00.00500s
|`->config-bootcmd ran successfully @02.13300s +00.00000s
|`->config-growpart ran successfully @02.13400s +00.12100s
Finished stage: (init-network) 00.81900 seconds
Starting stage: modules-config
|`->config-runcmd previously ran @03.00800s +00.00000s
|`->config-timezone previously ran @03.00800s +00.00000s
Finished stage: (modules-config) 00.00700 seconds
Starting stage: modules-final
|`->config-scripts-per-once previously ran @03.24100s +00.00000s
|`->config-scripts-per-boot ran successfully @03.24200s +00.00000s
|`->config-scripts-per-instance previously ran @03.24200s +00.00000s
|`->config-scripts-user previously ran @03.24200s +00.00000s
|`->config-phone-home ran successfully @03.24300s +13.03200s
|`->config-power_state_change ran successfully @16.27600s +00.01300s
Finished stage: (modules-final) 13.05400 seconds
Total Time: 14.08500 seconds
-- Boot Record 03 --
The total time elapsed since completing an event is printed after the "@" character.
The time the event takes is printed after the "+" character.
Starting stage: init-local
|`->cache invalid in datasource: DataSourceNoCloudNet [seed=ds_config_seedfrom,http://foreman.xxxxx/userdata/][dsmode=net] @00.00700s +00.00500s
|`->no local data found from DataSourceNoCloud @00.01400s +00.17900s
Finished stage: (init-local) 00.19900 seconds
Starting stage: init-network
|`->no cache found @01.68800s +00.00000s
|`->found network data from DataSourceNoCloudNet @01.69700s +00.42900s
|`->setting up datasource @02.22000s +00.00000s
|`->reading and applying user-data @02.26800s +00.02700s
|`->reading and applying vendor-data @02.29500s +00.00100s
|`->activating datasource @02.33900s +00.00700s
|`->config-bootcmd ran successfully @02.35200s +00.00100s
|`->config-growpart ran successfully @02.35400s +00.12700s
Finished stage: (init-network) 00.86500 seconds
Starting stage: modules-config
|`->config-runcmd previously ran @03.41900s +00.00000s
|`->config-timezone previously ran @03.41900s +00.00000s
Finished stage: (modules-config) 00.00800 seconds
Starting stage: modules-final
|`->config-scripts-per-once previously ran @03.68800s +00.00000s
|`->config-scripts-per-boot ran successfully @03.68900s +00.00000s
|`->config-scripts-per-instance previously ran @03.68900s +00.00000s
|`->config-scripts-user previously ran @03.68900s +00.00000s
|`->config-phone-home previously ran @03.69000s +00.00000s
|`->config-power_state_change previously ran @03.69000s +00.00000s
Finished stage: (modules-final) 00.00800 seconds
Total Time: 1.08000 seconds
Template on host, according to Foreman
#cloud-config
hostname: test02.xxxxxxxx
fqdn: test02.xxxxxxxx
manage_etc_hosts: true
package_upgrade: true
users: {}
runcmd:
- [ touch, /tmp/myfile ]
# update all packages with yum
- yum clean all
- yum update -y
# install and configure puppet
- |
rpm -Uvh https://yum.puppet.com/puppet6/puppet6-release-el-7.noarch.rpm
if [ -f /usr/bin/dnf ]; then
dnf -y install puppet-agent
else
yum -t -y install puppet-agent
fi
cat > /etc/puppetlabs/puppet/puppet.conf << EOF
[main]
vardir = /opt/puppetlabs/puppet/cache
logdir = /var/log/puppetlabs/puppet
rundir = /var/run/puppetlabs
ssldir = /etc/puppetlabs/puppet/ssl
[agent]
pluginsync = true
report = true
ca_server = foreman.xxxxxx
certname = test02.xxxxxx
environment = production
server = foreman.xxxxxxxxxx
EOF
puppet_unit=puppet
/usr/bin/systemctl list-unit-files | grep -q puppetagent && puppet_unit=puppetagent
/usr/bin/systemctl enable ${puppet_unit}
# export a custom fact called 'is_installer' to allow detection of the installer environment in Puppet modules
export FACTER_is_installer=true
# passing a non-existent tag like "no_such_tag" to the puppet agent only initializes the node
/opt/puppetlabs/bin/puppet agent --config /etc/puppetlabs/puppet/puppet.conf --onetime --tags no_such_tag --server foreman.xxxxxxxxxxx --no-daemonize
/opt/puppetlabs/bin/puppet resource service puppet ensure=running
# use runcmd to grow the VG, LV and root filesystem, as cloud-init
# doesn't handle LVM resizing natively
- [ cloud-init-per, once, grow_pv, pvresize, /dev/sda2 ]
- [ cloud-init-per, once, grow_vg-lv, lvextend, --resizefs, -l, +100%FREE, /dev/mapper/vg-lv_root ]
# timezone: set the timezone for this instance
# the value of 'timezone' must exist in /usr/share/zoneinfo
timezone: Europe/Amsterdam
growpart:
mode: growpart
devices: ['/dev/sda2']
power_state:
delay: "+5"
mode: reboot
message: Bye Bye
timeout: 10
condition: True
phone_home:
url: http://foremanxxxxxxxx/unattended/built
post: []
tries: 10