Skip to content
Snippets Groups Projects
Commit 5c1be6ca authored by Chris Croome's avatar Chris Croome
Browse files

Generate local_facts using a2query

parent 0e464423
No related branches found
No related tags found
No related merge requests found
Pipeline #20416 passed
......@@ -28,6 +28,7 @@ apache_dhparam_path: /etc/apache2/dhparam.pem
apache_dhparam_size: 2048
apache_localhost_port: 80
apache_ulimit: 65536
apache_a2query: /usr/sbin/a2query
apache_packages_present:
- lynx
# - libapache2-mod-fcgid
......
---
- name: Ansible local facts
block:
- name: Required packages present
ansible.builtin.apt:
pkg:
- jo
state: present
- name: Ansible facts.d directory present
ansible.builtin.file:
path: /etc/ansible/facts.d
recurse: true
state: directory
mode: 0700
owner: root
group: root
- name: Ansible a2query local facts script present
ansible.builtin.template:
src: a2query.fact.j2
dest: /etc/ansible/facts.d/a2query.fact
mode: 0700
owner: root
group: root
- name: Re-read Ansible local facts
ansible.builtin.setup:
filter: ansible_local
tags:
- quota
...
......@@ -28,6 +28,9 @@
update_cache: false
when: ( apache_packages_present is defined ) and ( apache_packages_present != [] )
- name: Include local facts tasks
include_tasks: local_facts.yml
- name: Include Apache checks
include_tasks: checks.yml
......
#!/usr/bin/env bash
# {{ ansible_managed }}
set -euo pipefail
IFS=$'\n'
A2QUERY="{{ apache_a2query }}"
if [[ -f "${A2QUERY}" ]]; then
jo state=present version=$(${A2QUERY} -v) mpm=$(${A2QUERY} -M) \
conf_enabled=$(${A2QUERY} -c | awk '{ print $1 }' | sort | jo -a) \
modules_enabled=$(${A2QUERY} -m | awk '{ print $1 }' | sort | jo -a) \
sites_enabled=$(${A2QUERY} -s | awk '{ print $1 }' | sort | jo -a)
else
jo state=absent
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment