In the setup module (get_facts), Ansible should be detecting an FQDN that
you can access with '{{ ansible_fqdn }}'
I would use the lineinfile module. A rough draft (untested) without
> correct indentation:
>
> - name: "Ensure FQDN is present"
> lineinfile:
> dest=/etc/sysconfig/network
> line="HOSTNAME={{ ansible_fqdn }}"
>
> regexp="^HOSTNAME=.*"
> insertafter=EOF
> state=present
>
> This has to be adapted, of course. Replace FQDN with your real fqdn.
>
> Basically this looks for a line beginning with "HOSTNAME" (the regexp
> part) and replaces it with the line "HOSTNAME=FQDN". If there is no
> line matching the regexp, it puts the line at the end of the file.
>
> Johannes
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/4708afb9-da95-4f0b-8382-b44d3c6b97f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.