Compare commits
3 Commits
main
...
reboot_mod
Author | SHA1 | Date | |
---|---|---|---|
562868e187 | |||
f831e3a0cb | |||
16f8bdd07d |
3
.ci.env
3
.ci.env
@ -1,3 +0,0 @@
|
|||||||
export ANSIBLE_LINT_EXCLUSION="--exclude .gitea"
|
|
||||||
export ANSIBLE_INVENTORY="-i 127.0.0.1, --connection=local"
|
|
||||||
export ANSIBLE_PLAYBOOK=""
|
|
@ -1,30 +0,0 @@
|
|||||||
name: Ansible Code Pipeline
|
|
||||||
run-name: ${{ gitea.actor }} is running Ansible Code Pipeline
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
Ansible-Development-Pipeline:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ ansible-dev-fedora ]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Clone repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Ansible Environment Verify
|
|
||||||
run: |
|
|
||||||
whoami
|
|
||||||
. ./.ci.env
|
|
||||||
env
|
|
||||||
git log -1
|
|
||||||
ansible --version
|
|
||||||
ansible-lint --version
|
|
||||||
|
|
||||||
- name: Run Ansible-Lint
|
|
||||||
run: |
|
|
||||||
. ./.ci.env
|
|
||||||
ansible-lint -v --offline $ANSIBLE_LINT_EXCLUSION
|
|
@ -1,38 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Check for mounted NFS shares # noqa: command-instead-of-module
|
|
||||||
ansible.builtin.command: mount -t nfs,nfs4
|
|
||||||
register: lazy_reboot_nfs_mounts
|
|
||||||
changed_when: false
|
|
||||||
failed_when: lazy_reboot_nfs_mounts['rc'] not in [0, 32]
|
|
||||||
|
|
||||||
- name: Create a list of NFS mount points
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
lazy_reboot_nfs_list:
|
|
||||||
"{{ lazy_reboot_nfs_mounts['stdout_lines'] | map('split') | map(attribute=2) | list }}"
|
|
||||||
|
|
||||||
- name: Verify mount status and reboot host
|
|
||||||
block:
|
|
||||||
- name: Verify mount status
|
|
||||||
ansible.builtin.command: "ls {{ item }}"
|
|
||||||
timeout: 5
|
|
||||||
changed_when: false
|
|
||||||
register: r_lazy_reboot_verify_mounts
|
|
||||||
loop: "{{ lazy_reboot_nfs_list }}"
|
|
||||||
loop_control:
|
|
||||||
label: "{{ item }}"
|
|
||||||
|
|
||||||
rescue:
|
|
||||||
- name: Group shares that failed status check
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
lazy_reboot_failed_shares:
|
|
||||||
"{{ r_lazy_reboot_verify_mounts['results'] | selectattr('failed') | map(attribute='item') | list }}"
|
|
||||||
|
|
||||||
- name: Lazily unmount the failed shares
|
|
||||||
ansible.builtin.command: "umount -f -l {{ item }}"
|
|
||||||
changed_when: false
|
|
||||||
register: r_lazy_unmount
|
|
||||||
async: 30
|
|
||||||
poll: 0
|
|
||||||
loop: "{{ lazy_reboot_failed_shares }}"
|
|
||||||
loop_control:
|
|
||||||
label: "{{ item }}"
|
|
@ -1,7 +1,4 @@
|
|||||||
---
|
---
|
||||||
- name: Check for hung NFS mounts
|
|
||||||
ansible.builtin.include_tasks: hung_nfs_check.yml
|
|
||||||
|
|
||||||
- name: Capture initial boot ID
|
- name: Capture initial boot ID
|
||||||
ansible.builtin.slurp:
|
ansible.builtin.slurp:
|
||||||
src: "{{ verified_reboot_bootid_file }}"
|
src: "{{ verified_reboot_bootid_file }}"
|
||||||
@ -12,9 +9,19 @@
|
|||||||
verified_reboot_pre_boot_id: "{{ verified_reboot_pre_boot_id_raw['content'] | b64decode | trim }}"
|
verified_reboot_pre_boot_id: "{{ verified_reboot_pre_boot_id_raw['content'] | b64decode | trim }}"
|
||||||
verified_reboot_check_count: 0
|
verified_reboot_check_count: 0
|
||||||
|
|
||||||
- name: Reboot the host
|
- name: Reboot host using reboot module or fallback
|
||||||
ansible.builtin.command:
|
block:
|
||||||
cmd: "/usr/sbin/shutdown -r +{{ verified_reboot_reboot_time }} '{{ verified_reboot_reboot_msg }}'"
|
- name: Reboot the host [reboot module]
|
||||||
|
ansible.builtin.reboot:
|
||||||
|
msg: "{{ verified_reboot_reboot_msg }}"
|
||||||
|
pre_reboot_delay: "{{ (verified_reboot_reboot_time ~ 'm') | community.general.to_seconds }}"
|
||||||
|
connect_timeout: "{{ verified_reboot_wait_conn_timeout }}"
|
||||||
|
reboot_timeout: "{{ verified_reboot_wait_delay }}"
|
||||||
|
rescue:
|
||||||
|
- name: Reboot the host [fallback]
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: "/usr/sbin/shutdown -r +{{ verified_reboot_reboot_time }} '{{ verified_reboot_reboot_msg }}'"
|
||||||
|
|
||||||
- name: Verify reboot status of host
|
always:
|
||||||
ansible.builtin.include_tasks: check_boot_id.yml
|
- name: Verify reboot status of host
|
||||||
|
ansible.builtin.include_tasks: check_boot_id.yml
|
||||||
|
Reference in New Issue
Block a user