Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make sure when condition doesnt break maintenance_only #73

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions roles/maintenance_10_linux/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@
name: "Logrotate: Are there large files that point to a too verbose service?"
ansible.builtin.debug:
msg: "List of unrotated logs: {{ unmanaged_logs }}"
when: "unmanaged_logs | length > 0"
when:
- "vars.taskid not in maintenance_exclude_tasks"
- "maintenance_only is not defined or maintenance_only == vars.taskid"
- "unmanaged_logs | length > 0"
changed_when: "unmanaged_logs | length > 0"

- <<: *task
Expand Down Expand Up @@ -230,16 +233,20 @@
line: "root: {{ linux_serverlogs_root_alias }}"
insertbefore: EOF
when:
- "'postfix' in ansible_facts.packages"
- "vars.taskid not in maintenance_exclude_tasks"
- "maintenance_only is not defined or maintenance_only == vars.taskid"
- "'postfix' in ansible_facts.packages"
check_mode: true

- <<: *task
vars:
taskid: 10-051
name: "Mail: aliases.db: Make sure /etc/aliases.db is up to date"
ansible.builtin.shell: "[ -f /etc/aliases ] && postalias /etc/aliases || exit 2"
when: "'postfix' in ansible_facts.packages"
when:
- "vars.taskid not in maintenance_exclude_tasks"
- "maintenance_only is not defined or maintenance_only == vars.taskid"
- "'postfix' in ansible_facts.packages"
changed_when: "task.rc == 2" # rc == 2 => file doesn't exist
failed_when: "task.rc == 1" # rc == 1 => postalias failed

Expand All @@ -249,7 +256,10 @@
name: "Netboxinventory: Make sure pkg list is populated"
ansible.builtin.fail:
msg: "Error: Pkg list from host is empty"
when: "ansible_facts.packages | length == 0"
when:
- "vars.taskid not in maintenance_exclude_tasks"
- "maintenance_only is not defined or maintenance_only == vars.taskid"
- "ansible_facts.packages | length == 0"

- <<: *task
vars:
Expand Down
5 changes: 4 additions & 1 deletion roles/maintenance_31_nginx/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
name: "SSL: If in use, will SSL certificate be valid in a month"
ansible.builtin.debug:
msg: "{{ item.not_after }}: {{ item.subject }}"
when: not (item.valid_at.one_month_later | default(true))
when:
- "vars.taskid not in maintenance_exclude_tasks"
- "maintenance_only is not defined or maintenance_only == vars.taskid"
- not (item.valid_at.one_month_later | default(true))
changed_when: true
loop: "{{ nginx_cert_info.results }}"