Initial project commit

This commit is contained in:
2024-12-16 19:59:57 -05:00
commit fa1b5cce00
3409 changed files with 460909 additions and 0 deletions

View File

@ -0,0 +1,2 @@
---
rear_unmount_nfs_path: /var/tmp/nfs_mnt

View File

@ -0,0 +1,25 @@
---
- name: Try to unmount the filesystem
block:
- name: Unmount filesystem
ansible.posix.mount:
path: "{{ rear_unmount_nfs_path }}"
state: unmounted
delay: 3
retries: 3
rescue:
- name: "Rescue: Lazy unmount the NFS share"
ansible.builtin.command:
cmd: "umount -l {{ rear_unmount_nfs_path }}"
- name: Log unmount rescue to syslogger
community.general.syslogger:
msg: "{{ lookup('template', 'syslog.j2') | replace('\n', ' ') }}"
ident: ansbl_rear_unmount_rescue
vars:
actor: "rear_unmount_rescue"
title: >
ReaR Unmount Rescue
summary: "Unable to unmount the filesystem {{ rear_unmount_nfs_path }} using POSIX module. Rescued via lazy unmount."
severity: "high"
flags: ["inhibitor"]

View File

@ -0,0 +1,17 @@
actor="{{ actor | default(item.actor) }}"
title="{{ title | default(item.title) }}"
{% if (item.actor is defined) and item.actor in remeditated_inhibitors %}
flags="{{ item.flags + ['remediated_in_automation'] }}"
{% else %}
flags="{{ flags | default(item.flags) }}"
{% endif %}
summary="{{ summary | default(item.summary) }}"
severity="{{ severity | default(item.severity) }}"
{% if item.detail.remediations is defined %}
remediation="{{
item.detail.remediations | selectattr('type', 'equalto', 'hint') |
map(attribute='context') | join(', ') }}"
{% else %}
remediation="{{ remediation | default('') }}"
{% endif %}
ansible_tower_job_id="{{ tower_job_id | default(None) }}"

5
roles/requirements.yml Normal file
View File

@ -0,0 +1,5 @@
---
- name: verified_reboot
src: https://gitea.thezengarden.net/ansible_plays/verified_reboot.git
scm: git
version: main

View File

@ -0,0 +1,5 @@
skip_list:
- yaml[colons]
- yaml[empty-lines]
- yaml[line-length]
- no-changed-when

View File

@ -0,0 +1,6 @@
verified_reboot
=========
This role will use proc's boot_id file to determine if a host has rebooted or not.

View File

@ -0,0 +1,24 @@
---
verified_reboot_reboot_time: 1 # Time in minutes issued to the shutdown command
verified_reboot_reboot_msg: '*** ANSIBLE INITIATED REBOOT ***'
verified_reboot_bootid_file: /proc/sys/kernel/random/boot_id
# Maximum number of times to check for a successful reboot
verified_reboot_max_checks: 10
# Maximum number of seconds to wait for a connection to happen before closing and retrying.
verified_reboot_wait_conn_timeout: 20
# Number of seconds to sleep between checks.
verified_reboot_wait_sleep: 10
# Number of seconds to wait before starting to poll.
verified_reboot_wait_delay: 70
# Maximum number of seconds to wait for.
#
# We need to ensure this is long enough to cover ANY reboot
# from either Bigboot or IPU based reboots using this
#
# Default: 1800 (30mins)
verified_reboot_wait_timeout: 1800

View File

@ -0,0 +1,2 @@
install_date: 'Tue 10 Dec 2024 09:27:56 PM '
version: main

View File

@ -0,0 +1,26 @@
galaxy_info:
author: Chris Hammer
description: This role will use proc's boot_id file to determine if a host has rebooted or not.
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: BSD-3-Clause
min_ansible_version: "2.14"
platforms:
- name: EL
versions:
- "7"
- "8"
- "9"

View File

@ -0,0 +1,47 @@
---
- name: Max check count reached
ansible.builtin.fail:
msg: "Max check count ({{ verified_reboot_max_checks }}) reached. Aborting after {{ verified_reboot_check_count }} tries."
when:
- verified_reboot_check_count | int >= verified_reboot_max_checks
- name: Increment check count
ansible.builtin.set_fact:
verified_reboot_check_count: "{{ verified_reboot_check_count | int + 1 }}"
- name: Current Iteration
ansible.builtin.debug:
msg: "{{ verified_reboot_check_count }}"
verbosity: 1
- name: Wait for host to connect or try again
block:
- name: Wait for connection to host
ansible.builtin.wait_for_connection:
connect_timeout: "{{ verified_reboot_wait_conn_timeout }}"
sleep: "{{ verified_reboot_wait_sleep }}"
delay: "{{ verified_reboot_wait_delay }}"
timeout: "{{ verified_reboot_wait_timeout }}"
rescue:
- name: Re-check host status - RESCUE
ansible.builtin.include_tasks: check_boot_id.yml
- name: Capture boot ID post reboot
ansible.builtin.slurp:
src: "{{ verified_reboot_bootid_file }}"
register: verified_reboot_post_boot_id_raw
- name: Set post-reboot boot ID
ansible.builtin.set_fact:
verified_reboot_post_boot_id: "{{ verified_reboot_post_boot_id_raw['content'] | b64decode | trim }}"
- name: Debug boot IDs
ansible.builtin.debug:
msg: "{{ verified_reboot_pre_boot_id }} == {{ verified_reboot_post_boot_id }}"
verbosity: 1
- name: Re-check host status
ansible.builtin.include_tasks: check_boot_id.yml
when:
- verified_reboot_pre_boot_id == verified_reboot_post_boot_id
- verified_reboot_check_count | int < verified_reboot_max_checks

View File

@ -0,0 +1,17 @@
---
- name: Capture initial boot ID
ansible.builtin.slurp:
src: "{{ verified_reboot_bootid_file }}"
register: verified_reboot_pre_boot_id_raw
- name: Set pre-reboot boot ID
ansible.builtin.set_fact:
verified_reboot_pre_boot_id: "{{ verified_reboot_pre_boot_id_raw['content'] | b64decode | trim }}"
verified_reboot_check_count: 0
- name: Reboot the host
ansible.builtin.command:
cmd: "/usr/sbin/shutdown -r +{{ verified_reboot_reboot_time }} '{{ verified_reboot_reboot_msg }}'"
- name: Verify reboot status of host
ansible.builtin.include_tasks: check_boot_id.yml