2024-07-11 22:20:45 +02:00
|
|
|
---
|
2024-03-19 23:02:50 +01:00
|
|
|
- name: Configre work environment
|
|
|
|
become: true
|
|
|
|
block:
|
|
|
|
- name: Wait for connection
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.builtin.wait_for_connection:
|
2024-03-19 23:02:50 +01:00
|
|
|
timeout: 300
|
|
|
|
delay: 5
|
|
|
|
|
|
|
|
- name: Gather facts
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.builtin.setup:
|
2024-03-19 23:02:50 +01:00
|
|
|
|
|
|
|
- name: Check if host is booted from the Arch install media
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.builtin.stat:
|
2024-03-19 23:02:50 +01:00
|
|
|
path: /run/archiso
|
|
|
|
register: archiso_stat
|
|
|
|
|
|
|
|
- name: Abort if the host is not booted from the Arch install media
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.builtin.fail:
|
|
|
|
msg: This host is not booted from the Arch install media!
|
2024-03-19 23:02:50 +01:00
|
|
|
when: not archiso_stat.stat.exists
|
|
|
|
|
|
|
|
- name: Setect Interface
|
|
|
|
when: hypervisor == "vmware"
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.builtin.shell: "ip l | awk -F': ' '!/lo/{print $2; exit}'"
|
2024-03-19 23:02:50 +01:00
|
|
|
register: interface_name
|
|
|
|
|
|
|
|
- name: Set IP-Address
|
|
|
|
when: hypervisor == "vmware"
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.builtin.command: ip addr replace {{ ansible_host }}/24 dev {{ interface_name.stdout }}
|
2024-03-19 23:02:50 +01:00
|
|
|
- name: Set Default Gateway
|
|
|
|
when: hypervisor == "vmware"
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.builtin.command: ip route replace default via {{ vm_gw }}
|
2024-03-19 23:02:50 +01:00
|
|
|
- name: Synchronize clock via NTP
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.builtin.command: timedatectl set-ntp true
|
2024-03-19 23:02:50 +01:00
|
|
|
- name: Speed-up Bootstrap process
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.builtin.lineinfile:
|
2024-03-19 23:02:50 +01:00
|
|
|
path: /etc/pacman.conf
|
2024-07-11 22:20:45 +02:00
|
|
|
regexp: ^#ParallelDownloads =
|
|
|
|
line: ParallelDownloads = 20
|
2024-03-19 23:02:50 +01:00
|
|
|
|
|
|
|
- name: Wait for Pacman
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.builtin.wait_for:
|
2024-03-19 23:02:50 +01:00
|
|
|
timeout: 15
|
|
|
|
|
|
|
|
- name: Setup Pacman
|
2024-07-11 22:20:45 +02:00
|
|
|
community.general.pacman:
|
2024-03-20 00:07:10 +01:00
|
|
|
update_cache: true
|
|
|
|
force: true
|
2024-03-22 06:19:03 +01:00
|
|
|
name: "{{ item.name }}"
|
2024-03-19 23:02:50 +01:00
|
|
|
state: latest
|
2024-03-22 06:19:03 +01:00
|
|
|
loop:
|
2024-07-11 22:20:45 +02:00
|
|
|
- { name: glibc }
|
|
|
|
- { name: dnf, os: [almalinux, fedora, rhel9, rhel8, rocky] }
|
|
|
|
- { name: debootstrap, os: [debian11, debian12, ubuntu, ubuntu-lts] }
|
|
|
|
- { name: debian-archive-keyring, os: [debian11, debian12] }
|
|
|
|
- { name: ubuntu-keyring, os: [ubuntu, ubuntu-lts] }
|
2024-03-22 06:19:03 +01:00
|
|
|
when: "'os' not in item or os in item.os"
|
2024-03-22 05:59:39 +01:00
|
|
|
retries: 4
|
2024-03-19 23:02:50 +01:00
|
|
|
delay: 15
|
|
|
|
|
|
|
|
- name: Configure RHEL Repos for installation
|
2024-04-16 01:14:05 +02:00
|
|
|
when: os | lower in ["almalinux", "fedora", "rocky"]
|
2024-03-19 23:02:50 +01:00
|
|
|
block:
|
2024-07-11 22:20:45 +02:00
|
|
|
- name: Create directories for repository files and RPM GPG keys
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: /etc/yum.repos.d
|
|
|
|
state: directory
|
2024-10-28 18:37:44 +01:00
|
|
|
mode: '0755'
|
2024-03-19 23:02:50 +01:00
|
|
|
|
2024-07-11 22:20:45 +02:00
|
|
|
- name: Create RHEL repository file
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "{{ os | lower }}.repo.j2"
|
|
|
|
dest: /etc/yum.repos.d/{{ os | lower }}.repo
|
2024-10-28 18:37:44 +01:00
|
|
|
mode: '0644'
|