Created
June 14, 2013 15:12
-
-
Save chadoh/5782635 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| # Run this with ansible-playbook and supply the private key for your EC2/Euca | |
| # user (to access the instance in the second play), e.g: | |
| # ansible-playbook eucalyptus-ec2-deploy.yml -v --private-key=/path/to/ec2/pri/key | |
| - name: Set up a new ubuntu instance and register it in your ansible inventory file | |
| hosts: local | |
| connection: local | |
| user: root | |
| gather_facts: false | |
| vars: | |
| keypair: pd-app-server | |
| instance_type: c1.medium | |
| security_group: default | |
| image: ami-d0f89fb9 # default ubuntu, provided by the aws wizard | |
| tasks: | |
| # Launch 1 instances with the following parameters. Register the output. | |
| - name: Launch instance | |
| local_action: ec2 key_name={{ keypair }} group={{ security_group }} | |
| instance_type={{ instance_type }} image={{ image }} | |
| instance_tags='{"Name":"{{ instance_name }}", "role":"dev"}' | |
| wait=yes count=1 | |
| register: ec2 | |
| # Use with_items to add each instance's public IP to a new hostgroup for | |
| # use in the next play. | |
| - name: Add new instances to host group | |
| local_action: add_host hostname={{item.dns_name}} groups=dev | |
| ansible_ssh_user=ubuntu | |
| with_items: ${ec2.instances} | |
| # Use the ec2_vol module to create volumes for attachment to each instance. | |
| # Use with_items to attach to each instance (by returned id) launched | |
| # previously. | |
| #- name: Create a volume and attach | |
| #local_action: ec2_vol volume_size=10 instance={{item.id}} | |
| #with_items: ${ec2.instances} | |
| - name: provision the newly created instance | |
| hosts: dev | |
| vars: | |
| ruby: ree-1.8.7-2012.02 | |
| prince: prince_8.1-5_ubuntu12.04_amd64.deb | |
| phantomjs: phantomjs-1.9.0-linux-x86_64 | |
| tasks: | |
| - include: ../tasks/apt.yml | |
| - include: ../tasks/ruby.yml | |
| - include: ../tasks/shell_setup.yml | |
| - include: ../tasks/db.yml | |
| - include: ../tasks/prince.yml | |
| - include: ../tasks/phantomjs.yml |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output when running it: