2019-02-26 03:49:51 +00:00
---
- block :
2020-04-18 01:36:50 +00:00
- name : gather package facts
package_facts :
manager : auto
2019-02-26 03:49:51 +00:00
- name : check if atomic
stat :
path : /run/ostree-booted
register : ostree
- name : check for cloud.cfg
stat :
path : /etc/cloud/cloud.cfg
register : cloudcfg
- name : set fact (atomic state)
set_fact :
is_atomic : "{{ ostree.stat.exists }}"
- name : set fact (cloud.cfg state)
set_fact :
is_cloudy : "{{ cloudcfg.stat.exists }}"
2021-04-05 05:18:41 +00:00
- name : include dnf tasks
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', '>='))
2019-02-26 03:49:51 +00:00
- name : install prereqs
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
2020-06-04 02:11:08 +00:00
- name : disable fastestmirror (fedora - non-atomic)
2019-02-26 03:49:51 +00:00
lineinfile :
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
2019-02-26 03:49:51 +00:00
- name : remove update_etc_hosts from cloud.cfg
lineinfile :
line : ' - update_etc_hosts'
path : /etc/cloud/cloud.cfg
state : absent
2019-06-14 01:15:47 +00:00
when : is_cloudy|bool
2019-02-26 03:49:51 +00:00
2021-04-05 05:18:41 +00:00
- name : add all hosts to /etc/hosts
2019-02-26 03:49:51 +00:00
lineinfile :
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 }}"
2019-07-31 02:52:28 +00:00
- name : set hostname to match inventory
hostname :
name : "{{ inventory_hostname }}"
register : hostname_change
2019-02-26 03:49:51 +00:00
- name : remove requiretty
lineinfile :
regexp : '^\w+\s+requiretty'
path : /etc/sudoers
state : absent
2021-04-05 05:18:41 +00:00
- name : import epel GPG key
rpm_key :
state : present
key : https://getfedora.org/static/fedora.gpg
when : ansible_distribution in ['Red Hat Enterprise Linux', 'RedHat'] and not is_atomic
- name : install epel (dist pkg)
2019-02-26 03:49:51 +00:00
package :
name : epel-release
state : latest
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
2021-04-05 05:18:41 +00:00
- name : install epel (upstream pkg)
2020-04-18 01:36:50 +00:00
package :
2021-04-05 05:18:41 +00:00
name : "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ansible_distribution_major_version}}.noarch.rpm"
state : present
when : ansible_distribution in ['Red Hat Enterprise Linux', 'RedHat'] and not is_atomic
- name : remove unwanted packages
package :
name : "{{ item }}"
2020-04-18 01:36:50 +00:00
state : absent
2021-04-05 05:18:41 +00:00
when : "(item in ansible_facts.packages)"
with_items : "{{ UNWANTED_PKGS }}" # see roles/bootstrap/defaults/main.yml
- name : disable NetworkManager phoning home on Fedora
file :
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
mode : 0644
when : (ansible_distribution in ['Fedora'] and not is_atomic) and ('NetworkManager' in ansible_facts.packages)
2020-04-18 01:36:50 +00:00
2019-02-26 03:49:51 +00:00
tags :
- bootstrap