<p>The answer was to include the <code>runcmd</code> within the autoinstall, like that:</p>
<pre><code>package_update: true
package_upgrade: true

autoinstall:
  version: 1
  locale: en_US
  keyboard:
    layout: fr
  identity:
    hostname: user
    username: user
    password: &quot;$6$xyz$waX2p....&quot;
  ssh:
    install-server: true
  packages:
    - openssh-server
  package_upgrade: true
  late-commands:
    - shutdown -h now
  runcmd:
    - apt install -y curl
</code></pre>

CC BY-SA 4.0
2023-10-04T16:28:04.247Z
2023-10-04T16:28:04.247Z
Bastien
<p>I am trying to set up an Ubuntu Server 22.04 installation using autoinstall and cloud-init. I have two USB keys (I followed this tutorial <a href="https://www.jimangel.io/posts/automate-ubuntu-22-04-lts-bare-metal/" rel="nofollow noreferrer">https://www.jimangel.io/posts/automate-ubuntu-22-04-lts-bare-metal/</a>):</p>
<ul>
<li>One with an ISO image of Ubuntu Server 22.04 with autoinstall enabled.</li>
<li>The second one contains two YAML files: <code>meta-data</code> (empty file) and <code>user-data</code>.</li>
</ul>
<p>When I try to install the new setup on a machine, ubuntu gets installed, the user is created <strong>but</strong> when the computer reboots, none of the packages (see user-data) seem to be installed. Even simple tests like creating a directory using runcmd do not persist.</p>
<p><strong>Debugging Attempts</strong></p>
<p>Checked cloud-init logs at /var/log/cloud-init.log and /var/log/cloud-init-output.log but did not find any relevant errors or warnings.
Tried simplifying the user-data file to just create a directory, but it did not work.</p>
<p>I'd appreciate any pointers to debug and resolve this issue.</p>
<p>Here is my user-data file:</p>
<pre><code>#cloud-config
package_update: true
package_upgrade: true

autoinstall:
  version: 1
  locale: en_US
  keyboard:
    layout: fr
  identity:
    hostname: user
    username: user
    password: &quot;$6$xyz$waX2p....&quot;
  ssh:
    install-server: true
  packages:
    - openssh-server
  package_upgrade: true
  late-commands:
    - shutdown -h now
runcmd:
  - apt install -y curl autossh unzip
  - apt install -y docker.io
  - systemctl start docker
  - systemctl enable docker
  - mkdir /home/bob
</code></pre>

<ubuntu><cloud-init>
Ubuntu Server 22.04 Autoinstall and Cloud-Init Not Executing Commands
Bastien
# Ubuntu Server 22.04 Autoinstall and Cloud-Init Not Executing Commands

(Asked by: username_0 on 2023-10-04)

I am trying to set up an Ubuntu Server 22.04 installation using autoinstall and cloud-init. I have two USB keys (I followed this tutorial https://www.jimangel.io/posts/automate-ubuntu-22-04-lts-bare-metal/):

One with an ISO image of Ubuntu Server 22.04 with autoinstall enabled.
The second one contains two YAML files: meta-data (empty file) and user-data.

When I try to install the new setup on a machine, ubuntu gets installed, the user is created but when the computer reboots, none of the packages (see user-data) seem to be installed. Even simple tests like creating a directory using runcmd do not persist.
Debugging Attempts
Checked cloud-init logs at /var/log/cloud-init.log and /var/log/cloud-init-output.log but did not find any relevant errors or warnings.
Tried simplifying the user-data file to just create a directory, but it did not work.
I'd appreciate any pointers to debug and resolve this issue.
Here is my user-data file:
#cloud-config
package_update: true
package_upgrade: true

autoinstall:
  version: 1
  locale: en_US
  keyboard:
    layout: fr
  identity:
    hostname: user
    username: user
    password: "$6$xyz$waX2p...."
  ssh:
    install-server: true
  packages:
    - openssh-server
  package_upgrade: true
  late-commands:
    - shutdown -h now
runcmd:
  - apt install -y curl autossh unzip
  - apt install -y docker.io
  - systemctl start docker
  - systemctl enable docker
  - mkdir /home/bob

**Tags:** ubuntu, cloud-init


---

## 1 answers

### Answer by username_0 on 2023-10-04. Score: 0

The answer was to include the runcmd within the autoinstall, like that:
package_update: true
package_upgrade: true

autoinstall:
  version: 1
  locale: en_US
  keyboard:
    layout: fr
  identity:
    hostname: user
    username: user
    password: "$6$xyz$waX2p...."
  ssh:
    install-server: true
  packages:
    - openssh-server
  package_upgrade: true
  late-commands:
    - shutdown -h now
  runcmd:
    - apt install -y curl


---

