2019-02-26 03:49:51 +00:00
---
- block :
2023-08-31 01:26:56 +00:00
- name : Gather package facts
ansible.builtin.package_facts :
2020-04-18 01:36:50 +00:00
manager : auto
2023-08-31 01:26:56 +00:00
- name : Check if atomic
ansible.builtin.stat :
2019-02-26 03:49:51 +00:00
path : /run/ostree-booted
register : ostree
2023-08-31 01:26:56 +00:00
- name : Check for cloud.cfg
ansible.builtin.stat :
2019-02-26 03:49:51 +00:00
path : /etc/cloud/cloud.cfg
register : cloudcfg
2023-08-31 01:26:56 +00:00
- name : Set fact (atomic state)
ansible.builtin.set_fact :
2019-02-26 03:49:51 +00:00
is_atomic : "{{ ostree.stat.exists }}"
2023-08-31 01:26:56 +00:00
- name : Set fact (cloud.cfg state)
ansible.builtin.set_fact :
2019-02-26 03:49:51 +00:00
is_cloudy : "{{ cloudcfg.stat.exists }}"
2023-08-31 01:26:56 +00:00
- name : Include dnf tasks
2021-04-05 05:18:41 +00:00
include_tasks : dnf.yml
when : (ansible_distribution in ["Fedora"] and not is_atomic) or (ansible_distribution in ["RedHat", "Red Hat Enterprise Linux", "CentOS"] and ansible_distribution_major_version is version('8', '>='))
2023-08-31 01:26:56 +00:00
- name : Remove unwanted packages
become : true
ansible.builtin.package :
name : "{{ item }}"
state : absent
when : "(item in ansible_facts.packages)"
with_items : "{{ UNWANTED_PKGS }}" # see roles/bootstrap/defaults/main.yml
- name : Install prereqs
become : true
ansible.builtin.package :
2020-04-18 01:36:50 +00:00
name : "{{ DEFAULT_PKGS | difference(ansible_facts.packages) }}"
2019-02-26 03:49:51 +00:00
state : installed
2020-04-18 01:36:50 +00:00
when : (ansible_distribution in ["CentOS", "Red Hat Enterprise Linux", "RedHat", "Fedora"] and not is_atomic)
2019-02-26 03:49:51 +00:00
2023-08-31 01:26:56 +00:00
- name : Disable fastestmirror (fedora - non-atomic)
become : true
ansible.builtin.lineinfile :
2019-02-26 03:49:51 +00:00
path : /etc/dnf/dnf.conf
regexp : "^fastestmirror="
2020-06-04 02:11:08 +00:00
line : "fastestmirror=False"
when : ansible_distribution in ["Fedora"] and not is_atomic
2023-08-31 01:26:56 +00:00
- name : Remove update_etc_hosts from cloud.cfg
become : true
ansible.builtin.lineinfile :
2019-02-26 03:49:51 +00:00
line : ' - update_etc_hosts'
path : /etc/cloud/cloud.cfg
state : absent
2019-06-14 01:15:47 +00:00
when : is_cloudy|bool
2023-08-31 01:26:56 +00:00
- name : Add all hosts to /etc/hosts
become : true
ansible.builtin.lineinfile :
2019-02-26 03:49:51 +00:00
path : /etc/hosts
state : present
2021-04-05 05:18:41 +00:00
line : "{{ hostvars[item].ip | default('127.0.0.1') }} {{ hostvars[item].ansible_hostname }}"
regexp : "^{{ hostvars[item].ip | default('127.0.0.1') }}.*{{ hostvars[item].ansible_hostname }}$"
2019-02-26 03:49:51 +00:00
with_items : "{{ groups.all }}"
2023-08-31 01:26:56 +00:00
- name : Set hostname to match inventory
ansible.builtin.hostname :
2019-07-31 02:52:28 +00:00
name : "{{ inventory_hostname }}"
register : hostname_change
2023-08-31 01:26:56 +00:00
- name : Remove requiretty
become : true
ansible.builtin.lineinfile :
2019-02-26 03:49:51 +00:00
regexp : '^\w+\s+requiretty'
path : /etc/sudoers
state : absent
2023-08-31 01:26:56 +00:00
- name : Import EPEL GPG key
become : true
ansible.builtin.rpm_key :
2021-04-05 05:18:41 +00:00
state : present
key : https://getfedora.org/static/fedora.gpg
when : ansible_distribution in ['Red Hat Enterprise Linux', 'RedHat'] and not is_atomic
2023-08-31 01:26:56 +00:00
- name : Install EPEL (dist pkg)
become : true
ansible.builtin.package :
2019-02-26 03:49:51 +00:00
name : epel-release
2023-08-31 01:26:56 +00:00
state : present
2021-04-05 05:18:41 +00:00
when : ansible_distribution in ['CentOS'] and not is_atomic
2019-02-26 03:49:51 +00:00
2023-08-31 01:26:56 +00:00
- name : Install EPEL (upstream pkg)
become : true
ansible.builtin.package :
name : "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm"
2021-04-05 05:18:41 +00:00
state : present
when : ansible_distribution in ['Red Hat Enterprise Linux', 'RedHat'] and not is_atomic
2023-08-31 01:26:56 +00:00
- name : Disable NetworkManager phoning home on Fedora
become : true
ansible.builtin.file :
2021-04-05 05:18:41 +00:00
path : /etc/NetworkManager/conf.d/20-connectivity-fedora.conf
access_time : preserve # make this properly idempotent, register no change when file exists
modification_time : preserve # ^
state : touch
2023-08-31 01:26:56 +00:00
mode : '0644'
2021-04-05 05:18:41 +00:00
when : (ansible_distribution in ['Fedora'] and not is_atomic) and ('NetworkManager' in ansible_facts.packages)
2020-04-18 01:36:50 +00:00
2023-08-31 01:26:56 +00:00
- name : Ensure systemd-oomd service and socket are disabled and stopped
become : true
ansible.builtin.systemd :
name : "{{ item }}"
state : stopped
enabled : false
with_items :
- systemd-oomd.service
- systemd-oomd.socket
when : (ansible_distribution in ['Fedora'] and not is_atomic)
- name : Ensure systemd-oomd service and socket are masked
become : true
ansible.builtin.systemd :
name : "{{ item }}"
masked : true
with_items :
- systemd-oomd.service
- systemd-oomd.socket
when : (ansible_distribution in ['Fedora'] and not is_atomic)
- name : Ensure systemd-oomd-defaults package is removed
become : true
ansible.builtin.package :
name : systemd-oomd-defaults
state : absent
2019-02-26 03:49:51 +00:00
tags :
- bootstrap