user-data only executed partly

Asked by Andy Kannberg

Hi all,

I try to use cloud-init for configuring ubuntu 22.04 LTS / Ubuntu 23.10 instances on KVM. For this I have created a user-data file to setup users, network config, among others. It looks like this:

#cloud-config
hostname: devdba001
fqdn: devdba001.dev.biotonus.net

groups:
  - admingroup: [root,sys]

password: password
chpasswd:
  expire: false

users:
  - name: andyk
    passwd: $6$ZWqWQ3QLeJ0hE5vd$Ikox3yjpeKzN38mEFaQSCORu2AEa.SqXs7GI1J3FaGMTc.s7Jj3Oyjekb5vpAv4nOsYtqltGHnXCV70GBLmqq.
    lock_passwd: false
    groups: [sudo, admingroup]
    sudo: ALL=(ALL) NOPASSWD:ALL
    shell: /bin/bash
  - name: andres
    passwd: $6$ZWqWQ3QLeJ0hE5vd$Ikox3yjpeKzN38mEFaQSCORu2AEa.SqXs7GI1J3FaGMTc.s7Jj3Oyjekb5vpAv4nOsYtqltGHnXCV70GBLmqq.
    lock_passwd: false
    groups: [sudo, admingroup]
    sudo: ALL=(ALL) NOPASSWD:ALL
    shell: /bin/bash

# Assign static IP address to primary interface

write_files:
  - path: /etc/netplan/50-cloud-init.yaml
    permissions: '0600'
    owner: root:root
    content: |
      network:
        version: 2
        renderer: networkd
        ethernets:
           enp1s0:
               dhcp4: no
               addresses: [5.39.221.153/25]
               routes:
               - to: default
                 via: 5.39.221.129
               nameservers:
                  addresses: [5.39.221.129,8.8.8.8,8.8.4.4]
           enp2s0:
               dhcp4: no
               addresses: [192.168.60.3/24]

growpart:
  mode: auto
  devices: ["/"]
  ignore_growroot_disabled: true

runcmd:
  - [ netplan, apply ]
  - [ apt-get, update ]
# - [ systemctl, enable, ufw ]
# - [ ufw, enable ]
# - [ ufw, allow, ssh ]
# - [ systemctl, enable, ssh ]
#  - [ ufw, default, allow, outgoing ]
# - [ ufw, default, deny, incoming ]

# Specify Power State:
power_state:
  delay: "1"
  mode: reboot
  message: Rebooting after cloud-init
  timeout: 30
  condition: True

The parts of user creation and the write_file command are executed flawlessly. However, setting the password for the ubuntu user doesn't work either.

As you also can see I commented out some lines under the 'runcmd' part, as they just won't execute. The first two lines, "netplan apply"and "apt-get update" are executed, the rest is not executed. The same goes for the 'growpart' lines. They are not executed.

I use the Ubuntu cloud images "mantic-server-cloudimg-amd64.img" and "jammy--server-cloudimg-amd64.img" as basis, which are then copied to "hostname.qcow2"

I checked the log file /var/log/cloud-init-output.log but it didn't show anything about wrong configuration or something. There is no mention whatsoever of the growpart nor about the runcmd lines failing or being ignored (I do see the two lines that are executed.)

Can anyone shed a light on this or perhaps help me with debugging this problem ?

best regards,
Andy Kannberg

Question information

Language:
English Edit question
Status:
Open
For:
Ubuntu cloud-init Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

Can you help with this problem?

Provide an answer of your own, or ask Andy Kannberg for more information if necessary.

To post a message you must log in.