initial project commit

This commit is contained in:
Chris Hammer 2024-04-23 16:12:25 -04:00
commit 46e62977ae
4 changed files with 97 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
ansible.cfg
hosts
collections/ansible_collections

69
apache-precheck.yml Normal file
View File

@ -0,0 +1,69 @@
---
- name: Apache Pre-Check
hosts: all
become: true
gather_facts: true
vars:
mw_apache_bin: 'httpd'
mw_apache_pkg: 'httpd'
# mw_apache_pkg: 'php'
tasks:
- name: Check if Middleware Apache package is present
ansible.builtin.package:
name: "{{ mw_apache_pkg }}"
state: present
check_mode: true
changed_when: false
register: mw_apache_pkg_check
- name: Debug mw_apache_pkg_check
ansible.builtin.debug:
var: mw_apache_pkg_check
- name: Verify Middleware Apache package and process presence
block:
- name: Assert that Middleware Apache package is present
ansible.builtin.assert:
that: mw_apache_pkg_check['results'] | length == 0
success_msg: Middleware Apache is installed on this host.
fail_msg: Middleware Apache is NOT installed on this host.
- name: Set Middleware Apache presence flag
ansible.builtin.set_stats:
data:
mw_apache_is_installed: true
rescue:
- name: Set Middleware Apache presence flag
ansible.builtin.set_stats:
data:
mw_apache_is_installed: false
- name: Middleware Apache package not present. Ending host.
ansible.builtin.meta: end_play
- name: Verify if Middleware Apache process is running
block:
- name: Check if any Middleware Apache processes are running
community.general.pids:
name: "{{ mw_apache_bin }}"
register: mw_apache_pids
- name: Assert that Middleware Apache process is running
ansible.builtin.assert:
that: mw_apache_pids['pids'] | length >= 2
success_msg: Middleware Apache is running on this host.
fail_msg: Middleware Apache is NOT running on this host.
- name: Set Middleware Apache process running flag
ansible.builtin.set_stats:
data:
mw_apache_is_running: true
rescue:
- name: Set Middleware Apache process running flag
ansible.builtin.set_stats:
data:
mw_apache_is_running: false

7
requirements.yml Normal file
View File

@ -0,0 +1,7 @@
collections:
- name: community.general
version: 8.6.0
- name: ansible.posix
version: 1.5.4

18
verify-apache.yml Normal file
View File

@ -0,0 +1,18 @@
---
- name: Verify Middleware Apache
hosts: all
become: true
gather_facts: false
tasks:
- name: Verify Middleware Apache package presence
ansible.builtin.debug:
msg: "Middleware Apache package is present on this host."
when:
- mw_apache_is_installed | bool
- name: Verify Middleware Apache process is running
ansible.builtin.debug:
msg: "Middleware Apache process is running."
when:
- mw_apache_is_running | bool