PLAY [Install Ubuntu 22.04 LTS on CentOS VPS] ********************************** TASK [Gathering Facts] ********************************************************* ok: [147.93.47.163] TASK [Create backup directory] ************************************************* ok: [147.93.47.163] TASK [Archive important directories] ******************************************* changed: [147.93.47.163] TASK [Install required packages] *********************************************** changed: [147.93.47.163] TASK [Create partition layout] ************************************************* fatal: [147.93.47.163]: FAILED! => {"changed": false, "msg": "state is present but all of the following are missing: number"} PLAY RECAP ********************************************************************* 147.93.47.163 : ok=4 changed=2 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0 [adminuser@srv692476 ~]$ ---yaml code--- - name: Install Ubuntu 22.04 LTS on CentOS VPS hosts: target_vps become: yes vars: ubuntu_codename: "jammy" ubuntu_mirror: "http://archive.ubuntu.com/ubuntu/" target_disk: "/dev/vda" hostname: "ubuntu-vps" timezone: "UTC" tasks: - name: Backup important data block: - name: Create backup directory file: path: /root/backup state: directory - name: Archive important directories archive: path: - /etc - /root - /home dest: /root/backup/system_backup.tar.gz format: gz - name: Install required packages package: name: - debootstrap - arch-install-scripts state: present - name: Create partition layout parted: device: "{{ target_disk }}" label: gpt state: present - name: Create root partition parted: device: "{{ target_disk }}" number: 1 state: present part_start: "0%" part_end: "100%" - name: Format root partition filesystem: fstype: ext4 dev: "{{ target_disk }}1" - name: Mount root filesystem mount: path: /mnt src: "{{ target_disk }}1" fstype: ext4 state: mounted - name: Bootstrap Ubuntu base system command: > debootstrap --arch amd64 {{ ubuntu_codename }} /mnt {{ ubuntu_mirror }} args: creates: /mnt/bin - name: Configure base system command: chroot /mnt /bin/bash -c "{{ item }}" with_items: - echo "{{ hostname }}" > /etc/hostname - ln -sf /usr/share/zoneinfo/{{ timezone }} /etc/localtime - echo "deb {{ ubuntu_mirror }} {{ ubuntu_codename }} main restricted universe multiverse" > /etc/apt/sources.list - echo "deb {{ ubuntu_mirror }} {{ ubuntu_codename }}-updates main restricted universe multiverse" >> /etc/apt/sources.list - echo "deb {{ ubuntu_mirror }} {{ ubuntu_codename }}-security main restricted universe multiverse" >> /etc/apt/sources.list - apt-get update - apt-get install -y linux-image-generic - apt-get install -y systemd systemd-sysv - apt-get install -y grub2 - apt-get install -y cloud-init openssh-server - systemctl enable ssh - name: Generate and configure fstab command: genfstab -U /mnt >> /mnt/etc/fstab - name: Install and configure GRUB command: chroot /mnt /bin/bash -c "{{ item }}" with_items: - grub-install {{ target_disk }} - update-grub - name: Set root password command: chroot /mnt /bin/bash -c "echo 'root:Ch3erios' | chpasswd" - name: Create admin user command: chroot /mnt /bin/bash -c "{{ item }}" with_items: - useradd -m -s /bin/bash adminuser - echo 'adminuser:Ch3erios' | chpasswd - usermod -aG sudo adminuser - name: Unmount filesystem mount: path: /mnt state: unmounted - name: Reboot system reboot: reboot_timeout: 600 handlers: - name: Reboot handler reboot: reboot_timeout: 600