[英]Ansible dynamic inventory when connecting with AWS
I have downloaded ec2.py and ec2.ini files and placed them under 我已经下载了ec2.py和ec2.ini文件,并将它们放在
/etc/ansible/inventory
and i have changed the ansible.cfg to 我已经将ansible.cfg更改为
inventory = /etc/ansible/inventory/ec2.py
i have environment variables set up as 我将环境变量设置为
export AWS_ACCESS_KEY_ID="XXXXXXXXXXXXXXX"
export AWS_SECRET_ACCESS_KEY="XXXXXXXXXXXXXXXXXXXXX"
export AWS_DEFAULT_REGION="us-east-1"
export EC2_INI_PATH="/etc/ansible/inventory/ec2.ini"
now when i run ansible -m ping all i am getting 现在当我运行ansible -m ping我得到的一切
[WARNING]: provided hosts list is empty, only localhost is available
instead of pinging all instances in my account 而不是ping我帐户中的所有实例
when i run ./ec2.py --list i get 当我运行./ec2.py --list我得到
{
"_meta": {
"hostvars": {}
}
}
all my instances in aws are running 我在AWS中的所有实例都在运行
It seems you are not using the right inventory file. 似乎您使用的库存文件不正确。
Run ansible with -v option to check what config file it is really using 使用-v选项运行ansible以检查其实际使用的配置文件
ansible -v -m ping all
Check if you have ANSIBLE_INVENTORY or ANSIBLE_HOSTS environment variables overriding expected config file. 检查是否有ANSIBLE_INVENTORY或ANSIBLE_HOSTS环境变量覆盖预期的配置文件。 You can override inventory definition by setting 您可以通过设置覆盖广告资源定义
export ANSIBLE_INVENTORY=/etc/ansible/inventory/ec2.py
Remind that configuration files are processed in the following order 提醒配置文件按以下顺序处理
Prior to 1.5 the order was: 在1.5之前的订单是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.