Hey guys!
I’m trying to install some applications with curtin via snap during installation phase. I get the follwing error:
error: cannot communicate with server: Post http://localhost/v2/snaps/lxd: dial unix /run/snapd.socket: connect: no such file or directory
curtin: Installation failed with exception: Unexpected error while running command.
Command: ['curtin', 'in-target', '--', 'snap', 'install', 'lxd', '--classic']
Exit code: 1
Reason: -
Stdout: error: cannot communicate with server: Post http://localhost/v2/snaps/lxd: dial unix /run/snapd.socket: connect: no such file or directory
Stderr: ''
Any idea what I am doing wrong? It seams that the snapd is not working. Starting it manually before the installation is getting ignored because of chroot.
late_commands:
[...]
install_00: ["curtin", "in-target", "--", "snap", "install", "lxd", "--classic"]
install_01: ["curtin", "in-target", "--", "snap", "install", "conjure-up", "--classic"]
install_02: ["curtin", "in-target", "--", "snap", "install", "kubectl", "--classic"]
BR
I would add a late_command before trying to install lxd that restarts snapd such as (you will need to convert to late_command):
$ systemctl restart snapd
I have had issues in the past with something similar and this seemed to fix the issue.
Doesn’t work. If I put a systemctl restart snapd in front I’ll get the chroot error:
Running command ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmp8jcuz8xn/target', 'sh', '-c', 'systemctl restart snapd && snap install lxd --classic'] with allowed return codes [0] (capture=False) Running in chroot, ignoring request: restart error: cannot communicate with server: Post http://localhost/v2/snaps/lxd: dial unix /run/snapd.socket: connect: no such file or directory
It won’t work because the target does not have snapd running. This is a bug report/feature request we have already made the curtin team to support…
Hi,
Ryan from curtin team here. If you’d like to install a set of snaps in your target image, I suggest that you pass some cloud-config into the target.
https://cloudinit.readthedocs.io/en/latest/topics/modules.html#snap
On target first boot, cloud-init handles installing snaps after networking and snapd are up and running.
Thank you andreserl and rasharper! Will have a look into it
Doesn’t work. Could someone tell me what I am doing wrong?
If I am getting this correct, I have to add a “snap” section inside the cloud-init file:
/etc/maas/preseeds/curtin_userdata_ubuntu_amd64_generic_bionic
It looks like the following:
#cloud-config
debconf_selections:
maas: |
{{for line in str(curtin_preseed).splitlines()}}
{{line}}
{{endfor}}
early_commands:
{{if third_party_drivers and driver}}
[...]
late_commands:
maas: [...]
snap:
commands:
00: snap install conjure-up
write_files:
userconfig:
[...]
But I don’t see anything inside the log file and conjure-up isn’t installed after deployment
There is useful info in a closed Set default cloud-init - #2 by cgrabowski , but the best explanation is in https://ubuntu.com/blog/customising-maas-installs to use curtin --in-target --
.
I ended up with the following customization and I hope it helps the next person:
$ cat /etc/maas/preseeds/curtin_userdata
#cloud-config
debconf_selections:
maas: |
{{for line in str(curtin_preseed).splitlines()}}
{{line}}
{{endfor}}
early_commands:
{{if third_party_drivers and driver}}
...
{{endif}}
write_files:
install_packages:
path: /home/ubuntu/install_packages.sh
permissions: '0755'
content: |
#!/bin/bash
set -eu
DEBIAN_FRONTEND=noninteractive
GENERIC_PACKAGES=(python3-pip)
sudo DEBIAN_FRONTEND=${DEBIAN_FRONTEND} apt-get install --verbose-versions ${GENERIC_PACKAGES[@]} -y
late_commands:
maas: [wget, '--no-proxy', {{node_disable_pxe_url|escape.json}}, '--post-data', {{node_disable_pxe_data|escape.json}}, '-O', '/dev/null']
install_nvidia_drivers: curtin in-target -- bash -x /home/ubuntu/install_packages
{{if third_party_drivers and driver}}
...
{{endif}}
system
Closed
26 June 2024 18:49
9
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.