register: ec2
- name: add the instance to web and production groups
add_host: hostname={{ item.public_dns_name }} groups=web,production
- with_items: ec2.tagged_instances
+ with_items: "{{ ec2.tagged_instances }}"
when: item.public_dns_name is defined
- 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
+ with_items: "{{ ec2.tagged_instances }}"
when: item.public_dns_name is defined
- name: configure webservers
hosts: web:&production
become: True
+ gather_facts: False
+ vars:
+ ansible_python_interpreter: /usr/bin/python2.7
+ pre_tasks:
+ - name: install python
+ raw: apt-get install -y python2.7
roles:
- web