2012-06-24 03:18:05 +00:00
|
|
|
==============
|
|
|
|
Cloud Map File
|
|
|
|
==============
|
|
|
|
|
|
|
|
A number of options exist when creating virtual machines. They can be managed
|
|
|
|
directly from profiles and the command line execution, or a more complex map
|
2012-08-01 15:41:52 +00:00
|
|
|
file can be created. The map file allows for a number of virtual machines to
|
2012-06-24 03:18:05 +00:00
|
|
|
be created and associated with specific profiles.
|
|
|
|
|
|
|
|
Map files have a simple format, specify a profile and then a list of virtual
|
|
|
|
machines to make from said profile:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
2012-08-01 15:41:52 +00:00
|
|
|
fedora_small:
|
2013-11-22 21:33:09 +00:00
|
|
|
- web1
|
|
|
|
- web2
|
|
|
|
- web3
|
2012-06-24 03:18:05 +00:00
|
|
|
fedora_high:
|
2013-11-22 21:33:09 +00:00
|
|
|
- redis1
|
|
|
|
- redis2
|
|
|
|
- redis3
|
2012-06-24 03:18:05 +00:00
|
|
|
cent_high:
|
2013-11-22 21:33:09 +00:00
|
|
|
- riak1
|
|
|
|
- riak2
|
|
|
|
- riak3
|
2012-06-24 03:18:05 +00:00
|
|
|
|
|
|
|
This map file can then be called to roll out all of these virtual machines. Map
|
|
|
|
files are called from the salt-cloud command with the -m option:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
$ salt-cloud -m /path/to/mapfile
|
|
|
|
|
|
|
|
Remember, that as with direct profile provisioning the -P option can be passed
|
|
|
|
to create the virtual machines in parallel:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
$ salt-cloud -m /path/to/mapfile -P
|
2012-08-01 15:41:52 +00:00
|
|
|
|
2015-06-18 20:25:20 +00:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
Due to limitations in the GoGrid API, instances cannot be provisioned in parallel
|
|
|
|
with the GoGrid driver. Map files will work with GoGrid, but the ``-P``
|
|
|
|
argument should not be used on maps referencing GoGrid instances.
|
|
|
|
|
2012-08-01 15:41:52 +00:00
|
|
|
A map file can also be enforced to represent the total state of a cloud
|
|
|
|
deployment by using the ``--hard`` option. When using the hard option any vms
|
|
|
|
that exist but are not specified in the map file will be destroyed:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
$ salt-cloud -m /path/to/mapfile -P -H
|
2012-09-21 20:18:33 +00:00
|
|
|
|
2013-02-08 18:16:51 +00:00
|
|
|
Be careful with this argument, it is very dangerous! In fact, it is so
|
|
|
|
dangerous that in order to use it, you must explicitly enable it in the main
|
|
|
|
configuration file.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
enable_hard_maps: True
|
|
|
|
|
2013-03-14 01:21:00 +00:00
|
|
|
A map file can include grains and minion configuration options:
|
2012-09-21 20:18:33 +00:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
fedora_small:
|
2013-11-22 21:33:42 +00:00
|
|
|
- web1:
|
|
|
|
minion:
|
|
|
|
log_level: debug
|
|
|
|
grains:
|
|
|
|
cheese: tasty
|
|
|
|
omelet: du fromage
|
|
|
|
- web2:
|
|
|
|
minion:
|
|
|
|
log_level: warn
|
|
|
|
grains:
|
|
|
|
cheese: more tasty
|
|
|
|
omelet: with peppers
|
2012-09-21 20:18:33 +00:00
|
|
|
|
2012-10-12 17:58:59 +00:00
|
|
|
A map file may also be used with the various query options:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
$ salt-cloud -m /path/to/mapfile -Q
|
2013-11-22 17:56:57 +00:00
|
|
|
{'ec2': {'web1': {'id': 'i-e6aqfegb',
|
2012-10-12 17:58:59 +00:00
|
|
|
'image': None,
|
|
|
|
'private_ips': [],
|
|
|
|
'public_ips': [],
|
|
|
|
'size': None,
|
|
|
|
'state': 0}},
|
|
|
|
'web2': {'Absent'}}
|
|
|
|
|
|
|
|
...or with the delete option:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
$ salt-cloud -m /path/to/mapfile -d
|
|
|
|
The following virtual machines are set to be destroyed:
|
|
|
|
web1
|
|
|
|
web2
|
|
|
|
|
|
|
|
Proceed? [N/y]
|
|
|
|
|
2015-06-01 21:25:58 +00:00
|
|
|
.. warning:: Specifying Nodes with Maps on the Command Line
|
|
|
|
Specifying the name of a node or nodes with the maps options on the command
|
|
|
|
line is *not* supported. This is especially important to remember when
|
|
|
|
using ``--destroy`` with maps; ``salt-cloud`` will ignore any arguments
|
|
|
|
passed in which are not directly relevant to the map file. *When using
|
|
|
|
``--destroy`` with a map, every node in the map file will be deleted!*
|
|
|
|
Maps don't provide any useful information for destroying individual nodes,
|
|
|
|
and should not be used to destroy a subset of a map.
|
|
|
|
|
2014-02-14 23:53:55 +00:00
|
|
|
|
|
|
|
Setting up New Salt Masters
|
|
|
|
===========================
|
|
|
|
|
|
|
|
Bootstrapping a new master in the map is as simple as:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
fedora_small:
|
2014-06-06 01:34:13 +00:00
|
|
|
- web1:
|
|
|
|
make_master: True
|
2014-02-14 23:53:55 +00:00
|
|
|
- web2
|
|
|
|
- web3
|
|
|
|
|
2014-12-11 15:51:43 +00:00
|
|
|
Notice that **ALL** bootstrapped minions from the map will answer to the newly
|
2014-02-14 23:53:55 +00:00
|
|
|
created salt-master.
|
|
|
|
|
2014-12-11 15:51:43 +00:00
|
|
|
To make any of the bootstrapped minions answer to the bootstrapping salt-master
|
2014-02-15 10:23:07 +00:00
|
|
|
as opposed to the newly created salt-master, as an example:
|
2014-02-14 23:53:55 +00:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
fedora_small:
|
2014-06-06 01:34:13 +00:00
|
|
|
- web1:
|
|
|
|
make_master: True
|
|
|
|
minion:
|
|
|
|
master: <the local master ip address>
|
|
|
|
local_master: True
|
2014-02-14 23:53:55 +00:00
|
|
|
- web2
|
|
|
|
- web3
|
2014-02-15 00:03:46 +00:00
|
|
|
|
|
|
|
|
2014-12-11 15:51:43 +00:00
|
|
|
The above says the minion running on the newly created salt-master responds to
|
2014-02-15 00:03:46 +00:00
|
|
|
the local master, ie, the master used to bootstrap these VMs.
|
|
|
|
|
|
|
|
Another example:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
fedora_small:
|
2014-06-06 01:34:13 +00:00
|
|
|
- web1:
|
|
|
|
make_master: True
|
2014-02-15 00:03:46 +00:00
|
|
|
- web2
|
2014-06-06 01:34:13 +00:00
|
|
|
- web3:
|
|
|
|
minion:
|
|
|
|
master: <the local master ip address>
|
|
|
|
local_master: True
|
2014-02-15 00:03:46 +00:00
|
|
|
|
2014-12-11 15:51:43 +00:00
|
|
|
The above example makes the ``web3`` minion answer to the local master, not the
|
2015-06-01 21:25:58 +00:00
|
|
|
newly created master.
|