Hi
I try to write my own lxd preseed file and containers cloud-init files to use and restore volume. my test here assume that my volume named ‘myvolume’ is a volume linked to the /home folder of the container. The commands used to create the volume are lxc storage volume create default myvolume
and lxc storage volume attach default myvolume mycontainer /home
For the moment my preseed file for lxd default config is:
config:
core.https_address: '[::]:8443'
core.trust_password: true
images.auto_update_interval: "0"
networks:
- config:
ipv4.address: 10.111.174.1/24
ipv4.nat: "true"
ipv6.address: none
description: "My Network"
name: lxdbr0
type: bridge
storage_pools:
- config:
source: /var/snap/lxd/common/lxd/storage-pools/default
description: ""
name: default
driver: dir
profiles:
- config: {}
description: Default LXD profile used by virtbazx
devices:
eth0:
name: eth0
network: lxdbr0
type: nic
root:
path: /
pool: default
type: disk
name: virtbazx-default
cluster:
And my container cloud-init file is:
#cloud-config
timezone: Europe/Paris
hostname: builder-vhost
groups:
- ansible
users:
- name: myuser
sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: sudo
shell: /bin/bash
ssh_authorized_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGchBXUfJluldcK9FqIA887w/YPSPOL8m+A9TI5GleTL myuser@builder-vhost
ssh_import_id: myuser
ssh_redirect_user: true
- name: ansible
groups: ansible
ssh_authorized_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGchBXUfJluldcK9FqIA887w/YPSPOL8m+A9TI5GleTL ansible@builder-vhost
ssh_import_id: ansible
ssh_redirect_user: true
packages:
- openssh-client
- openssh-server
- python3
package_update: false
package_upgrade: false
ssh_deletekeys: true
ssh_keys:
ed25519_private: |
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACAXN0tY8HbDIK2lM7jZz0IEMpZny3bGW2lEOfWOU8hTxAAAAJDSXdY+0l3W
PgAAAAtzc2gtZWQyNTUxOQAAACAXN0tY8HbDIK2lM7jZz0IEMpZny3bGW2lEOfWOU8hTxA
AAAEAhCZQjRFqPlsQle97+P5pMO2lNp1t20E12gX657mozgBc3S1jwdsMgraUzuNnPQgQy
lmfLdsZbaUQ59Y5TyFPEAAAADXJvb3RAbHhtYXN0ZXI=
-----END OPENSSH PRIVATE KEY-----
ed25519_public: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBc3S1jwdsMgraUzuNnPQgQylmfLdsZbaUQ59Y5TyFPE root@builder-vhost
write_files:
- path: /etc/ssh/sshd_config.tmp
content: |
#ListenAddress ::
ListenAddress 0.0.0.0
Port 8822
Protocol 2
HostKey /etc/ssh/ssh_host_ecdsa_key
PermitRootLogin no
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no
PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
#Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
HostbasedAuthentication no
LoginGraceTime 120
MaxStartups 2
AllowTcpForwarding no
X11Forwarding no
LogLevel VERBOSE
ClientAliveInterval 300
ClientAliveCountMax 0
PrintMotd no
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
# override default of no subsystems
Subsystem sftp /usr/lib/openssh/sftp-server
AllowUsers myuser
owner: root:root
permissions: 0400
encoding: text/plain
append: false
- path: /etc/hosts.allow.tmp
content: |
sshd: 192.168.1.
owner: root:root
permissions: 0600
encoding: text/plain
append: true
runcmd:
- cp -f /etc/hosts.allow /etc/hosts.allow.old
- cp -f /etc/ssh/sshd_config /etc/ssh/sshd_config.old
- mv -f /etc/hosts.allow.tmp /etc/hosts.allow
- mv -f /etc/ssh/sshd_config.tmp /etc/ssh/sshd_config
- systemctl restart ssh
- curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
- python get-pip.py --user
- pip install --user ansible
If someone can help me to add volumes informations on this two files