From a8ff82859380d741c83015cdb4ef664f4d16be8e Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Wed, 2 Oct 2013 20:58:10 -0400 Subject: [PATCH] Minor AWS doc cleanup --- docsite/latest/rst/guide_aws.rst | 61 ++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/docsite/latest/rst/guide_aws.rst b/docsite/latest/rst/guide_aws.rst index a6a6ff2ebe..7e04188bff 100644 --- a/docsite/latest/rst/guide_aws.rst +++ b/docsite/latest/rst/guide_aws.rst @@ -7,7 +7,12 @@ Amazon Web Services Guide Introduction ```````````` -Ansible contains a number of core modules for interacting with Amazon Web Services (AWS) and other API compatible private clouds, such as Eucalyptus. (There are other supported cloud systems, but this documentation is about AWS ones). This page illustrates some use cases for provisioning and managing hosts EC2 resources. +.. note:: This section of the documentation is under construction. We are in the process of adding more examples about all of the EC2 modules + and how they work together. There's also an ec2 example in the language_features directory of the 'ansible-examples' github repository + that you may wish to consult. Once complete, there will also be new examples of ec2 in ansible-examples. + +Ansible contains a number of core modules for interacting with Amazon Web Services (AWS). These also work with Eucalyptus, which is an AWS compatible private cloud solution. There are other supported cloud types, but this documentation chapter is about AWS API clouds. The purpose of this +section is to explain how to put Ansible modules together (and use inventory scripts) to use Ansible in AWS context. Requirements for the AWS modules are minimal. All of the modules require and are tested against boto 2.5 or higher. You'll need this Python module installed on the execution host. If you are using Red Hat Enterprise Linux or CentOS, install boto from `EPEL `_: @@ -15,10 +20,12 @@ Requirements for the AWS modules are minimal. All of the modules require and ar $ yum install python-boto +You can also install it via pip if you want. + Provisioning ```````````` -The ec2 module provides the ability to provision instance(s) within EC2. Typically the provisioning task will be performed against your Ansible master server as a local_action. +The ec2 module provides the ability to provision instances within EC2. Typically the provisioning task will be performed against your Ansible master server as a local_action statement. .. note:: @@ -33,27 +40,33 @@ The ec2 module provides the ability to provision instance(s) within EC2. Typica exporting the variable as EC2_URL=https://myhost:8773/services/Eucalyptus. This can be set using the 'environment' keyword in Ansible if you like. -Provisioning a number of instances in ad-hoc mode mode: +Here is an example of provisioning a number of instances in ad-hoc mode mode: .. code-block:: bash - # ansible localhost -m ec2 -a "image=ami-6e649707 instance_type=m1.large keypair=mykey group=webservers wait=yes" + # ansible localhost -m ec2 -a "image=ami-6e649707 instance_type=m1.large keypair=mykey group=webservers wait=yes" -c local In a play, this might look like (assuming the parameters are held as vars):: tasks: - name: Provision a set of instances - local_action: ec2 keypair={{mykeypair}} group={{security_group}} instance_type={{instance_type}} image={{image}} wait=true count={{number}} + local_action: ec2 + keypair={{mykeypair}} + group={{security_group}} + instance_type={{instance_type}} + image={{image}} + wait=true + count={{number}} register: ec2 - -By registering the return its then possible to dynamically create a host group consisting of these new instances. This facilitates performing configuration actions on the hosts immediately in a subsequent play:: - tasks: + +By registering the return its then possible to dynamically create a host group consisting of these new instances. This facilitates performing configuration actions on the hosts immediately in a subsequent task:: + - name: Add all instance public IPs to host group local_action: add_host hostname={{ item.public_ip }} groupname=ec2hosts with_items: ec2.instances -With the host group now created, the second play in your provision playbook might now have some configuration steps:: +With the host group now created, a second play in your provision playbook might now have some configuration steps:: - name: Configuration play hosts: ec2hosts @@ -64,6 +77,8 @@ With the host group now created, the second play in your provision playbook migh - name: Check NTP service action: service name=ntpd state=started +Rather than include configuration inline, you may also choose to just do it as a task include or a role. + The method above ties the configuration of a host with the provisioning step. This isn't always ideal and leads us onto the next section. Advanced Usage @@ -93,6 +108,16 @@ More information on pull-mode playbooks can be found `here