【问题标题】:how can i pass the parameter file in ansible cloud formation module如何在 ansible 云形成模块中传递参数文件
【发布时间】:2020-01-07 13:54:46
【问题描述】:

我在 ansible 中使用 cloudformation 模块,但在传递参数文件时遇到问题。

致命:[本地主机]:失败! => {“改变”:假,“味精”:“不支持 (cloudformation) 模块的参数:dist 支持的参数 包括:aws_access_key、aws_secret_key、backoff_delay、 backoff_max_delay,backoff_retries,功能,changeset_name, create_changeset、create_timeout、debug_botocore_endpoint_logs、 disable_rollback、ec2_url、events_limit、notification_arns、profile、 区域,role_arn,security_token,stack_name,stack_policy,状态, 标签,模板,模板主体,模板格式,模板参数, template_url、termination_protection、validate_certs"}

我已经使用了没有dist属性的template_parameters,如下图,

#template_parameters: "{{ lookup('file', '/root/cloudformation_template/Parameter-tableau.json') | from_json }}"

但我遇到了同样的错误。该任务类似于以下任务,

- name: create a cloudformation stack
  cloudformation:
        stack_name: "ansible-cloudformation111"
        state: "present"
        template: "/root/cloudformation_template/poc-tableau.json"
        template_parameters:
        dist: "{{ lookup('file', '/root/cloudformation_template/Parameter-tableau.json')  }}"

【问题讨论】:

    标签: ansible ansible-facts


    【解决方案1】:

    有点难说是什么问题,因为你问题中的代码块没有格式化,而格式化在yaml和ansible中非常重要。但我有一个猜测。

    如果你的任务是这样的格式

    name: create a cloudformation stack
    cloudformation:
      stack_name: "ansible-cloudformation111"
      state: "present"
      template: "/root/cloudformation_template/poc-tableau.json"
      template_parameters:
      dist: "{{ lookup('file', '/root/cloudformation_template/Parameter-tableau.json') }}"
    

    然后您将收到错误消息Unsupported parameters for (cloudformation) module: dist,因为这里的distcloudformation 的参数,因为格式原因。将dist 行缩进两个空格应该可以解决问题:

    name: create a cloudformation stack
    cloudformation:
      stack_name: "ansible-cloudformation111"
      state: "present"
      template: "/root/cloudformation_template/poc-tableau.json"
      template_parameters:
        dist: "{{ lookup('file', '/root/cloudformation_template/Parameter-tableau.json') }}"
    

    【讨论】:

    • 嗨 steingberg,谢谢你的回答
    • -主机:本地主机成为:是任务:-名称:创建cloudformation堆栈cloudformation:stack_name:“ansible”状态:“present”模板:“/root/cloudformation_template/poc-tableau.json” template_parameters: dist: "{{ lookup('file', '/root/cloudformation_template/Parameter-tableau.json') | from_json }}"
    • 必须有值 - 。"}
    • 我正在尝试使用云形成模块在 ansible 中启动一个新实例我有两个文件一个是 cloudformation 模板文件和参数文件都在 json 文件中我无法在云形成模块请提出任何解决方案如何在ansible中传递参数文件
    • 嗨。听起来您最初发布的错误已通过在任务中使用正确的缩进修复,现在您收到一条新的错误消息。那是对的吗?如果是这样,我建议发布一个新问题。在那里,提供更多详细信息,包括两个 json 文件的内容、您正在运行的完整剧本以及您收到的完整错误。
    猜你喜欢
    • 1970-01-01
    • 2019-11-13
    • 2021-09-03
    • 1970-01-01
    • 2019-10-20
    • 1970-01-01
    • 1970-01-01
    • 2021-12-24
    • 2018-10-23
    相关资源
    最近更新 更多