ansible - Making a hosts file group into an input in Ansible playbook
问题描述
I have an ansible playbook that calls an API. I have a delegate_to: localhost
.
I want to run my playbook "against" every host in a group Linux
.
I want the API call to do 2 things.
I want it to run once for every host in the
Linux
groupFor every run, it should have a different host IP/hostname as the input
linux
looks like:
[linux]
10.234.0.13
10.234.0.12
I run my like this: ansible-playbook -i linux my_playbook
How do I make the inventory group an input?
解决方案
when ansible executes on the remote host it collects some meta data of the hosts. One of the meta data is ip address. The meta data is called ansible facts. There is an ansible fact to get the ip address
ansible_default_ipv4.address
推荐阅读
- python - Azure python sdk,如何部署一个 vm,它是一个 Azure Spot 实例
- react-native - 如何在本机反应中将参数与主体变量连接起来
- solr - SOLR:如何在 solr 查询中添加今天日期的记录
- javascript - 解决方案:管理 highchart 中组列之间的空间
- redirect - 我如何使用 GoDaddy 域进行重定向
- sql - Active Record 查询 YII2 中两个 id 之间的更新而不使用行查询
- ruby-on-rails - 如何从远程 oracle 数据库 Ruby on rails 获取数据
- spring - 如何覆盖spring框架bean?
- c# - 在 .Net Core 3.1 中使用 NetFwTypeLib 时出现内存泄漏
- eclipse-rcp - 产品定义没有从所需功能中提取依赖项