I am trying to use Ansible to replace a sample text with a variable. I have tried using no quotes, "", and '', but nothing seems to work. I also tried using the replace module and the lineinfile module.
Please let me know what I am doing wrong.
- hosts: 10.1.1.10
become: yes
vars:
server1:
1a: "ED:5A:13:AA:34:20"
2a: "ED:5A:13:AA:34:21"
tasks:
- name: Replace mac address in file
lineinfile:
path: /tmp/file.json.j2
regexp: 'FILL_THIS_IN'
line: "{{ server1.1a }}"
Best Answer
Excerpt from the documentation about variables:
So you should refactor to:
and in the code: