Hope you can get some inspiration from here: https://github.com/danvaida/Atlassian-Stash-Ansible/blob/master/ec2.yml
On Saturday, 10 January 2015 15:40:36 UTC+1, Dan Vaida wrote: > > On the run now but will share this later. > > Btw, are you really missing the task of allocating the EIPs to the > instances? This would go before the route53 task. > > Dan. > > On Jan 10, 2015, at 2:26 PM, Dan Vaida <[email protected]> wrote: > > I'm doing this by registering the results of the ec2 provisioning task and > then cycle through the hosts in a subsequent task for creating the dns > records. > > On Monday, 29 December 2014 17:09:03 UTC+1, Navid Paya wrote: >> >> Hi >> I'm trying to automate creating and destroying our staging environment. >> So far, I have a playbook to create the cluster: >> >> --- >> - name: Launch an EC2 instance from our our latest AMI in staging >> hosts: localhost >> connection: local >> gather_facts: no >> tasks: >> - name: Start the new EC2 instance >> ec2: >> image: ami-xxxxxxxx >> region: ap-southeast-1 >> zone: ap-southeast-1b >> instance_type: m3.medium >> vpc_subnet_id: subnet-xxxxxxxx >> group_id: ['sg-xxxxxxxx', 'sg-xxxxxxxx'] >> key_name: blahblah-deploy >> instance_tags: >> Cluster: grabqa01 >> Name: "{{ item}}.grabqa01.net" >> Env: staging >> Role: "{{ item }}" >> with_items: >> - redis >> - postgresql >> - frontend >> - dispatcher-athena >> - dispatcher-hermes >> - dispatcher-listener >> - dispatcher-processor >> - poi >> >> Now since EC2 instances take forever to initialize, I give it 20 minutes >> and then run another playbook to create DNS records for the created >> instances using Route53. I wanted to do this which would be so nice if it >> worked: >> >> - name: Set DNS Records >> hosts: 'tag_Cluster_grabqa01:&tag_Role_{{ item }}' >> tasks: >> - route53: >> aws_access_key: xxxxxxxxxxxxxxx >> aws_secret_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx >> command: create >> zone: grabqa01.net >> record: {{ item }}.grabqa01.net >> type: A >> ttl: 600 >> value: "{{ ansible_all_ipv4_addresses }}" >> delegate_to: localhost >> with_items: >> - redis >> - postgresql >> - frontend >> - dispatcher-athena >> - dispatcher-hermes >> - dispatcher-listener >> - dispatcher-processor >> - poi >> >> Basically, I want to find the hosts matching a search and then create a >> DNS record pointing at them. What would be the best way to do that? I'd >> rather not have to write a block for every single role I have. >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ansible Project" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/ansible-project/2QFD21LVCkw/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/6cb9be9e-41a0-47b7-9568-45d2794c7a06%40googlegroups.com > > <https://groups.google.com/d/msgid/ansible-project/6cb9be9e-41a0-47b7-9568-45d2794c7a06%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/24cf4a0d-007c-4feb-997e-5a6cbef6dcc5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
