Several Problems with Autoinstaller and cloud-init
For some of the points I found the correct syntax meanwhile.
- hostname: still not working. For that I would need some suggestions
- ssh public keys: at least for the one user for installation, I have working ssh pubkeys now. I am not sure why the exact syntax from earlier tries now works, perhaps it's the first time of combination with the right mix (ssh -> authorized-keys without an users part). See config further down
- root: We gave up on having a working root user and decided that having an user with admin rights will be enough and take it with Ansible from here.
- other users: Did not try that part again, due to having one user is enough.
- network interfaces: Just not putting anything for that in the config did the part with "Take the first one working".
- own mirror: still to be done, not sure what we are missing here. To be clear, how to configure this in cloud-init is known, but how to use an own mirror for that, not.
For the LVM config of your HDD, I recommend that you install one server from scratch manually with configuring your disk to your wishes and then take the install log to get the disk part right. Had some days of trial and error until I did that, just to find out, that you can't name the partitions like you want and better use the numbers, the system would give them, instead of anything else. When doing this, switch all preserve parts to false and the size of the last partition to -1 to use entire disk space.
Current, working user-data:
#cloud-config
autoinstall:
package_upgrade: true
packages:
- zsh
- tmux
- nmap
- curl
- wget
- git
- htop
- iperf
- fail2ban
- vim
- net-tools
apt:
geoip: true
preserve_sources_list: false
primary:
- arches: [amd64, i386]
uri: http://de.archive.ubuntu.com/ubuntu
- arches: [default]
uri: http://ports.ubuntu.com/ubuntu-ports
identity: {hostname: localhost, password: <password>,
username: ansible, realname: ansible}
keyboard: {layout: de, toggle: null, variant: ''}
locale: en_GB
ssh:
allow-pw: true
install-server: true
authorized-keys:
- ssh-rsa ...
- ssh-rsa ...
user-data:
disable_root: true
storage:
config:
- {ptable: gpt, path: /dev/sda, wipe: superblock-recursive, preserve: false, name: '', grub_device: true, type: disk, id: disk-sda}
- {device: disk-sda, size: 1048576, flag: bios_grub, number: 1, preserve: false,
grub_device: false, type: partition, id: partition-sda1}
- {device: disk-sda, size: 2147483648, wipe: superblock, flag: linux, number: 2,
preserve: false, grub_device: false, type: partition, id: partition-sda2}
- {fstype: ext4, volume: partition-sda2, preserve: false, type: format, id: format-0}
- {device: disk-sda, size: -1, wipe: superblock, flag: linux, number: 3,
preserve: false, grub_device: false, type: partition, id: partition-sda3}
- name: vg0
devices: [partition-sda3]
preserve: false
type: lvm_volgroup
id: lvm_volgroup-0
- {name: root, volgroup: lvm_volgroup-0, size: 5368709120B, preserve: false, type: lvm_partition,
id: lvm_partition-0}
- {fstype: ext4, volume: lvm_partition-0, preserve: false, type: format, id: format-1}
- {device: format-1, path: /, type: mount, id: mount-1}
- {name: swap, volgroup: lvm_volgroup-0, size: 4294967296B, preserve: false, type: lvm_partition,
id: lvm_partition-1}
- {fstype: swap, volume: lvm_partition-1, preserve: false, type: format, id: format-2}
- {device: format-2, path: '', type: mount, id: mount-2}
- {name: tmp, volgroup: lvm_volgroup-0, size: 4294967296B, preserve: false, type: lvm_partition,
id: lvm_partition-2}
- {fstype: ext4, volume: lvm_partition-2, preserve: false, type: format, id: format-3}
- {device: format-3, path: /tmp, type: mount, id: mount-3}
- {name: usr, volgroup: lvm_volgroup-0, size: 16106127360B, preserve: false, type: lvm_partition,
id: lvm_partition-3}
- {fstype: ext4, volume: lvm_partition-3, preserve: false, type: format, id: format-4}
- {device: format-4, path: /usr, type: mount, id: mount-4}
- {name: var, volgroup: lvm_volgroup-0, size: 10737418240B, preserve: false, type: lvm_partition,
id: lvm_partition-4}
- {fstype: ext4, volume: lvm_partition-4, preserve: false, type: format, id: format-5}
- {device: format-5, path: /var, type: mount, id: mount-5}
- {name: varlog, volgroup: lvm_volgroup-0, size: 4294967296B, preserve: false,
type: lvm_partition, id: lvm_partition-5}
- {fstype: ext4, volume: lvm_partition-5, preserve: false, type: format, id: format-6}
- {device: format-6, path: /var/log, type: mount, id: mount-6}
- {device: format-0, path: /boot, type: mount, id: mount-0}
swap: {swap: 0}
version: 1
late-commands:
- echo 'ansible ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ansible