你如何更改ansible_default_ipv4? [英] How do you change ansible_default_ipv4?
问题描述
我想将 ansible_default_ipv4 更改为指向 eth1 而不是 eth0.我可以在剧本中或通过 --extra-vars 选项执行此操作吗?
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?
推荐答案
ansible 使用命令 ip -4 route get 8.8.8.8
来获取默认的 ipv4 接口.您可以更改您的 ip/路由表 使 eth1
成为默认路由,它会返回它.
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:使用set_fact
来覆盖ansible_default_ipv4
事实,但由于缓存、范围、...
PS: using set_fact
to override the ansible_default_ipv4
fact, but it has it's own pitfalls due to caching, scope, ...
这篇关于你如何更改ansible_default_ipv4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!