hostname variable inside of a file

43 views
Skip to first unread message

Frederick

unread,
Aug 25, 2022, 2:04:48 PM8/25/22
to Ansible Project
Good Day!

I am very new to Ansible so I apologize. I am trying to make a playbook where I push a file to the client host with the hostname/fqdn inside the file. For example:

My file: cluster/files/etciscsi-initiatorname.iscsi

InitiatorName=iqn.1994-05.com.redhat:{|rhn.system.hostname|}


Where {|rhn.system.hostname|} is replaced with the fqdn that the file is being pushed to. I figured out how to get the ansible_fqdn from the ansible_facts but i'm struggling beyond that.


[root@walter tasks]# cat initiatorname.iscsi.yml

---
- name: Copy configuration file
  copy: src=files/etciscsi-initiatorname.iscsi dest=/etc/iscsi/initiatorname.iscsi


Thank you


Mike Eggleston

unread,
Aug 25, 2022, 2:11:04 PM8/25/22
to ansible...@googlegroups.com
Are you doing this in a shell loop? Look at the -e option. 

Mike

On Aug 25, 2022, at 13:04, Frederick <nage...@gmail.com> wrote:

Good Day!
--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c69e5b9a-144c-4234-a00d-23b3eaa13fben%40googlegroups.com.

Rowe, Walter P. (Fed)

unread,
Aug 25, 2022, 2:16:02 PM8/25/22
to ansible...@googlegroups.com
I strongly encourage you to take the Red Hat Ansible class. It is a week long class and worth every penny.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

Frederick

unread,
Aug 25, 2022, 2:30:05 PM8/25/22
to Ansible Project
Thanks!
Reply all
Reply to author
Forward
0 new messages