【问题标题】:Ansible aws_ec2 inventory plugin - dynamic boto_profileAnsible aws_ec2 库存插件 - 动态 boto_profile
【发布时间】:2019-02-08 06:51:32
【问题描述】:

我正在使用 aws_ec2 库存插件,并希望在运行时将 boto_profile 作为 var 传递。

我正在尝试运行以下命令:

ansible-playbook playbook.yml --extra-vars profile=foo

在我的aws_ec2.yml 插件文件中,我有:

boto_profile: "{{ profile }}"

这会返回错误:

The config profile ({{ profile }}) could not be found

我可以在我的剧本中使用profile var。我正在使用带有profile: "{{ profile }}"ec2 模块,如果我定义一个静态库存,这似乎可以工作。

是否可以将profile var 传递到动态库存文件中?

【问题讨论】:

    标签: amazon-ec2 ansible


    【解决方案1】:

    Jinja2 模板不适用于清单配置文件。

    使用环境变量AWS_PROFILEAWS_DEFAULT_PROFILE 在运行时设置配置文件。

    点赞:AWS_PROFILE=foo ansible-playbook playbook.yml

    【讨论】:

    • 无赖。我正在运行一个 docker 映像,我认为我不能在运行时设置 env var。
    • 配置文件中没有模板是否有原因?
    猜你喜欢
    • 1970-01-01
    • 2020-09-02
    • 2020-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-24
    相关资源
    最近更新 更多