---
# Connect DB and Webserver
# DB: setup appropriate access rights / grants
# Web: teach about DB host
#
# Assumes:
#   DB and Webservers setup and running, each in their security group
#
# Run:
#    env ANSIBLE_HOSTS=./ec2.py ansible-playbook config-ec2-connections.yml
#
# Copyright (c) 2013 Hubert Feyrer <hubert@feyrer.de>
#

 - hosts:
   - security_group_ec2-webservers
   - security_group_ec2-dbservers
   user: feyrer
   sudo: yes
   gather_facts: false

   tasks:
    - name: Collect EC2 host information
      action: ping

    - name: Prepare connection-script in /tmp/do-connect-vms.sh
      template: src=files/do-connections.sh.j2 dest=/tmp/do-connections.sh

    - name: Run connection-script
      command: sh -c 'sudo sh -x /tmp/do-connections.sh 2>&1 | tee /tmp/do-connections.log'

#   - name: Clean up
#     rm /tmp/do-connect-vms.sh
#     rm /tmp/do-connect-vms.log
#     rm /tmp/dump-names.sql
#     rm /tmp/ansible-1.0.tgz
