From 8518b767d170a0fed7a15efb76b01c58222e563c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20-=20Le=20Filament?= <theo@le-filament.com> Date: Tue, 29 Oct 2024 17:18:41 +0100 Subject: [PATCH] fix: collect package facts only for servers in maintenance --- tasks/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index d5bec29..d33cab1 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -319,13 +319,14 @@ changed_when: false register: known_hosts_line with_items: "{{ groups.backup_server }}" + when: inventory_hostname in groups.maintenance_contract - name: Add backup servers in root known host ansible.builtin.known_hosts: hash_host: true key: "{{ hostvars[item['item']].host_server_known_entry }}" name: "[{{ hostvars[item['item']].ansible_host }}]:{{ default_sshd_port }}" - when: item.found is not defined + when: inventory_hostname in groups.maintenance_contract and item.found is not defined with_items: "{{ known_hosts_line.results }}" - name: Copy Installed Package Listing script on server @@ -335,6 +336,7 @@ owner: root group: root mode: '0700' + when: inventory_hostname in groups.maintenance_contract - name: Disable e-mailing of crontab ansible.builtin.cron: @@ -348,3 +350,4 @@ minute: "43" hour: "0" job: /root/collect_installed_packages_facts.sh + when: inventory_hostname in groups.maintenance_contract -- GitLab