ansible-collection/roles/cron_healthcheck_script/tasks/validate-config.yml
GregoryDosh b19fa02af3
All checks were successful
Update Version / Update Version (push) Successful in 11s
fix: small quick hack for TZ /etc/timezone when missing (deprecated path)
2025-09-10 13:27:48 -05:00

65 lines
2.7 KiB
YAML

# Ansible Roles for managing Auengun.net Infrastructure & Testing/Learning.
# Source available at git.auengun.net/homelab/ansible-collection
# Copyright (C) 2023 GregoryDosh
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# SPDX-License-Identifier: AGPL-3.0-or-later
# SPDX-FileCopyrightText: 2023 GregoryDosh
---
- name: Grab System TZ
ansible.builtin.shell: |
cat /etc/timezone 2>/dev/null || echo -n 'Etc/UTC'
changed_when: false
register: "_host_tz_stdout"
- name: Register absolute paths for binaries
ansible.builtin.shell: |
command -v {{ item.bin }}
ignore_errors: true
changed_when: false
register: "_BIN_ABSOLUTE_PATHS"
with_items:
- { var: CURL_BIN_ABSOLUTE_PATH, bin: "curl" }
- { var: MKTEMP_BIN_ABSOLUTE_PATH, bin: "mktemp" }
- ansible.builtin.set_fact:
HEALTHCHECK_SCHEDULE_TZ: "{{ HEALTHCHECK_SCHEDULE_TZ | default(_host_tz_stdout.stdout) }}"
CURL_BIN_ABSOLUTE_PATH: "{{ CURL_BIN_ABSOLUTE_PATH | default(_BIN_ABSOLUTE_PATHS.results[0].stdout) }}"
MKTEMP_BIN_ABSOLUTE_PATH: "{{ MKTEMP_BIN_ABSOLUTE_PATH | default(_BIN_ABSOLUTE_PATHS.results[1].stdout) }}"
- name: Validate required variables defined.
ansible.builtin.assert:
that:
- "HEALTHCHECK_SCHEDULE_TZ | length > 0"
- "CURL_BIN_ABSOLUTE_PATH | length > 0"
- "HEALTHCHECK_CRON_DAY | length > 0"
- "HEALTHCHECK_CRON_HOUR | length > 0"
- "HEALTHCHECK_CRON_MINUTE | length > 0"
- "HEALTHCHECK_CRON_MONTH | length > 0"
- "HEALTHCHECK_CRON_USER | length > 0"
- "HEALTHCHECK_CRON_WEEKDAY | length > 0"
- "HEALTHCHECK_FILE_BASEPATH | length > 0"
- "HEALTHCHECK_FILE_CONTENT | length > 0"
- "HEALTHCHECK_FILE_GROUP | length > 0"
- "HEALTHCHECK_FILE_MODE | length > 0"
- "HEALTHCHECK_FILE_NAME | length > 0"
- "HEALTHCHECK_FILE_USER | length > 0"
- "HEALTHCHECK_GRACE | string | length > 0"
- "HEALTHCHECK_NAME | length > 0"
- "HEALTHCHECK_SCHEDULE | length > 0"
- "HEALTHCHECK_SITE_API_KEY | length > 0"
- "HEALTHCHECK_SITE_URL | length > 0"
- "HEALTHCHECK_TAGS | length > 0"
- "MKTEMP_BIN_ABSOLUTE_PATH | length > 0"