I’m trying to come up with an ansible process to compare a DNS against an FQDN:
This is what I have:
I’m trying to come up with an ansible process to compare a DNS against an FQDN:
This is what I have:
This is not working? Is there a better way to do this? Or please suggest a fix.
Consider using the dig-lookup: https://docs.ansible.com/ansible/playbooks_lookups.html#the-dns-lookup-dig
Cheers,
Paul
Your tasks: is misplaced and indentation is wrong, but this should work
- name: Set DNS variable
command: dig {{ ansible_fqdn }} +short
register: DNSOUT
- name: Verify DNS
command: echo not in DNS!
when: DNSOUT.stdout == ""
The Verify DNS task won't show you anything on in the console, if that's what you are after you can do it like this
- debug: msg="{{ ansible_fqdn }} not in DNS!"
when: DNSOUT.stdout == ""