From: Lorin Hochstein Date: Tue, 10 Feb 2015 00:14:05 +0000 (-0500) Subject: add instance role X-Git-Url: https://git.halfball.org/?a=commitdiff_plain;h=83e42e405b6f758aa5ed52c388413afbdb175024;p=ansiblebook.git add instance role --- diff --git a/ch12/playbooks/instance-role.yml b/ch12/playbooks/instance-role.yml new file mode 100644 index 0000000..0f8b4d3 --- /dev/null +++ b/ch12/playbooks/instance-role.yml @@ -0,0 +1,28 @@ +--- +- name: launch instance role + hosts: localhost + gather_facts: False + vars: + region: us-west-1 + instance_type: t2.micro + tasks: + - name: Get the ubuntu trusty AMI + ec2_ami_search: distro=ubuntu release=trusty virt=hvm region={{ region }} + register: ubuntu_image + - name: start the instance + ec2: + region: "{{ region }}" + image: "{{ ubuntu_image.ami }}" + instance_type: "{{ instance_type }}" + key_name: mykey + group: [ssh, outbound] + instance_tags: { Name: instance-role, type: ansible } + exact_count: 1 + count_tag: { type: ansible } + instance_profile_name: ansible + wait: yes + register: ec2 + - name: wait for ssh server to be running + wait_for: host={{ item.public_dns_name }} port=22 search_regex=OpenSSH + with_items: ec2.tagged_instances + when: item.public_dns_name is defined