--- - name: 'install monitoring agent requirements' apt: pkg: 'monitoring-plugins-basic' state: 'present' update_cache: true cache_valid_time: 3600 tags: - 'packages' - name: 'add monitoring plugin - check_mem.pl' copy: src: 'check_mem.pl' dest: '/usr/lib/nagios/plugins/check_mem.pl' mode: '0755' - name: 'create monitoring user' user: name: 'icinga' state: 'present' tags: - 'monitoring' - name: 'create monitoring entry' set_fact: agent_monitoring_entry: > {{ { host_fqdn: { 'address': ansible_host, 'agent_type': 'ssh', } } }} tags: - 'monitoring' - name: 'update monitoring facts' set_fact: monitoring_facts: > {{ hostvars[monitoring_host]['monitoring_facts'] | default({}) | combine(agent_monitoring_entry, recursive=true) }} delegate_facts: true delegate_to: '{{ monitoring_host }}' tags: - 'monitoring' ...