当使用--profile时,ansible-inventory在ec2.py中不能正常工作。

问题描述 投票:0回答:1

我使用follaboring命令从aws导入库存,效果很好。

ansible-inventory -i /etc/ansible/inventory/ec2.py --list -y > $some_dic

现在,我想使用特定的aws证书 所以我把命令修改为follwoing:

/etc/ansible/inventory/ec2.py --list --profile my-profile

这样就能正常工作了。

然而,当我把所有的东西都放在一起时,却无法正常工作

ansible-inventory -i /etc/ansible/inventory/ec2.py --list --profile my-profile -y > $some_dic

错误。

ansible-inventory: error: unrecognized arguments: --profile

任何关于这个问题的想法?

amazon-web-services amazon-ec2 ansible ansible-inventory
1个回答
1
投票

ansible-inventory 命令试图解析所有的选项,包括 --profile 它没有的。

/etc/ansible/inventory/ec2.py --list --profile my-profile 执行 ec2.py--profile 选项,但当同一 ec2.py 传给 ansible-inventory 使用 -i 选项,该文件本身成为 ansible-inventory 命令。

虽然,我自己还没试过,但你可以尝试设置为 AWS_PROFILE 然后执行类似于 此处.

也可以看一下文档中的可用选项。ansible-inventory.

© www.soinside.com 2019 - 2024. All rights reserved.