i am running below task and replacing whole content in the destination file with ip address
---
- hosts: localhost
connection: local
tasks:
- debug: var=ansible_all_ipv4_addresses
- debug: var=ansible_default_ipv4.address
- copy: content="{{ ansible_all_ipv4_addresses }}" dest=/root/curator.yml
i have variable in curator.yml, i want to update variable {{ ansible_default_ipv4.address }} with ip address.
---
client:
hosts:
- {{ ansible_default_ipv4.address }}
port: 9200
url_prefix:
use_ssl: False
ssl_no_validate: False
http_auth:
timeout: 30
master_only: False
logging:
loglevel: INFO
logfile:
logformat: default
blacklist: ['elasticsearch', 'urllib3']
When i execute above playbook task it's replacing whole information in curator.yml with ip address in the debug output
PLAY [localhost] ****************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************** ok: [localhost]
TASK [debug] ******************************************************************************************************************** ok: [localhost] => { "ansible_all_ipv4_addresses": [ "10.0.0.5" ] }
TASK [debug] ******************************************************************************************************************** ok: [localhost] => { "ansible_default_ipv4.address": "10.0.0.5" }
TASK [copy] ********************************************************************************************************************* changed: [localhost]
PLAY RECAP ********************************************************************************************************************** localhost : ok=4 changed=1 unreachable=0 failed=0
i am also included below task but looks like it's not working
#- name: rewrite
# vars:
# ansible_default_ipv4.address: "{{ ansible_default_ipv4.address[0] }}"
# template:
# src: templates/curator.yml.j2
# dest: /root/curator.yml