On 31.05.16 21:19 John.1209 wrote:
> I need to ensure that the /etc/sysconfig/network file contains the FQDN on 
> a good number of hosts.  I think the lineinfile module would be helpful 
> here.  But I'm sure how to write the Ansible script to do so.  Any advice?

Start with:
https://gist.github.com/muloka/7687250
https://docs.ansible.com/ansible/lineinfile_module.html

Rough draft (untested):
###############

- fail: msg="Variable ansible_fqdn is not set"
  when: ansible_fqdn is undefind

- name: Test lineinfile
  lineinfile: dest=/etc/sysconfig/network regexp=^XYZ line="{{
ansible_fqdn }}"

###############

The most important part is the regexp, which tells the lineinfile
module which line you want to change.

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/574DE729.30903%40ojkastl.de.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to