How to use variable in path

24 views
Skip to first unread message

Sanjay Chakraborty

unread,
Oct 12, 2021, 12:22:39 PM10/12/21
to ansible...@googlegroups.com
I need to disable ipv6 on the network interface config file. The interface name is not the same for all environments. How I can achieve that ?
playbook :
----
- name: Disable ipv6 from interface
   hosts: groupone
   gather_facts: true
   ansible.builtin.replace:
       path: /etc/sysconfig/network-scripts/ifcfg-{{ item }}
       regexp: 'IPV6'
       replace: '#IPV6'
   loop: "{{ ansible_default_ipv4.interface }}"
#Wantlist=True
error msg: Invalide data pass to loop.
   

Matt Martz

unread,
Oct 12, 2021, 12:38:09 PM10/12/21
to ansible...@googlegroups.com
Just replace `{{ item }}` with `{{ ansible_default_ipv4.interface }}` and delete the `loop`

--
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/CAHOFgkSMd8UFRs52BuSn06qEZxSSSHdAMNZNs%3DO4Ypt%2BcWA%3Dww%40mail.gmail.com.


--
Matt Martz
@sivel
sivel.net

Sanjay Chakraborty

unread,
Oct 12, 2021, 1:21:28 PM10/12/21
to ansible...@googlegroups.com
It worked Matt!
Ironically I did try that but it was gather_fact = false and it failed previously. 
Thank you ! 

Regards,
Sanjay C.

Reply all
Reply to author
Forward
0 new messages