ansible-collection/roles/dcaass/tasks/pre-setup-and-validation.yml
GregoryDosh b24a51083d
Some checks failed
Create Release / Create Release (push) Failing after 6s
Update Version / Update Version (push) Successful in 6s
ci: adjust ci to use more license information & sha for tracing
2024-12-10 20:40:44 -06:00

75 lines
3 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: Fail if systemd not found
when: ansible_service_mgr != 'systemd'
ansible.builtin.fail:
msg: >-
Service Manager `systemd` not found.
- name: Fail if using deprecated variables
ansible.builtin.fail:
msg: >-
Remove or update deprecated var: {{ item }}
when: "item in vars"
with_items:
- DCAASS_SERVICE_ALLOW_ANSIBLE_RESTART
- name: Register absolute paths for bins
ansible.builtin.shell: |
command -v {{ item }}
ignore_errors: true
changed_when: false
register: "_BIN_ABSOLUTE_PATHS"
with_items:
- docker
- sh
- xargs
- name: Parse binary paths from ansible list
ansible.builtin.set_fact:
DOCKER_BIN_ABSOLUTE_PATH: "{{ DOCKER_BIN_ABSOLUTE_PATH | default(_BIN_ABSOLUTE_PATHS.results[0].stdout) }}"
SH_BIN_ABSOLUTE_PATH: "{{ SH_BIN_ABSOLUTE_PATH | default(_BIN_ABSOLUTE_PATHS.results[1].stdout) }}"
XARGS_BIN_ABSOLUTE_PATH: "{{ XARGS_BIN_ABSOLUTE_PATH | default(_BIN_ABSOLUTE_PATHS.results[2].stdout) }}"
- name: Validate required variables defined.
ansible.builtin.assert:
that:
- "DCAASS_CONFIG_DIR_MODE | length > 0"
- "DCAASS_CONFIG_FILE_MODE | length > 0"
- "DCAASS_CONFIG_GROUP_NAME | length > 0"
- "DCAASS_CONFIG_PATH | length > 0"
- "DCAASS_CONFIG_USER_NAME | length > 0"
- "DCAASS_DOCKER_COMPOSE | length > 0"
- "DCAASS_DOCKER_COMPOSE_BASE_TEMPLATE | length > 0"
- "DCAASS_DOCKER_COMPOSE_PATH | length > 0"
- "DCAASS_ENV_FILE_NAME | length > 0"
- "DCAASS_SERVICE_AFTER | length > 0"
- "DCAASS_SERVICE_ANSIBLE_ALLOW_RESTART | string | length > 0"
- "DCAASS_SERVICE_ANSIBLE_RELOAD_TYPE | length > 0"
- "DCAASS_SERVICE_GROUP_NAME | length > 0"
- "DCAASS_SERVICE_NAME | length > 0"
- "DCAASS_SERVICE_REQUIRES | length > 0"
- "DCAASS_SERVICE_RESTART_POLICY | length > 0"
- "DCAASS_SERVICE_RESTART_SEC | string | length > 0"
- "DCAASS_SERVICE_USER_NAME | length > 0"
- "DOCKER_BIN_ABSOLUTE_PATH | length > 0"
- "SH_BIN_ABSOLUTE_PATH | length > 0"
- "XARGS_BIN_ABSOLUTE_PATH | length > 0"