播放时出现以下错误:Terminate instances
正在运行:
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Either region or ec2_url must be specified"}
这是我的剧本:
- hosts: localhost
connection: local
remote_user: test
gather_facts: no
vars_files:
- files/aws_creds.yml
- files/info.yml
tasks:
- name: Basic provisioning of EC2 instance
ec2:
assign_public_ip: no
aws_access_key: "{{ aws_id }}"
aws_secret_key: "{{ aws_key }}"
region: "{{ aws_region }}"
image: "{{ standard_ami }}"
instance_type: "{{ free_instance }}"
key_name: "{{ ssh_keyname }}"
count: 3
state: present
group_id: "{{ secgroup_id }}"
wait: no
#delete_on_termination: yes
instance_tags:
Name: Dawny33Template
register: ec2
- name: Add new instance to host group
add_host:
hostname: "{{ item.public_ip }}"
groupname: launched
with_items: "{{ ec2.instances }}"
## Here lies the SSH code
- name: Wait for SSH to come up
wait_for:
host: "{{ item.public_ip }}"
port: 22
delay: 60
timeout: 320
state: started
with_items: "{{ ec2.instances }}"
- name: Configure instance(s)
hosts: launched
become: True
gather_facts: True
#roles:
# - my_awesome_role
# - my_awesome_test
tasks:
- name: install git
yum: name=git state=present
- name: check out a git repository
git: repo={{ repo_url }} dest=/Dest/To/Repo/ accept_hostkey=yes
vars:
repo_url: https://github.com/lorin/mezzanine-example.git
- name: Terminate instances
hosts: localhost
connection: local
tasks:
- name: Terminate instances that were previously launched
ec2:
state: 'absent'
instance_ids: '{{ ec2.instance_ids }}'
错误的真正含义是什么?而且,我该如何解决?
答案 0 :(得分:1)
你以非常高的速度解决问题......花一些时间了解正在发生的事情是很好的。
我看到你在启动实例时第一次播放时包含aws_creds.yml
,并且在上一次播放中没有定义任何vars文件......