fix issue in provisisonning

This commit is contained in:
vincent 2021-03-21 12:45:52 +01:00
parent bdb76c3935
commit 46d69427f0
2 changed files with 23 additions and 10 deletions

View File

@ -2,23 +2,21 @@
# defaults file for ansible-arch-provissionning # defaults file for ansible-arch-provissionning
partition_table: partition_table:
- device: "/dev/sda" - device: "/dev/sda"
label: msdos
settings: settings:
- number: 1 - number: 1
part_end: 512MB part_end: 512MB
name: boot
flags: [boot, esp] flags: [boot, esp]
fstype: vfat fstype: vfat
format: yes format: yes
- number: 2 - number: 2
part_start: 512MB part_start: 512MB
part_end: 1524MB part_end: 1524MB
name: swap flags: []
flags: [swap]
fstype: swap fstype: swap
format: yes format: yes
- number: 3 - number: 3
part_start: 1524MB part_start: 1524MB
name: root
flags: [lvm] flags: [lvm]
fstype: ext4 fstype: ext4
format: yes format: yes
@ -72,3 +70,5 @@ provissionning_enable_service:
- sshd - sshd
- dhcpcd - dhcpcd
system_arch_local_mirror: system_arch_local_mirror:
#need vfat boot partition with esp label
provissionning_UEFI_Enable: False

View File

@ -3,8 +3,7 @@
# #
- name: debug - name: debug
debug: debug:
var: item msg: "{% if provissionning_UEFI_Enable == True %} GPT {% else %} msdos {% endif %}"
loop: '{{ partition_table|subelements("settings") }}'
- name: Abort if the host is not booted from the Arch install media - name: Abort if the host is not booted from the Arch install media
fail: fail:
msg: "This host {{ ansible_nodename }} is not booted from the Arch install media!" msg: "This host {{ ansible_nodename }} is not booted from the Arch install media!"
@ -21,11 +20,11 @@
- name: create partition - name: create partition
parted: parted:
device: "{{ item.0.device }}" device: "{{ item.0.device }}"
label: gpt label: "{% if provissionning_UEFI_Enable == True %}GPT{% else %}msdos{% endif %}"
number: "{{ item.1.number }}" number: "{{ item.1.number }}"
part_start: "{{ item.1.part_start | default('0%') }}" part_start: "{{ item.1.part_start | default('0%') }}"
part_end: "{{ item.1.part_end | default('100%') }}" part_end: "{{ item.1.part_end | default('100%') }}"
name: "{{ item.1.name }}" #name: "{{ item.1.name }} |default('none')"
flags: "{{ item.1.flags }}" flags: "{{ item.1.flags }}"
state: present state: present
loop: '{{ partition_table|subelements("settings") }}' loop: '{{ partition_table|subelements("settings") }}'
@ -62,6 +61,7 @@
when: system_arch_local_mirror is defined when: system_arch_local_mirror is defined
- name: update archlinux-keyring - name: update archlinux-keyring
pacman: pacman:
update_cache: yes
name: archlinux-keyring name: archlinux-keyring
state: latest state: latest
@ -97,10 +97,19 @@
command: arch-chroot /mnt mkinitcpio -p linux command: arch-chroot /mnt mkinitcpio -p linux
- name: Set up grub - name: Set up grub
block: block:
- name: Install grub - name: Install uefi grub
command: arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=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 - name: Create grub config
command: arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg command: arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
- name: Remove root SSH access - name: Remove root SSH access
become: yes become: yes
lineinfile: lineinfile:
@ -108,7 +117,11 @@
regexp: "^PermitRootLogin" regexp: "^PermitRootLogin"
line: "PermitRootLogin yes" line: "PermitRootLogin yes"
state: present state: present
- name: change root password
user:
name: root
password: "{{ vault_default_root |password_hash('sha512') }}"
when: vault_default_root is defined
- name: Reboot - name: Reboot
reboot: reboot:
connect_timeout: 1 connect_timeout: 1