Compare commits

..

No commits in common. "024b6f8c9fa85f15675fc8fedad15f7b185fb547" and "25610e364f48f0e0361a29c8ff6c3c78e8b7cde2" have entirely different histories.

3 changed files with 65 additions and 65 deletions

View file

@ -1,25 +1,12 @@
--- ---
bootstrap_default_pkgs: DEFAULT_PKGS:
common:
- sudo - sudo
- vim - vim
RedHat:
- python3-rpm
- python3-dnf
AlmaLinux: &CENT
- epel-release
- python3-rpm
- python3-dnf
Rocky: *CENT
Fedora:
- vim-default-editor - vim-default-editor
- kitty-terminfo UNWANTED_PKGS:
# removal assumes no need to sort by os_family, unlike the installation requests
bootstrap_unwanted_pkgs:
- earlyoom - earlyoom
- power-profiles-daemon - power-profiles-daemon
- nano-default-editor
- nano - nano
- nano-default-editor
- systemd-oomd-defaults - systemd-oomd-defaults
- zram-generator-defaults - zram-generator-defaults

View file

@ -1,42 +1,54 @@
--- ---
- name: Bootstrap/common tasks - block:
tags:
- bootstrap
block:
- name: Gather service facts - name: Gather package facts
ansible.builtin.service_facts: ansible.builtin.package_facts:
tags: ['always'] # ensure this runs if tasks are selected w/ tags (may provide required info) manager: auto
- name: Remove unwanted packages # before installation; may be required for conflicts - name: Check if atomic
ansible.builtin.stat:
path: /run/ostree-booted
register: ostree
- name: Check for cloud.cfg
ansible.builtin.stat:
path: /etc/cloud/cloud.cfg
register: cloudcfg
- name: Set fact (atomic state)
ansible.builtin.set_fact:
is_atomic: "{{ ostree.stat.exists }}"
- name: Set fact (cloud.cfg state)
ansible.builtin.set_fact:
is_cloudy: "{{ cloudcfg.stat.exists }}"
- 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', '>='))
- name: Remove unwanted packages
become: true become: true
ansible.builtin.package: ansible.builtin.package:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
with_items: "{{ bootstrap_unwanted_pkgs }}" when: "(item in ansible_facts.packages)"
with_items: "{{ UNWANTED_PKGS }}" # see roles/bootstrap/defaults/main.yml
- name: Install prereqs - name: Install prereqs
become: true become: true
ansible.builtin.package: ansible.builtin.package:
name: "{{ bootstrap_default_pkgs['common'] + bootstrap_default_pkgs[ansible_distribution] }}" name: "{{ DEFAULT_PKGS | difference(ansible_facts.packages) }}"
state: present state: installed
update_cache: true when: (ansible_distribution in ["CentOS", "Red Hat Enterprise Linux", "RedHat", "Fedora"] and not is_atomic)
when: (not ansible_local.os.is_atomic) # skip if an ostree/atomic host, unhandled
- name: Include dnf tasks - name: Disable fastestmirror (fedora - non-atomic)
ansible.builtin.include_tasks: dnf.yml
when:
- ansible_os_family in ["RedHat"]
- not ansible_local.os.is_atomic # see 'custom-facts' role
- ansible_distribution_major_version is version('8', '>=') # don't use on EL6/7, as rare as they are anymore
- name: Disable fastestmirror (Fedora - non-atomic)
become: true become: true
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: /etc/dnf/dnf.conf path: /etc/dnf/dnf.conf
regexp: "^fastestmirror=" regexp: "^fastestmirror="
line: "fastestmirror=False" line: "fastestmirror=False"
when: ansible_distribution in ["Fedora"] and not ansible_local.os.is_atomic when: ansible_distribution in ["Fedora"] and not is_atomic
- name: Remove update_etc_hosts from cloud.cfg - name: Remove update_etc_hosts from cloud.cfg
become: true become: true
@ -44,19 +56,18 @@
line: ' - update_etc_hosts' line: ' - update_etc_hosts'
path: /etc/cloud/cloud.cfg path: /etc/cloud/cloud.cfg
state: absent state: absent
when: ansible_local.os.is_cloudy when: is_cloudy|bool
# - name: Add all hosts to /etc/hosts - name: Add all hosts to /etc/hosts
# become: true become: true
# ansible.builtin.lineinfile: ansible.builtin.lineinfile:
# path: /etc/hosts path: /etc/hosts
# state: present state: present
# line: "{{ hostvars[item].ip | default('127.0.0.1') }} {{ hostvars[item].ansible_hostname }}" 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 }}$" regexp: "^{{ hostvars[item].ip | default('127.0.0.1') }}.*{{ hostvars[item].ansible_hostname }}$"
# with_items: "{{ groups.all }}" with_items: "{{ groups.all }}"
- name: Set hostname to match inventory - name: Set hostname to match inventory
become: true
ansible.builtin.hostname: ansible.builtin.hostname:
name: "{{ inventory_hostname }}" name: "{{ inventory_hostname }}"
register: hostname_change register: hostname_change
@ -73,36 +84,31 @@
ansible.builtin.rpm_key: ansible.builtin.rpm_key:
state: present state: present
key: https://getfedora.org/static/fedora.gpg key: https://getfedora.org/static/fedora.gpg
when: ansible_distribution in ['Red Hat Enterprise Linux', 'RedHat'] and not ansible_local.os.is_atomic when: ansible_distribution in ['Red Hat Enterprise Linux', 'RedHat'] and not is_atomic
- name: Install EPEL (dist pkg) - name: Install EPEL (dist pkg)
become: true become: true
ansible.builtin.package: ansible.builtin.package:
name: epel-release name: epel-release
state: present state: present
when: ansible_distribution in ['CentOS'] and not ansible_local.os.is_atomic when: ansible_distribution in ['CentOS'] and not is_atomic
- name: Install EPEL (upstream pkg) - name: Install EPEL (upstream pkg)
become: true become: true
ansible.builtin.package: ansible.builtin.package:
name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm" name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm"
state: present state: present
when: ansible_distribution in ['Red Hat Enterprise Linux', 'RedHat'] and not ansible_local.os.is_atomic when: ansible_distribution in ['Red Hat Enterprise Linux', 'RedHat'] and not is_atomic
- name: Disable NetworkManager phoning home (on Fedora, when enabled) - name: Disable NetworkManager phoning home on Fedora
become: true become: true
tags: ['phone', 'phoning']
ansible.builtin.file: ansible.builtin.file:
path: /etc/NetworkManager/conf.d/20-connectivity-fedora.conf path: /etc/NetworkManager/conf.d/20-connectivity-fedora.conf
access_time: preserve # make this properly idempotent, register no change when file exists access_time: preserve # make this properly idempotent, register no change when file exists
modification_time: preserve # ^ modification_time: preserve # ^
state: touch state: touch
mode: '0644' mode: '0644'
when: when: (ansible_distribution in ['Fedora'] and not is_atomic) and ('NetworkManager' in ansible_facts.packages)
- ansible_distribution in ['Fedora']
- not ansible_local.os.is_atomic
- "'NetworkManager.service' in ansible_facts.services"
- ansible_facts.services['NetworkManager.service'].status in ['enabled']
- name: Ensure systemd-oomd service and socket are disabled and stopped - name: Ensure systemd-oomd service and socket are disabled and stopped
become: true become: true
@ -113,7 +119,7 @@
with_items: with_items:
- systemd-oomd.service - systemd-oomd.service
- systemd-oomd.socket - systemd-oomd.socket
when: (ansible_distribution in ['Fedora'] and not ansible_local.os.is_atomic) when: (ansible_distribution in ['Fedora'] and not is_atomic)
- name: Ensure systemd-oomd service and socket are masked - name: Ensure systemd-oomd service and socket are masked
become: true become: true
@ -123,4 +129,13 @@
with_items: with_items:
- systemd-oomd.service - systemd-oomd.service
- systemd-oomd.socket - systemd-oomd.socket
when: (ansible_distribution in ['Fedora'] and not ansible_local.os.is_atomic) 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
tags:
- bootstrap

View file

@ -2,13 +2,11 @@
# depends on create-user role / create_username var # depends on create-user role / create_username var
- name: "Install Docker" - name: "Install Docker"
become: true
ansible.builtin.package: ansible.builtin.package:
name: "{{ docker_pkgs[ansible_distribution] }}" name: "{{ docker_pkgs[ansible_distribution] }}"
state: present state: present
- name: Enable/start docker - name: Enable/start docker
become: true
ansible.builtin.service: ansible.builtin.service:
name: docker name: docker
state: started state: started