#cloud-config autoinstall: version: 1 locale: en_US keyboard: layout: us packages: - at identity: hostname: AutomationNVMeTesting # From kickstart configuration we'll take the 1st server user username: ss7841 password: '$6$xPm1ZAhB$4Pq.aZ0bhkNSpuSXQpXypnKwc5T3g6I6lU2.ONsi11cg/SQIOEi83gRRgtHF.3emBElUbfuSHjKzayPH2tRDS.' kernel: {package: linux-generic} ssh: { allow-pw: true, authorized-keys: [], install-server: true } early-commands: - | #!/bin/bash # Determine the first disk ROOTDRIVE=$(lsblk -ido KNAME,TYPE,SIZE,MODEL | grep -E '^(nvme|sd)' | grep disk | awk -F' ' 'NR==1{print $1}') echo "Disk:$ROOTDRIVE" # Replace the placeholder with the actual disk name in the storage configuration sed -i "s|DISK_NAME_VARIABLE|$ROOTDRIVE|g" /autoinstall.yaml - sleep 5 storage: config: # Install GRUB in MBR - { ptable: gpt, path: /dev/DISK_NAME_VARIABLE, wipe: superblock-recursive, preserve: false, name: '', grub_device: true, type: disk, id: disk-DISK_NAME_VARIABLE } # BIOS boot partition - { device: disk-DISK_NAME_VARIABLE, size: 1048576, wipe: superblock, flag: bios_grub, number: 1, preserve: false, type: partition, id: partition-0 } - { device: disk-DISK_NAME_VARIABLE, size: 2147483648, wipe: superblock, number: 2, preserve: false, grub_device: false, type: partition, id: partition-1 } - { fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-0 } - { device: disk-DISK_NAME_VARIABLE, size: -1, wipe: superblock, flag: '', number: 3, preserve: false, grub_device: false, type: partition, id: partition-2 } - { name: ubuntu-vg, devices: [ partition-2 ], preserve: false, type: lvm_volgroup, id: lvm_volgroup-0 } - { name: ubuntu-lv, volgroup: lvm_volgroup-0, size: -1, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_partition-0 } - { fstype: ext4, volume: lvm_partition-0, preserve: false, type: format, id: format-1 } - { path: /, device: format-1, type: mount, id: mount-1 } - { path: /boot, device: format-0, type: mount, id: mount-0 } user-data: disable_root: false late-commands: - | # Set root password #sed -i 's|^root:.*|root:$6$xPm1ZAhB$4Pq.aZ0bhkNSpuSXQpXypnKwc5T3g6I6lU2.ONsi11cg/SQIOEi83gRRgtHF.3emBElUbfuSHjKzayPH2tRDS.:19763:0:99999:7:::|' /target/etc/shadow #sed -i 's|\(^root:\)[^:]*|\1$6$xPm1ZAhB$4Pq.aZ0bhkNSpuSXQpXypnKwc5T3g6I6lU2.ONsi11cg/SQIOEi83gRRgtHF.3emBElUbfuSHjKzayPH2tRDS.|' /target/etc/shadow current_days=$(($(date +%s) / 86400)) sed -i "s|^root:.*|root:$6$xPm1ZAhB$4Pq.aZ0bhkNSpuSXQpXypnKwc5T3g6I6lU2.ONsi11cg/SQIOEi83gRRgtHF.3emBElUbfuSHjKzayPH2tRDS.:$current_days:0:2:7:::|" /target/etc/shadow # Remove the existing netplan configuration file rm /target/etc/netplan/00-installer-config.yaml # Detect Ethernet interfaces and store them in variables BACKEND_INTERFACE=$(ip ntable | grep dev | sort | uniq | sed -e 's/^.*dev //;/^lo/d' | head -n 1 | tail -n 1 | xargs) FRONTEND_INTERFACE=$(ip ntable | grep dev | sort | uniq | sed -e 's/^.*dev //;/^lo/d' | head -n 2 | tail -n 1 | xargs) # Generate the new netplan configuration file using the detected interfaces cat << EOF > /target/etc/netplan/00-installer-config.yaml network: version: 2 renderer: networkd ethernets: $BACKEND_INTERFACE: dhcp4: false dhcp6: false $FRONTEND_INTERFACE: dhcp4: false dhcp6: false addresses: [184.164.157.34/29,184.164.157.35/29,184.164.157.36/29,184.164.157.37/29,184.164.157.38/29] nameservers: addresses: [8.8.8.8,8.8.4.4] routes: - to: default via: 184.164.157.33 EOF - | cat << EOF > /target/etc/systemd/system/password-expired.service [Unit] Description=Change password expiration date # Instructs systemd on when the script should be run After=multi-user.target [Service] # This field provides a full path to the actual script to be executed on startup ExecStart=/password-expired.sh # This parameter ensures the service only runs once and then its status is considered as inactive Type=oneshot # This parameter ensures the service is not considered �active� anymore after the ExecStart process exits #RemainAfterExit=yes [Install] WantedBy=multi-user.target EOF - | cat << EOF > /target/password-expired.sh #!/bin/bash chage -M 2 ss7841 echo "sleep 5 ; bash /clean-password-expired-service.sh" | at now rm -- "\$0" EOF - | cat << EOF > /target/clean-password-expired-service.sh #!/bin/bash echo 5ty6%TY^ | sudo -S systemctl stop password-expired.service echo 5ty6%TY^ | sudo -S disable password-expired.service echo 5ty6%TY^ | sudo -S rm -f /etc/systemd/system/password-expired.service echo 5ty6%TY^ | sudo -S rm -f /etc/systemd/system/multi-user.target.wants/password-expired.service echo 5ty6%TY^ | sudo -S rm -f systemctl daemon-reload echo 5ty6%TY^ | sudo -S rm -f systemctl reset-failed rm -- "\$0" EOF - chmod +x /target/password-expired.sh - chmod +x /target/clean-password-expired-service.sh - chmod 664 /target/etc/systemd/system/password-expired.service # Reload systemd daemon: - curtin in-target --target=/ systemctl daemon-reload # Enable pasword expired service - sudo systemctl enable password-expired.service - ln -s /target/etc/systemd/system/password-expired.service /target/etc/systemd/system/multi-user.target.wants/password-expired.service #- wget -b -O /dev/null 'http://192.168.200.2/automation/completeKickstartInstallation.php?kickstartInstallationId=76135&securityKey=djbavfnlwtseuozrnslhckwtchdsmjxj' updates: security