1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

9 core roles check their vars + 3 roles record to iiab_state.yml

This commit is contained in:
root 2020-09-22 01:04:06 -04:00
parent 624fb68596
commit d87821d266
37 changed files with 737 additions and 416 deletions

View file

@ -0,0 +1,22 @@
#- name: Enable 'monit' service (chkconfig monit on)
# command: chkconfig monit on
# when: is_debian and ansible_local.local_facts.os_ver == "debian-8"
#- name: Restart monit service
# command: service monit restart
- name: Enable & (Re)Start 'monit' systemd service, if monit_enabled
systemd:
daemon_reload: yes
name: monit
enabled: yes
state: restarted
when: monit_enabled | bool
- name: Disable & Stop 'monit' service, if not monit_enabled
systemd:
daemon_reload: yes
name: monit
enabled: no
state: stopped
when: not monit_enabled

View file

@ -3,19 +3,19 @@
name: monit
state: present
- name: Install chkconfig package (debian-8)
package:
name: chkconfig
state: present
when: is_debian and ansible_distribution_major_version == "8"
# - name: Install chkconfig package (debian-8)
# package:
# name: chkconfig
# state: present
# when: is_debian and ansible_distribution_major_version == "8"
- name: Install /etc/monitrc from template
template:
backup: yes
src: monitrc
dest: /etc/monitrc
owner: root
group: root
#owner: root
#group: root
mode: '0600'
# - name: Install config file /etc/monit.d/watchdog from template (NEVER RUNS, WHY?)
@ -32,28 +32,6 @@
# retries: 5
# delay: 1
#TODO: create systemd script
- name: Enable 'monit' service (chkconfig monit on)
command: chkconfig monit on
when: is_debian and ansible_local.local_facts.os_ver == "debian-8"
#- name: Restart monit service
# command: service monit restart
- name: Add 'monit' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}"
section: monit
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Monit
- option: description
value: '"Monit is a background service monitor which can correct problems, send email, restart services."'
- option: enabled
value: "{{ monit_enabled }}"
# RECORD Monit AS INSTALLED

View file

@ -1,3 +1,24 @@
# "How do i fail a task in Ansible if the variable contains a boolean value?
# I want to perform input validation for Ansible playbooks"
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
- name: Assert that "monit_install is sameas true" (boolean not string etc)
assert:
that: monit_install is sameas true
fail_msg: "PLEASE SET 'monit_install: True' e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Assert that "monit_enabled | type_debug == 'bool'" (boolean not string etc)
assert:
that: monit_enabled | type_debug == 'bool'
fail_msg: "PLEASE GIVE VARIABLE 'monit_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
# 2019-07-06: The 'monit' package was suddenly removed from Debian 10.0.0
# "Buster" during the very final days prior to release, as confirmed by the
# sudden disappearance of these 2 pages:
@ -9,6 +30,30 @@
# be is_debian_10 in vars/raspbian-10.yml for now!) still provides 'monit' via
# apt -- so eliminating "Debian 10+" requires this funky conditional:
- name: Install 'monit' if monit_install and not Debian 10+
# 2020-09-21: The 'monit' package appears to be returning to Debian 11, per:
#
# https://packages.debian.org/bullseye/monit
# https://packages.debian.org/source/bullseye/monit
- name: Install Monit if 'monit_installed' not defined, e.g. in {{ iiab_state_file }} AND not Debian 10 # /etc/iiab/iiab_state.yml
include_tasks: install.yml
when: monit_install and not ((is_debian and not is_raspbian) and (not is_debian_8) and (not is_debian_9))
when: monit_installed is undefined and not (is_debian_10 and not is_raspbian)
#when: monit_installed is undefined and not ((is_debian and not is_raspbian) and (not is_debian_8) and (not is_debian_9))
- include_tasks: enable-or-disable.yml
- name: Add 'monit' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: monit
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Monit
- option: description
value: '"Monit is a background service monitor which can correct problems, send email, restart services."'
- option: enabled
value: "{{ monit_enabled }}"