- name: set default route with connecting ipv4
hosts: nodes
tasks:
- name: make default gw
command: sudo bash -c "export IP={{ IP }}; ip r | grep $IP |grep -Po 'dev \K\S+' |xargs -I{} bash -c \"DEV={};GW=`echo '${IP%.*}.1'`;ip r r default via \${GW} dev \${DEV}; ip r\""
vars:
IP: "{{ ansible_facts['env'].SSH_CONNECTION.split(' ')[2] }}"
register: output
- name: debug
debug:
msg: "{{ output }}"
Created
December 17, 2023 14:00
-
-
Save inceabdullah/3ac7632b7ccecdd28c725ec4e7070c7f to your computer and use it in GitHub Desktop.
Ansible Set Default Route with Connecting IPv4
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment