【问题标题】:ansible-inventory not working properly with ec2.py when using --profile使用 --profile 时,ansible-inventory 无法与 ec2.py 一起正常工作
【发布时间】:2020-06-10 09:45:26
【问题描述】:

我正在使用以下命令从 aws 导入库存,并且效果很好:

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

现在,我想使用特定的 aws 凭据,因此我将命令修改为如下:

/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】:

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

    /etc/ansible/inventory/ec2.py --list --profile my-profile 使用--profile 选项执行ec2.py,但是当使用-i 选项将相同的ec2.py 传递给ansible-inventory 时,文件本身将成为ansible-inventory 命令的参数。

    虽然自己没试过,可以尝试设置AWS_PROFILE,然后执行类似described here的命令。

    还可以查看ansible-inventory 的可用选项的文档。

    【讨论】:

      猜你喜欢
      • 2018-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-23
      • 1970-01-01
      • 2019-11-01
      • 2017-12-14
      • 2020-08-19
      相关资源
      最近更新 更多