2012-07-13 07:53:14 +00:00
|
|
|
========================
|
2012-08-02 03:37:52 +00:00
|
|
|
Getting Started With AWS
|
2012-07-13 07:53:14 +00:00
|
|
|
========================
|
|
|
|
|
2012-08-02 03:37:52 +00:00
|
|
|
Amazon AWS is a very widely used public cloud platform and one of the core
|
2012-07-13 07:53:14 +00:00
|
|
|
platforms Salt Cloud has been built to support.
|
|
|
|
|
|
|
|
Set up the cloud config at ``/etc/salt/cloud``:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Set up the location of the salt master
|
|
|
|
minion:
|
|
|
|
master: saltmaster.example.com
|
|
|
|
|
2012-08-02 03:37:52 +00:00
|
|
|
# Set the AWS login data
|
|
|
|
AWS.id: HJGRYCILJLKJYG
|
|
|
|
AWS.key: 'kdjgfsgm;woormgl/aserigjksjdhasdfgn'
|
|
|
|
AWS.keyname: test
|
|
|
|
AWS.securitygroup: quick-start
|
|
|
|
AWS.private_key: /root/test.pem
|
2012-07-13 07:53:14 +00:00
|
|
|
|
|
|
|
# Set up an optional default cloud provider
|
2012-08-02 03:37:52 +00:00
|
|
|
provider: AWS
|
2012-07-13 07:53:14 +00:00
|
|
|
|
2012-09-21 17:13:10 +00:00
|
|
|
# Optionally configure default region
|
|
|
|
AWS.location: ap-southeast-1
|
|
|
|
AWS.availability_zone: ap-southeast-1b
|
|
|
|
|
|
|
|
# Specify whether to use public or private IP for deploy script
|
2012-10-12 17:58:50 +00:00
|
|
|
AWS.ssh_interface: public
|
2012-09-21 17:13:10 +00:00
|
|
|
|
|
|
|
# Configure which user to use to run the deploy script
|
2012-10-12 17:58:50 +00:00
|
|
|
AWS.ssh_username: ec2-user
|
2012-09-21 17:13:10 +00:00
|
|
|
|
2012-07-13 07:53:14 +00:00
|
|
|
Set up an initial profile at ``/etc/salt/cloud.profiles``:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
2012-08-02 03:37:52 +00:00
|
|
|
base_aws:
|
|
|
|
provider: aws
|
2012-07-13 07:53:14 +00:00
|
|
|
image: ami-e565ba8c
|
|
|
|
size: Micro Instance
|
|
|
|
os: RHEL6
|
|
|
|
|
|
|
|
The profile can be realized now with a salt command:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
2012-08-02 03:37:52 +00:00
|
|
|
# salt-cloud -p base_aws ami.example.com
|
2012-07-13 07:53:14 +00:00
|
|
|
|
|
|
|
The created virtual machine will be named ``ami.example.com`` in the amazon
|
|
|
|
cloud and will have the same salt ``id``.
|
|
|
|
|
|
|
|
Once the vm is created it will start up the Salt Minion and connect back to
|
|
|
|
the Salt Master.
|
2012-10-12 17:58:50 +00:00
|
|
|
|
|
|
|
Required Settings
|
|
|
|
=================
|
|
|
|
|
|
|
|
AWS has several options that are always required:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Set the AWS login data
|
|
|
|
AWS.id: HJGRYCILJLKJYG
|
|
|
|
AWS.key: 'kdjgfsgm;woormgl/aserigjksjdhasdfgn'
|
|
|
|
AWS.keyname: test
|
|
|
|
AWS.securitygroup: quick-start
|
|
|
|
AWS.private_key: /root/test.pem
|
|
|
|
|
|
|
|
Optional Settings
|
|
|
|
=================
|
|
|
|
|
|
|
|
AWS allows a location to be set for servers to be deployed in. Availability
|
|
|
|
zones exist inside regions, and may be added to increase specificity.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Optionally configure default region
|
|
|
|
AWS.location: ap-southeast-1
|
|
|
|
AWS.availability_zone: ap-southeast-1b
|
|
|
|
|
|
|
|
AWS instances can have a public or private IP, or both. When an instance is
|
|
|
|
deployed, Salt Cloud needs to log into it via SSH to run the deploy script.
|
|
|
|
By default, the public IP will be used for this. If the salt-cloud command
|
|
|
|
is run from another AWS instance, the private IP should be used.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Specify whether to use public or private IP for deploy script
|
|
|
|
AWS.ssh_interface: public
|
|
|
|
|
|
|
|
AWS instances may not allow remote access to the root user by default. Instead,
|
|
|
|
another user must be used to run the deploy script using sudo. Some common
|
|
|
|
usernames include ec2-user (for Amazon Linux), ubuntu (for Ubuntu instances)
|
|
|
|
and bitnami (for images provided by Bitnami).
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Configure which user to use to run the deploy script
|
|
|
|
AWS.ssh_username: ec2-user
|
|
|
|
|
|
|
|
Multiple usernames can be provided, in which case Salt Cloud will attempt to
|
|
|
|
guess the correct username. This is mostly useful in the main configuration
|
|
|
|
file:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
AWS.ssh_username:
|
|
|
|
- ec2-user
|
|
|
|
- ubuntu
|
|
|
|
- bitnami
|
|
|
|
|
|
|
|
Multiple security groups can also be specified in the same fashion:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
AWS.securitygroup:
|
|
|
|
- default
|
|
|
|
- extra
|
|
|
|
|