commit 46e62977ae2f7c11aa9eebabe1de2e87c35aea5d Author: Chris Hammer Date: Tue Apr 23 16:12:25 2024 -0400 initial project commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b8174f1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +ansible.cfg +hosts +collections/ansible_collections diff --git a/apache-precheck.yml b/apache-precheck.yml new file mode 100644 index 0000000..4d68038 --- /dev/null +++ b/apache-precheck.yml @@ -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 diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..530f89f --- /dev/null +++ b/requirements.yml @@ -0,0 +1,7 @@ +collections: + - name: community.general + version: 8.6.0 + + - name: ansible.posix + version: 1.5.4 + diff --git a/verify-apache.yml b/verify-apache.yml new file mode 100644 index 0000000..54e36c2 --- /dev/null +++ b/verify-apache.yml @@ -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