Ansible-Bootstrap/roles/bootstrap/tasks/main.yml

80 lines
3.7 KiB
YAML
Raw Normal View History

2024-03-19 23:02:50 +01:00
---
- name: Include Packages
2024-07-11 22:20:45 +02:00
ansible.builtin.include_vars:
2024-03-19 23:02:50 +01:00
file: packages.yml
name: role_packages
- name: Run OS-specific bootstrap process
block:
- name: Bootstrap ArchLinux
when: os | lower == 'archlinux'
2024-07-11 22:20:45 +02:00
ansible.builtin.command: pacstrap /mnt {{ role_packages.archlinux | join(' ') }} --asexplicit
changed_when: result.rc == 0
register: result
2024-03-19 23:02:50 +01:00
- name: Bootstrap Debian System
when: os | lower in ['debian11', 'debian12']
2024-07-11 22:20:45 +02:00
ansible.builtin.command: "{{ item }}"
changed_when: result.rc == 0
register: result
2024-03-19 23:02:50 +01:00
with_items:
2024-10-28 21:07:33 +01:00
- debootstrap --include={{ role_packages[os].base | join(',') }} {{ 'bullseye' if os == 'debian11' else 'bookworm' }}
2024-10-28 18:26:54 +01:00
/mnt http://deb.debian.org/debian/
2024-03-19 23:02:50 +01:00
- arch-chroot /mnt apt install -y {{ role_packages[os].extra | join(' ') }}
- arch-chroot /mnt apt remove -y libcups2 libavahi-common3 libavahi-common-data
2024-04-17 10:53:09 +02:00
- name: Bootstrap Ubuntu System
when: os | lower in ['ubuntu', 'ubuntu-lts']
2024-07-11 22:20:45 +02:00
ansible.builtin.command: "{{ item }}"
changed_when: result.rc == 0
register: result
2024-04-17 10:53:09 +02:00
with_items:
2024-10-28 21:07:33 +01:00
- debootstrap --include={{ role_packages[os].base | join(',') }} {{ 'mantic' if os == 'ubuntu' else 'jammy' }}
2024-10-28 18:26:54 +01:00
/mnt http://archive.ubuntu.com/ubuntu/
- ln -sf /run/systemd/resolve/resolv.conf /mnt/etc/resolv.conf
2024-04-17 10:53:09 +02:00
- arch-chroot /mnt sed -i '1s|$| universe|' /etc/apt/sources.list
- arch-chroot /mnt apt update -y
- arch-chroot /mnt apt install -y {{ role_packages[os].extra | join(' ') }}
2024-03-19 23:02:50 +01:00
- name: Bootstrap AlmaLinux 9
when: os | lower == 'almalinux'
2024-07-11 22:20:45 +02:00
ansible.builtin.command: "{{ item }}"
changed_when: result.rc == 0
register: result
2024-03-19 23:02:50 +01:00
with_items:
- dnf --releasever=9 --best --repo=alma-baseos --installroot=/mnt --setopt=install_weak_deps=False groupinstall -y base core
- ln -sf /run/systemd/resolve/resolv.conf /mnt/etc/resolv.conf
2024-03-19 23:02:50 +01:00
- arch-chroot /mnt dnf --releasever=9 --setopt=install_weak_deps=False install -y {{ role_packages.almalinux | join(' ') }}
2024-10-29 14:17:01 +01:00
- name: Bootstrap Fedora 41
2024-03-19 23:02:50 +01:00
when: os | lower == 'fedora'
2024-07-11 22:20:45 +02:00
ansible.builtin.command: "{{ item }}"
changed_when: result.rc == 0
register: result
2024-03-19 23:02:50 +01:00
with_items:
2024-10-29 14:17:01 +01:00
- dnf --releasever=41 --best --repo=fedora --repo=fedora-updates
2024-10-28 18:26:54 +01:00
--installroot=/mnt --setopt=install_weak_deps=False groupinstall -y critical-path-base core
- ln -sf /run/systemd/resolve/resolv.conf /mnt/etc/resolv.conf
2024-10-29 14:17:01 +01:00
- arch-chroot /mnt dnf --releasever=41 --setopt=install_weak_deps=False install -y {{ role_packages.fedora | join(' ') }}
2024-04-17 06:02:32 +02:00
- arch-chroot /mnt dnf reinstall -y kernel-core
2024-03-19 23:02:50 +01:00
2024-04-16 01:14:05 +02:00
- name: Bootstrap RockyLinux 9
when: os | lower == 'rocky'
2024-07-11 22:20:45 +02:00
ansible.builtin.command: "{{ item }}"
changed_when: result.rc == 0
register: result
2024-04-16 01:14:05 +02:00
with_items:
- dnf --releasever=9 --best --repo=rocky-baseos --installroot=/mnt --setopt=install_weak_deps=False groupinstall -y base core
- ln -sf /run/systemd/resolve/resolv.conf /mnt/etc/resolv.conf
2024-04-16 01:14:05 +02:00
- arch-chroot /mnt dnf --releasever=9 --setopt=install_weak_deps=False install -y {{ role_packages.rocky | join(' ') }}
2024-03-19 23:02:50 +01:00
- name: Bootstrap RHEL System
when: os | lower in ['rhel8', 'rhel9']
2024-07-11 22:20:45 +02:00
ansible.builtin.command: "{{ item }}"
changed_when: result.rc == 0
register: result
2024-03-19 23:02:50 +01:00
with_items:
2024-07-11 22:20:45 +02:00
- dnf --releasever={{ '8' if os == 'rhel8' else '9' }} --installroot=/mnt --setopt=install_weak_deps=False groupinstall -y base core
- ln -sf /run/systemd/resolve/resolv.conf /mnt/etc/resolv.conf
2024-07-11 22:20:45 +02:00
- arch-chroot /mnt dnf --releasever={{ '8' if os == 'rhel8' else '9' }} --setopt=install_weak_deps=False install -y {{ role_packages[os] | join(' ') }}