diff --git a/defaults/main.yml b/defaults/main.yml index c89b4dd..cfef037 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,23 +2,21 @@ # defaults file for ansible-arch-provissionning partition_table: - device: "/dev/sda" + label: msdos settings: - number: 1 part_end: 512MB - name: boot flags: [boot, esp] fstype: vfat format: yes - number: 2 part_start: 512MB part_end: 1524MB - name: swap - flags: [swap] + flags: [] fstype: swap format: yes - number: 3 part_start: 1524MB - name: root flags: [lvm] fstype: ext4 format: yes @@ -72,3 +70,5 @@ provissionning_enable_service: - sshd - dhcpcd system_arch_local_mirror: +#need vfat boot partition with esp label +provissionning_UEFI_Enable: False diff --git a/tasks/main.yml b/tasks/main.yml index a91d96f..8750c60 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,8 +3,7 @@ # - name: debug debug: - var: item - loop: '{{ partition_table|subelements("settings") }}' + msg: "{% if provissionning_UEFI_Enable == True %} GPT {% else %} msdos {% endif %}" - name: Abort if the host is not booted from the Arch install media fail: msg: "This host {{ ansible_nodename }} is not booted from the Arch install media!" @@ -21,11 +20,11 @@ - name: create partition parted: device: "{{ item.0.device }}" - label: gpt + label: "{% if provissionning_UEFI_Enable == True %}GPT{% else %}msdos{% endif %}" number: "{{ item.1.number }}" part_start: "{{ item.1.part_start | default('0%') }}" part_end: "{{ item.1.part_end | default('100%') }}" - name: "{{ item.1.name }}" + #name: "{{ item.1.name }} |default('none')" flags: "{{ item.1.flags }}" state: present loop: '{{ partition_table|subelements("settings") }}' @@ -62,6 +61,7 @@ when: system_arch_local_mirror is defined - name: update archlinux-keyring pacman: + update_cache: yes name: archlinux-keyring state: latest @@ -97,10 +97,19 @@ command: arch-chroot /mnt mkinitcpio -p linux - name: Set up grub block: - - name: Install grub + - name: Install uefi grub command: arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB + when: provissionning_UEFI_Enable == True + + - name: Install legacy grub + command: "arch-chroot /mnt grub-install {{ item.0.device }} " + when: provissionning_UEFI_Enable == False + loop: '{{ mount_table|subelements("settings") }}' + when: item.1.mountpath == "/mnt/boot" + - name: Create grub config command: arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg + - name: Remove root SSH access become: yes lineinfile: @@ -108,7 +117,11 @@ regexp: "^PermitRootLogin" line: "PermitRootLogin yes" state: present - +- name: change root password + user: + name: root + password: "{{ vault_default_root |password_hash('sha512') }}" + when: vault_default_root is defined - name: Reboot reboot: connect_timeout: 1