2012-06-24 03:53:16 +00:00
|
|
|
========================
|
2013-01-21 19:34:57 +00:00
|
|
|
OS Support for Cloud VMs
|
2012-06-24 03:53:16 +00:00
|
|
|
========================
|
|
|
|
|
2013-01-21 19:34:57 +00:00
|
|
|
Salt Cloud works primarily by executing a script on the virtual machines as
|
2013-03-07 21:14:23 +00:00
|
|
|
soon as they become available. The script that is executed is referenced in the
|
|
|
|
cloud profile as the ``script``. In older versions, this was the ``os``
|
2013-01-21 19:34:57 +00:00
|
|
|
argument. This was changed in 0.8.2.
|
2012-06-24 03:53:16 +00:00
|
|
|
|
2013-01-21 19:34:57 +00:00
|
|
|
A number of legacy scripts exist in the deploy directory in the saltcloud
|
|
|
|
source tree. The preferred method is currently to use the salt-bootstrap
|
|
|
|
script. A stable version is included with each release tarball starting with
|
|
|
|
0.8.4. The most updated version can be found at:
|
|
|
|
|
|
|
|
https://github.com/saltstack/salt-bootstrap
|
|
|
|
|
|
|
|
If you do not specify a script argument, this script will be used at the
|
|
|
|
default.
|
|
|
|
|
|
|
|
If the Salt Bootstrap script does not meet your needs, you may write your own.
|
2012-10-09 03:07:59 +00:00
|
|
|
The script should be written in bash and is a Jinja template. Deploy scripts
|
2012-07-14 12:38:51 +00:00
|
|
|
need to execute a number of functions to do a complete salt setup. These
|
2012-06-24 03:53:16 +00:00
|
|
|
functions include:
|
|
|
|
|
2012-07-14 12:38:51 +00:00
|
|
|
1. Install the salt minion. If this can be done via system packages this method
|
2012-06-24 03:53:16 +00:00
|
|
|
is HIGHLY preferred.
|
|
|
|
2. Add the salt minion keys before the minion is started for the first time.
|
|
|
|
The minion keys are available as strings that can be copied into place in
|
2012-07-14 12:38:51 +00:00
|
|
|
the Jinja template under the dict named "vm".
|
2012-06-24 03:53:16 +00:00
|
|
|
3. Start the salt-minion daemon and enable it at startup time.
|
|
|
|
4. Set up the minion configuration file from the "minion" data available in
|
|
|
|
the Jinja template.
|
|
|
|
|
|
|
|
A good, well commented, example of this process is the Fedora deployment
|
|
|
|
script:
|
|
|
|
|
|
|
|
https://github.com/saltstack/salt-cloud/blob/master/saltcloud/deploy/Fedora.sh
|
2012-08-01 15:29:15 +00:00
|
|
|
|
2013-01-21 19:34:57 +00:00
|
|
|
A number of legacy deploy scripts are included with the release tarball. None
|
|
|
|
of them are as functional or complete as Salt Bootstrap, and are still included
|
|
|
|
for academic purposes.
|
2012-08-01 15:29:15 +00:00
|
|
|
|
|
|
|
|
2013-01-21 19:34:57 +00:00
|
|
|
Other Generic Deploy Scripts
|
|
|
|
============================
|
|
|
|
If you want to be assured of always using the latest Salt Bootstrap script,
|
|
|
|
there are a few generic templates available in the deploy directory of your
|
|
|
|
saltcloud source tree:
|
|
|
|
|
2013-06-21 00:58:36 +00:00
|
|
|
.. code-block:: bash
|
2013-01-21 19:34:57 +00:00
|
|
|
|
|
|
|
curl-bootstrap
|
|
|
|
curl-bootstrap-git
|
|
|
|
python-bootstrap
|
|
|
|
wget-bootstrap
|
|
|
|
wget-bootstrap-git
|
2012-08-01 15:29:15 +00:00
|
|
|
|
2013-03-05 15:57:16 +00:00
|
|
|
|
2013-01-21 19:34:57 +00:00
|
|
|
These are example scripts which were designed to be customized, adapted, and
|
|
|
|
refit to meet your needs. One important use of them is to pass options to
|
|
|
|
the salt-bootstrap script, such as updating to specific git tags.
|
2012-08-01 15:29:15 +00:00
|
|
|
|
2012-11-20 21:41:17 +00:00
|
|
|
|
|
|
|
Post-Deploy Commands
|
|
|
|
====================
|
|
|
|
|
2014-12-11 15:51:43 +00:00
|
|
|
Once a minion has been deployed, it has the option to run a salt command.
|
|
|
|
Normally, this would be the state.highstate command, which would finish
|
|
|
|
provisioning the VM. Another common option is state.sls, or for just testing,
|
2013-03-05 15:57:16 +00:00
|
|
|
test.ping. This is configured in the main cloud config file:
|
2012-11-20 21:41:17 +00:00
|
|
|
|
2012-12-10 19:30:33 +00:00
|
|
|
.. code-block:: yaml
|
2012-11-20 21:41:17 +00:00
|
|
|
|
|
|
|
start_action: state.highstate
|
|
|
|
|
2013-03-05 15:57:16 +00:00
|
|
|
|
2014-12-11 15:51:43 +00:00
|
|
|
This is currently considered to be experimental functionality, and may not work
|
|
|
|
well with all providers. If you experience problems with Salt Cloud hanging
|
2013-03-05 15:57:16 +00:00
|
|
|
after Salt is deployed, consider using Startup States instead:
|
2012-12-10 18:45:27 +00:00
|
|
|
|
2014-02-20 23:16:59 +00:00
|
|
|
http://docs.saltstack.com/ref/states/startup.html
|
2012-12-10 18:45:27 +00:00
|
|
|
|
|
|
|
|
2012-11-20 21:41:17 +00:00
|
|
|
Skipping the Deploy Script
|
|
|
|
==========================
|
|
|
|
|
2014-12-11 15:51:43 +00:00
|
|
|
For whatever reason, you may want to skip the deploy script altogether. This
|
|
|
|
results in a VM being spun up much faster, with absolutely no configuration.
|
2013-03-05 15:57:16 +00:00
|
|
|
This can be set from the command line:
|
2012-11-20 21:41:17 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud --no-deploy -p micro_aws my_instance
|
|
|
|
|
2013-03-05 15:57:16 +00:00
|
|
|
|
2012-11-20 21:41:17 +00:00
|
|
|
Or it can be set from the main cloud config file:
|
|
|
|
|
2012-12-10 19:30:33 +00:00
|
|
|
.. code-block:: yaml
|
2012-11-20 21:41:17 +00:00
|
|
|
|
|
|
|
deploy: False
|
|
|
|
|
2013-03-05 15:57:16 +00:00
|
|
|
|
|
|
|
Or it can be set from the provider's configuration:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
RACKSPACE.user: example_user
|
|
|
|
RACKSPACE.apikey: 123984bjjas87034
|
|
|
|
RACKSPACE.deploy: False
|
|
|
|
|
|
|
|
|
|
|
|
Or even on the VM's profile settings:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
ubuntu_aws:
|
|
|
|
provider: aws
|
|
|
|
image: ami-7e2da54e
|
2014-09-27 17:09:08 +00:00
|
|
|
size: t1.micro
|
2013-03-05 15:57:16 +00:00
|
|
|
deploy: False
|
|
|
|
|
|
|
|
|
2012-11-20 21:41:17 +00:00
|
|
|
The default for deploy is True.
|
|
|
|
|
2013-03-05 15:57:16 +00:00
|
|
|
In the profile, you may also set the script option to ``None``:
|
2013-01-21 19:34:57 +00:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
script: None
|
|
|
|
|
2013-03-05 15:57:16 +00:00
|
|
|
|
2014-12-11 15:51:43 +00:00
|
|
|
This is the slowest option, since it still uploads the None deploy script and
|
2013-03-05 15:57:16 +00:00
|
|
|
executes it.
|
|
|
|
|
2013-01-21 19:34:57 +00:00
|
|
|
|
2013-02-14 22:09:38 +00:00
|
|
|
Updating Salt Bootstrap
|
|
|
|
=======================
|
|
|
|
Salt Bootstrap can be updated automatically with salt-cloud:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -u
|
|
|
|
salt-cloud --update-bootstrap
|
|
|
|
|
2013-03-05 15:57:16 +00:00
|
|
|
|
2013-02-14 22:09:38 +00:00
|
|
|
Bear in mind that this updates to the latest (unstable) version, so use with
|
|
|
|
caution.
|
|
|
|
|
2013-03-07 21:14:23 +00:00
|
|
|
|
2013-02-14 22:09:38 +00:00
|
|
|
Keeping /tmp/ Files
|
|
|
|
===================
|
|
|
|
When Salt Cloud deploys an instance, it uploads temporary files to /tmp/ for
|
|
|
|
salt-bootstrap to put in place. After the script has run, they are deleted. To
|
|
|
|
keep these files around (mostly for debugging purposes), the --keep-tmp option
|
|
|
|
can be added:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -p myprofile mymachine --keep-tmp
|
|
|
|
|
2013-03-05 15:57:16 +00:00
|
|
|
|
2013-02-14 22:09:38 +00:00
|
|
|
For those wondering why /tmp/ was used instead of /root/, this had to be done
|
|
|
|
for images which require the use of sudo, and therefore do not allow remote
|
|
|
|
root logins, even for file transfers (which makes /root/ unavailable).
|
|
|
|
|
2013-03-05 15:57:16 +00:00
|
|
|
|
2013-02-14 22:09:38 +00:00
|
|
|
Deploy Script Arguments
|
|
|
|
=======================
|
|
|
|
Custom deploy scripts are unlikely to need custom arguments to be passed to
|
|
|
|
them, but salt-bootstrap has been extended quite a bit, and this may be
|
2013-03-07 21:14:23 +00:00
|
|
|
necessary. script_args can be specified in either the profile or the map file,
|
|
|
|
to pass arguments to the deploy script:
|
2013-02-14 22:09:38 +00:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
aws-amazon:
|
|
|
|
provider: aws
|
|
|
|
image: ami-1624987f
|
2014-09-27 17:09:08 +00:00
|
|
|
size: t1.micro
|
2013-02-14 22:09:38 +00:00
|
|
|
ssh_username: ec2-user
|
|
|
|
script: bootstrap-salt
|
|
|
|
script_args: -c /tmp/
|
|
|
|
|
2013-03-05 15:57:16 +00:00
|
|
|
|
2013-02-14 22:09:38 +00:00
|
|
|
This has also been tested to work with pipes, if needed:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
2014-12-11 15:51:43 +00:00
|
|
|
script_args: | head
|