ansible ec2运行列表需要是实例列表

Sim*_*eth 2 amazon-ec2 ansible ansible-playbook

我正在尝试使用ansible部署ec2实例.

我一直收到错误消息:

FAILED! => {"msg": "running list needs to be a list of instances to run: None",
Run Code Online (Sandbox Code Playgroud)

site.yml

---
- hosts: hornet
  user: root
  sudo: false
  gather_facts: False
  serial: 1
  roles:
    -  role: ec2
Run Code Online (Sandbox Code Playgroud)

角色/ EC2 /任务/ main.yml

---
- include_vars: "env.yml"
- name: create an EC2 instance
  local_action:
    module: ec2
    key_name: "{{ key_name }}"
    region: "{{ region }}"
    instance_type: "{{ instance_type }}"
    image: "{{ image }}"
    group_id: "{{ security_group }}"
    wait: yes
    private_ip: "{{ privip }}"
    assign_public_ip: True
    state: running
    instance_tags: { "{{ ectags }}","name: {{ inventory_hostname }}"}
    count: 1
    register: basic_ec2
Run Code Online (Sandbox Code Playgroud)

我在hosts文件中有两个主机.

[hornet]
awo-p01-hm02 privip=`UniqueIP` ectags="{purpose:hornetMQ}"
awo-p01-hm03 privip=`UniqueIP` ectags="{purpose:hornetMQ}"
Run Code Online (Sandbox Code Playgroud)

nit*_*one 6

我怀疑你真的想要state: present.state: running用于启动现有实例(您传递的实例instance_ids: [ ... ]).

我知道,令人难以置信的混乱和记录不完整.ec2模块尝试做太多事情.:(