Problem Description:
EDIT: autoinstall not going through the entire late-commands, and rebooted after doing the first command.
EDIT2: autoinstall doesn’t run curtin commands in 22.04 server
I wanna create and enable a systemd service that would show the IP without logging in. I tried via Systemd service:
late-commands:
- sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /target/etc/ssh/sshd_config
- curtin in-target --target=/target -- bash -c 'cat > /etc/systemd/system/show-ip-issue.service <<EOF
[Unit]
Description=Update /etc/issue with Ubuntu version and IP
After=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/bash -c "echo -e \'Ubuntu \$(lsb_release -rs)\\nSystem in barebones state\\nGive Ubuntu IP to IT for deployment\\n\$(hostname -I)\n\' > /etc/issue"
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOF'
- curtin in-target --target=/target -- systemctl daemon-reload
- curtin in-target --target=/target -- systemctl enable show-ip-issue.service
However, it doesn’t seem to show up on the target computer
Instead of using late-commands perhaps you could use cloud-init commands at the end of your autoinstall file. They might look something like this:
user-data:
disable_root: false
write_files:
- content: |
[Unit]
Description=Update /etc/issue with Ubuntu version and IP
After=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/bash -c "echo -e \'Ubuntu \$(lsb_release -rs)\\nSystem in barebones state\\nGive Ubuntu IP to IT for deployment\\n\$(hostname -I)\n\' > /etc/issue"
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
path: /etc/systemd/system/show-ip-issue.service
permissions: '0644'
runcmd:
- |
systemctl daemon-reload
systemctl enable show-ip-issue.service
You might want to use systemctl enable --now for that last command since the cloud-init commands won’t run until the first boot. I guess that means the very first login prompt won’t show this customization.