2012-06-24 03:53:16 +00:00
========================
OS Support for Cloud VMS
========================
Salt cloud works primarily by executing a script on the virtual machines as
soon as they become available. The script that is executed is referenced in
2012-11-20 21:41:17 +00:00
the cloud profile as the `` script `` .
2012-06-24 03:53:16 +00:00
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
.. code-block :: bash
#!/bin/bash
# Install the salt-minion package from yum. This is easy for Fedora because
# Salt packages are in the Fedora package repos
yum install -y salt-minion
# Save in the minion public and private RSA keys before the minion is started
mkdir -p /etc/salt/pki
echo '{{ vm['priv_key'] }}' > /etc/salt/pki/minion.pem
echo '{{ vm['pub_key'] }}' > /etc/salt/pki/minion.pub
# Copy the minion configuration file into place before starting the minion
echo '{{ minion }}' > /etc/salt/minion
# Set the minion to start on reboot
systemctl enable salt-minion.service
# Start the minion!
systemctl start salt-minion.service
2012-11-20 21:41:17 +00:00
Post-Deploy Commands
====================
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, test.ping. This is configured in the main cloud config file:
.. clode-block :: yaml
start_action: state.highstate
Skipping the Deploy Script
==========================
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. This can be set from the command line:
.. code-block :: bash
salt-cloud --no-deploy -p micro_aws my_instance
Or it can be set from the main cloud config file:
.. clode-block :: yaml
deploy: False
The default for deploy is True.