Cloud-init template not running for Ubuntu installs

Problem:
I’m provisioning Ubuntu VMWare templates via cloud-init. The “User data template” runs fine and sets the IP/hostname correctly. The “Cloud-init template” does not run. It is the same for Ubuntu 20.04 and 18.04.

Is there anything that needs to be configured extra for Ubuntu to make it work?

I can’t see any apparent errors in the foreman log files.
I have configured and used the same Foreman cloud-init templates for Centos 7/8 and they work fine.

Expected outcome:
The “Cloud-init template” to be run during provisioning.
Foreman and Proxy versions:
FOREMAN: 2.2.1
KATELLO 3.17
Distribution and version:
Server: CentOS 7
Client: Ubuntu 20.04/18.04
Other relevant data:

Those templates are just examples, we don’t test all of them over time. If you spot any problems please file PR and fix this for us! Thanks.

Hi Izap.

Maybe I wasn’t clear enough. The “user-data” template is the only template that seems to render during provisioning. The “cloud-init” template does not seem to get rendered. This seems only to be true for Ubuntu and not CentOS.

2020-12-03T10:03:43 [I|app|4ef60cf9] Parameters: {“utf8”=>“✓”, “authenticity_token”=>“oTw33jXi/YFTgFBxLdbIe7//09gGPD6KKw8AJ8dq5Fly
jAU8OW7H0pw6zsgaf+379DhbgKT0qnnvF6fWh/jRGw==”, “host”=>{“name”=>“d2seelm-lx9026”, “organization_id”=>“1”, “location_id”=>“2”, “hostg
roup_id”=>“9”, “content_facet_attributes”=>{“lifecycle_environment_id”=>“2”, “content_view_id”=>“10”, “content_source_id”=>“1”}, “ma
naged”=>“true”, “progress_report_id”=>"[FILTERED]", “type”=>“Host::Managed”, “interfaces_attributes”=>{“0”=>{"_destroy"=>“0”, “type”
=>“Nic::Managed”, “identifier”=>"", “name”=>“d2seelm-lx9026”, “domain_id”=>“4”, “subnet_id”=>"", “ip”=>"", “ip6”=>"", “managed”=>“1”
, “primary”=>“1”, “provision”=>“1”, “execution”=>“1”, “virtual”=>“0”, “tag”=>"", “attached_to”=>"", “compute_attributes”=>{“type”=>"
VirtualVmxnet3", “network”=>“dvportgroup-67”}}}, “compute_attributes”=>{“cpus”=>“1”, “corespersocket”=>“1”, “memory_mb”=>“4096”, “fi
rmware”=>“bios”, “cluster”=>“D2-01”, “resource_pool”=>“D2-01-Medium”, “path”=>"/Datacenters/D2/vm/linux/Dev", “guest_id”=>“ubuntu64G
uest”, “hardware_version”=>“vmx-15”, “memoryHotAddEnabled”=>“1”, “cpuHotAddEnabled”=>“1”, “add_cdrom”=>“0”, “boot_order”=>[“network”
, “disk”], “start”=>“1”, “annotation”=>"", “scsi_controllers”=>"{“scsiControllers”:[{“type”:“ParaVirtualSCSIController”,“key
“:1000}],“volumes”:[{“thin”:false,“name”:“Hard disk”,“mode”:“persistent”,“controllerKey”:1000,“sizeGb”:25,“storageP
od”:“D2-01-01”,“datastore”:null,“eagerZero”:false}]}”, “image_id”=>“5030811d-f401-8d04-dd7d-dfb533352ed8”}, “architecture_id”
=>“1”, “operatingsystem_id”=>“6”, “provision_method”=>“image”, “build”=>“1”, “medium_id”=>“8”, “ptable_id”=>“113”, “pxe_loader”=>“PX
ELinux BIOS”, “disk”=>”", “root_pass”=>"[FILTERED]", “is_owned_by”=>“5-Users”, “enabled”=>“1”, “comment”=>"", “overwrite”=>“false”},
“media_selector”=>“install_media”}
2020-12-03T10:03:43 [I|app|4ef60cf9] Rendering UserData template for d2seelm-lx9026.example.com
2020-12-03T10:03:44 [I|app|4ef60cf9] Revoked old certificates and enabled autosign for UserData
2020-12-03T10:03:44 [I|app|4ef60cf9] Adding Compute instance for d2seelm-lx9026.example.com

User data and cloud-init are two different kinds with different workflows:

Thanks Izap. I have already configured both of the mentioned templates.

I installed a CentOS server and checked the cloud-init logs. There I see a seed to the foreman server to fetch the cloud-init template.

I guess there is a problem with my cloud.cfg file in the VMWare Ubuntu image. It in not processing the /etc/cloud/cloud.cfg.d/10_foreman.cfg:

datasource_list: [NoCloud]
datasource:
  NoCloud:
    seedfrom: http://satellite.example.com/userdata/

Here is the cloud.cfg file in the Ubuntu VMware image. Help would be very much appreciated:

# The top level settings are used as module
# and system configuration.

# This will cause the set+update hostname module to not operate (if true)
preserve_hostname: false

# The modules that run in the 'init' stage
cloud_init_modules:
 - bootcmd
 - set_hostname
 - update_hostname
 - update_etc_hosts

# The modules that run in the 'config' stage
cloud_config_modules:
# Emit the cloud config ready event
# this can be used by upstart jobs for 'start on cloud-config'.
 - locale
 - grub-dpkg
 - runcmd

# The modules that run in the 'final' stage
cloud_final_modules:
 - scripts-per-once
 - scripts-per-boot
 - scripts-per-instance
 - scripts-user
 - phone-home

# System and/or distro specific settings
# (not accessible to handlers/transforms)
system_info:
# This will affect which distro class gets used
   distro: ubuntu
   network:
     renderers: ['netplan', 'eni', 'sysconfig']
   # Other config here will be given to the distro class and/or path classes
  paths:
      cloud_dir: /var/lib/cloud/
      templates_dir: /etc/cloud/templates/
      upstart_dir: /etc/init/
  ssh_svcname: sshd

disable_vmware_customization: false

manage_etc_hosts: true

# vim:syntax=yaml

Thanks in advance! :slight_smile:

I can’t help you with debugging cloud-init, sorry. I remember it was a nightmare when I was doing this for the last time.