2016-12-04 10:02:05 +08:00
|
|
|
---
|
|
|
|
- hosts: all
|
|
|
|
gather_facts: true
|
|
|
|
become: yes
|
|
|
|
tasks:
|
|
|
|
|
2016-12-07 04:23:12 +08:00
|
|
|
- name: check if it is Atomic host
|
|
|
|
stat: path=/run/ostree-booted
|
|
|
|
register: stat_ostree
|
2017-10-25 22:53:34 +08:00
|
|
|
check_mode: no
|
2016-12-07 04:23:12 +08:00
|
|
|
|
|
|
|
- name: set fact for using Atomic host
|
|
|
|
set_fact:
|
|
|
|
is_atomic: '{{ stat_ostree.stat.exists }}'
|
|
|
|
|
2023-03-17 00:43:03 +08:00
|
|
|
# - name: List repo files
|
|
|
|
# find:
|
|
|
|
# paths: /etc/yum.repos.d/
|
|
|
|
# file_type: file
|
|
|
|
# patterns: 'CentOS-Stream-*.repo'
|
|
|
|
# register: pre_stream_repo_files
|
|
|
|
# when:
|
|
|
|
# - ansible_facts['distribution'] == 'CentOS'
|
|
|
|
# - ansible_facts['distribution_major_version'] | int > 7
|
|
|
|
# - not is_atomic | bool
|
|
|
|
#
|
|
|
|
# # From ansible docs: 'replace: If not set, matches are removed entirely.'
|
|
|
|
# - name: Remove all mirrorlists
|
|
|
|
# replace:
|
|
|
|
# path: "{{ item.path }}"
|
|
|
|
# regexp: '^mirrorlist=.*'
|
|
|
|
# with_items: "{{ pre_stream_repo_files.files }}"
|
|
|
|
# when:
|
|
|
|
# - ansible_facts['distribution'] == 'CentOS'
|
|
|
|
# - ansible_facts['distribution_major_version'] | int > 7
|
|
|
|
# - not is_atomic | bool
|
|
|
|
#
|
|
|
|
# - name: Uncomment baseurls
|
|
|
|
# replace:
|
|
|
|
# path: "{{ item.path }}"
|
|
|
|
# regexp: '^mirrorlist=.*'
|
|
|
|
# regexp: '^\s*#*\s*(baseurl=.*)'
|
|
|
|
# replace: '\1'
|
|
|
|
# with_items: "{{ pre_stream_repo_files.files }}"
|
|
|
|
# when:
|
|
|
|
# - ansible_facts['distribution'] == 'CentOS'
|
|
|
|
# - ansible_facts['distribution_major_version'] | int > 7
|
|
|
|
# - not is_atomic | bool
|
|
|
|
#
|
|
|
|
# - name: Point baseurls to archive server
|
|
|
|
# replace:
|
|
|
|
# path: "{{ item.path }}"
|
|
|
|
# regexp: 'mirror.centos.org/\$contentdir/\$stream'
|
|
|
|
# replace: 'apt-mirror.front.sepia.ceph.com/centos/8-stream'
|
|
|
|
# with_items: "{{ pre_stream_repo_files.files }}"
|
|
|
|
# when:
|
|
|
|
# - ansible_facts['distribution'] == 'CentOS'
|
|
|
|
# - ansible_facts['distribution_major_version'] | int > 7
|
|
|
|
# - not is_atomic | bool
|
2022-04-14 02:51:08 +08:00
|
|
|
|
2024-03-20 01:31:47 +08:00
|
|
|
- name: update the system on RHEL-based OS # noqa: package-latest
|
|
|
|
ansible.builtin.yum:
|
|
|
|
name: '*'
|
|
|
|
state: latest
|
|
|
|
register: yum_upgrade
|
|
|
|
when: ansible_facts['os_family'] == 'RedHat'
|
|
|
|
|
|
|
|
- name: update the system on Debian-based OS # noqa: package-latest
|
|
|
|
ansible.builtin.apt:
|
|
|
|
name: '*'
|
|
|
|
state: latest
|
|
|
|
update_cache: true
|
|
|
|
when: ansible_facts['os_family'] == 'Debian'
|
2022-03-18 21:41:40 +08:00
|
|
|
|
2019-04-12 22:46:20 +08:00
|
|
|
- name: get root mount information
|
|
|
|
set_fact:
|
2021-03-03 22:43:50 +08:00
|
|
|
rootmount: "{{ ansible_facts['mounts']|json_query('[?mount==`/`]|[0]') }}"
|
2019-04-12 22:46:20 +08:00
|
|
|
|
2019-07-19 02:57:46 +08:00
|
|
|
# mount -o remount doesn't work on RHEL 8 for now
|
2019-04-12 22:46:20 +08:00
|
|
|
- name: add mount options to /
|
2022-06-15 00:18:36 +08:00
|
|
|
ansible.posix.mount:
|
2019-04-12 22:46:20 +08:00
|
|
|
path: '{{ rootmount.mount }}'
|
|
|
|
src: '{{ rootmount.device }}'
|
2024-03-20 01:31:47 +08:00
|
|
|
opts: "noatime,nodiratime,nobarrier"
|
2019-04-12 22:46:20 +08:00
|
|
|
fstype: '{{ rootmount.fstype }}'
|
|
|
|
state: mounted
|
|
|
|
|
2016-12-07 04:24:36 +08:00
|
|
|
# we need to install this so the Socket testinfra module
|
|
|
|
# can use netcat for testing
|
2016-12-07 04:23:12 +08:00
|
|
|
- name: install net-tools
|
|
|
|
package:
|
|
|
|
name: net-tools
|
|
|
|
state: present
|
2018-12-19 21:55:01 +08:00
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
2019-05-22 16:02:42 +08:00
|
|
|
when: not is_atomic | bool
|
2018-05-28 18:02:49 +08:00
|
|
|
|
2024-03-20 01:31:47 +08:00
|
|
|
- name: Resize logical volume for root partition to fill remaining free space
|
2018-06-01 17:32:00 +08:00
|
|
|
lvol:
|
|
|
|
lv: root
|
|
|
|
vg: atomicos
|
|
|
|
size: +100%FREE
|
|
|
|
resizefs: yes
|
2019-05-22 16:02:42 +08:00
|
|
|
when: is_atomic | bool
|