inventory_hostname

16 views
Skip to first unread message

richard kappler

unread,
Jun 9, 2015, 3:05:45 PM6/9/15
to ansible...@googlegroups.com
trying to replace a word in file. I have a testfile1.conf:

-------------------------------------------
this is a test file
this server name is placeholder
-------------------------------------------

I have an inventory file (and a hosts file, still trying to figure those out):

[servers]
server01 ansible_ssh_host=192.168.6.131
server02 ansible_ssh_host=192.168.6.139
server03 ansible_ssh_host=192.168.6.140

and my playbook:

---
- name: read IP from hosts match w var replace with vars
  hosts: servers
  tasks:

   - name: replace placeholder
     replace:
          dest=/vartest/testfile1.conf
          regexp='placeholder'
          replace={{ inventory_hostname }}
          backup=no


When I run the playbook, I get no errors, but instead of putting in the server name (server01, server02, or server03) it puts in the IP address of the target machine.

What am I missing? 

regards, Richard
Reply all
Reply to author
Forward
0 new messages