How do you change ansible_default_ipv4?

后端 未结 3 1840
时光说笑
时光说笑 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:43

    ansible uses command ip -4 route get 8.8.8.8 to get the default ipv4 interface. You can change your ip/routing tables to make eth1 the default route and it'll return it.

    Or you can use a custom fact.

    PS: using set_fact to override the ansible_default_ipv4 fact, but it has it's own pitfalls due to caching, scope, ...

提交回复
热议问题