Created
June 7, 2013 16:09
-
-
Save chadoh/5730413 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
| --- | |
| # This playbook is an example for deploying multiple instances into EC2/Euca and "doing something" with them. | |
| # - uses the ec2 and ec2_vol module. | |
| # | |
| # 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=true 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.public_ip}} groupname=dev | |
| 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}} | |
| #ec2_access_key={{access_key}} ec2_secret_key={{secret_key}} | |
| #with_items: ${ec2.instances} |
Author
Author
/etc/ansible/hosts looks like this:
[local]
localhost ansible_connection=local
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
running this with
ansible-playbook ansible/playbooks/launch_ubuntu_instance.yml -v --private-key=/Users/chadoh/.ssh/pd-app-server --extra-vars="instance_name=chad-testing-ansible"gives this error: