【问题标题】:resize type of ec2 with ansible用 ansible 调整 ec2 的类型
【发布时间】:2018-09-05 12:59:12
【问题描述】:

我想从 ansible 调整一个 ec2 类型的大小。

这是我的代码:

- name: resize the instance
  ec2: 
    aws_access_key: "{{ aws_access_key_var }}"
    aws_secret_key: "{{ aws_secret_key_var }}"
    region: "{{ region }}"
    instance_ids:
      - "{{ instance_id }}"
    instance_type: "{\"Value\": \"t2.small\"}"
    wait: True
  register: ec2_result_file

但我收到此错误:

fatal: [localhost]: FAILED! => {"changed": false, "msg": "image parameter is required for new instance"}

我尝试使用命令行都很好

aws  ec2 modify-instance-attribute --region reg  --instance-id i-xx  --instance-type "{\"Value\": \"t2.small\"}

问候,

【问题讨论】:

    标签: amazon-ec2 ansible


    【解决方案1】:

    如何得出解决方案:

    1. Ansible 告诉您它想要创建“一个新实例”,但您已经提供了一个现有的实例 ID。

    2. 转到ec2 module 的文档并检查您提供当前实例 ID 的参数:

      instance_ids 实例 ID 列表,当前用于状态:absentrunningstopped

    3. 检查您指定的state - 您没有指定,所以它是默认值。

    4. 检查相同的文档 state 参数的默认值是什么:它是 present

      present 未列在instance_ids 描述中,因此instance_ids 被完全忽略。

    Ansible 认为您真的想创建一个新实例。


    解决方案:

    state: running 添加到ec2 模块参数中。

    【讨论】:

    • 抱歉,打错了。
    • 再次感谢 :) 我尝试运行,停止但没有任何改变,只是它启动机器或停止机器再次感谢:) :P
    猜你喜欢
    • 1970-01-01
    • 2020-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-26
    • 2018-01-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多