refs #8025 send test email to AWX user email if defined, facts improved and renamed to debug

This commit is contained in:
Juan Ferrer 2025-02-06 11:20:14 +01:00
parent 7131a80cc7
commit f9921de0f0
4 changed files with 27 additions and 12 deletions

20
playbooks/debug.yml Normal file
View File

@ -0,0 +1,20 @@
- name: Gather facts from host and print variables
hosts: all
gather_facts: yes
tasks:
- name: Print ansible facts
tags: facts
debug:
var: ansible_facts
- name: Print all variables
tags: vars
debug:
var: vars
- name: Print variable value
tags: var
when: var_name is defined
debug:
msg: "{{ var_name }}: {{ lookup('vars', var_name, default='undefined') }}"

View File

@ -1,10 +0,0 @@
- name: Gather facts from host and print all variables
hosts: all
gather_facts: yes
tasks:
- name: Print all variables
debug:
var: vars
- name: Print variable value
debug:
msg: "Variable: {{ ansible_fqdn }}"

View File

@ -1,6 +1,7 @@
vn_env: lab
vn_first_time: false
vn_witness_checked: false
send_test_email: true
deb_packages:
- https://apt.verdnatura.es/pool/main/v/vn-host/vn-apt-source_3.0.1_all.deb
- https://apt.verdnatura.es/pool/main/v/vn-host/vn-host_3.0.1_all.deb

View File

@ -27,7 +27,11 @@
- name: Force execution of handlers immediately
meta: flush_handlers
- name: Sending mail to verify relay host configuration works
when: >
exim_config.changed
and send_test_email
and awx_user_email is defined
and awx_user_email | length > 0
shell: >
sleep 2; echo "If you see this message, relayhost on {{ ansible_fqdn }} has been configured correctly." \
| mailx -s "Relayhost test for {{ ansible_fqdn }}" "{{ sysadmin_mail }}"
when: exim_config.changed
| mailx -s "Relayhost test for {{ ansible_fqdn }}" "{{ awx_user_email }}"