infra-ansible

ansible script to ship alpine/ssh/wireguard

git clone https://9o.is/git/infra-ansible.git

debian_autoboot.yml

(1399B)


      1 ---
      2 - name: Set mtu to {{ static_mtu }}
      3   raw: apt install -y iproute2 && ip link set {{ debian_net_interface }} mtu {{ static_mtu }}
      4 
      5 - name: Reset ssh connection to apply mtu change
      6   delegate_to: localhost
      7   command: rm -rf ~/.ansible/cp
      8 
      9 - name: upload alpine iso
     10   copy:
     11     src: '{{ alpine_iso }}'
     12     dest: /alpine.iso
     13     owner: root
     14     group: root
     15     mode: '0644'
     16   register: iso_upload
     17 
     18 - name: create grub menuentry
     19   blockinfile:
     20     dest: /etc/grub.d/40_custom
     21     block: |
     22       menuentry "Alpine Linux" --id alpine-linux {
     23           loopback loop /alpine.iso
     24           linux (loop)/boot/vmlinuz-virt
     25           initrd (loop)/boot/initramfs-virt
     26       }
     27   notify: update grub
     28 
     29 - name: set grub default
     30   lineinfile:
     31     path: /etc/default/grub
     32     regexp: '^GRUB_DEFAULT='
     33     line: GRUB_DEFAULT=alpine-linux
     34   notify: update grub
     35 
     36 - name: show next steps (with grub)
     37   debug:
     38     msg:
     39       - 'ISO is ready for manual installation.'
     40       - '1) Reboot machine'
     41       - '2) In rescue mode, load the iso in memory and continue boot.'
     42       - 'mount /dev/vda1 /media/vda1'
     43       - 'cp /media/vda1/alpine.iso /dev/shm'
     44       - 'umount /dev/vda1'
     45       - 'mount -o loop -t iso9660 /dev/shm/alpine.iso /media/cdrom'
     46       - 'exit'
     47       - '3) Load apkovl if it is missing:'
     48       - 'tar xCf / {{ inventory_hostname }}.apkovl.tar.gz'
     49       - '4) Run setup-disk'
     50   when: iso_upload.changed
     51