How do you change ansible_default_ipv4?

后端 未结 3 1839
时光说笑
时光说笑 2021-02-07 09:51

I\'d like to change ansible_default_ipv4 to point to eth1 instead of eth0. Can I do this in either the playbook or via the --extra-vars option?

3条回答
  •  被撕碎了的回忆
    2021-02-07 10:36

    ip -4 route get 8.8.8.8 was not working on my server.

    I created this work around.

    - name: find default ipv4... this is a bit of a hack. shell: ifconfig $(route | grep default | awk '{print $(NF)}') | grep 'inet' | awk '{ print $2}' register: ipv4_address

    Now I can use ipv4_address wherever needed!

提交回复
热议问题