2014-03-24 16:10:13 +00:00
|
|
|
.. _config_lxc:
|
|
|
|
|
|
|
|
========================
|
2014-02-28 16:43:35 +00:00
|
|
|
Getting Started With LXC
|
2014-03-24 16:10:13 +00:00
|
|
|
========================
|
|
|
|
|
|
|
|
The LXC module is designed to install Salt in an LXC container on a controlled
|
|
|
|
and possibly remote minion.
|
2014-02-28 16:43:35 +00:00
|
|
|
|
2014-03-24 16:10:13 +00:00
|
|
|
In other words, Salt will connect to a minion, then from that minion:
|
2014-03-17 22:17:18 +00:00
|
|
|
|
2014-03-24 16:10:13 +00:00
|
|
|
- Provision and configure a container for networking access
|
2015-11-18 12:34:22 +00:00
|
|
|
- Use those modules to deploy salt and re-attach to master.
|
2015-05-22 16:06:04 +00:00
|
|
|
|
2015-11-18 12:34:22 +00:00
|
|
|
- :mod:`lxc runner <salt.runners.lxc>`
|
2015-05-22 16:06:04 +00:00
|
|
|
- :mod:`lxc module <salt.modules.lxc>`
|
2015-11-18 12:34:22 +00:00
|
|
|
- :mod:`seed <salt.modules.config>`
|
2014-02-28 16:43:35 +00:00
|
|
|
|
2014-04-24 22:16:53 +00:00
|
|
|
Limitations
|
2015-06-17 22:41:03 +00:00
|
|
|
-----------
|
2015-05-22 16:06:04 +00:00
|
|
|
|
2014-02-28 16:43:35 +00:00
|
|
|
- You can only act on one minion and one provider at a time.
|
2014-04-24 22:16:53 +00:00
|
|
|
- Listing images must be targeted to a particular LXC provider (nothing will be
|
2014-03-24 16:10:13 +00:00
|
|
|
outputted with ``all``)
|
2014-02-28 16:43:35 +00:00
|
|
|
|
|
|
|
Operation
|
|
|
|
---------
|
2015-05-22 16:06:04 +00:00
|
|
|
|
|
|
|
Salt's LXC support does use :mod:`lxc.init <salt.modules.lxc.init>`
|
|
|
|
via the :mod:`lxc.cloud_init_interface <salt.modules.lxc.cloud_init_interface>`
|
|
|
|
and seeds the minion via :mod:`seed.mkconfig <salt.modules.seed.mkconfig>`.
|
|
|
|
|
|
|
|
You can provide to those lxc VMs a profile and a network profile like if
|
|
|
|
you were directly using the minion module.
|
2014-02-28 16:43:35 +00:00
|
|
|
|
2014-03-17 22:17:18 +00:00
|
|
|
Order of operation:
|
2014-02-28 16:43:35 +00:00
|
|
|
|
2015-05-22 16:06:04 +00:00
|
|
|
- Create the LXC container on the desired minion (clone or template)
|
2014-04-24 22:16:53 +00:00
|
|
|
- Change LXC config options (if any need to be changed)
|
2014-03-17 22:17:18 +00:00
|
|
|
- Start container
|
|
|
|
- Change base passwords if any
|
2014-04-24 21:29:05 +00:00
|
|
|
- Change base DNS configuration if necessary
|
2014-03-24 16:10:13 +00:00
|
|
|
- Wait for LXC container to be up and ready for ssh
|
|
|
|
- Test SSH connection and bailout in error
|
2015-05-22 16:06:04 +00:00
|
|
|
- Upload deploy script and seeds, then re-attach the minion.
|
2014-02-28 16:43:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
Provider configuration
|
|
|
|
----------------------
|
|
|
|
|
2014-04-24 22:16:53 +00:00
|
|
|
Here is a simple provider configuration:
|
2014-03-17 22:17:18 +00:00
|
|
|
|
2014-02-28 16:43:35 +00:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
2014-04-24 22:16:53 +00:00
|
|
|
# Note: This example goes in /etc/salt/cloud.providers or any file in the
|
2014-02-28 16:43:35 +00:00
|
|
|
# /etc/salt/cloud.providers.d/ directory.
|
|
|
|
devhost10-lxc:
|
|
|
|
target: devhost10
|
2015-06-17 22:41:03 +00:00
|
|
|
driver: lxc
|
2014-02-28 16:43:35 +00:00
|
|
|
|
2015-08-10 15:20:26 +00:00
|
|
|
.. note::
|
|
|
|
.. versionchanged:: 2015.8.0
|
|
|
|
|
|
|
|
The ``provider`` parameter in cloud provider definitions was renamed to ``driver``. This
|
|
|
|
change was made to avoid confusion with the ``provider`` parameter that is used in cloud profile
|
|
|
|
definitions. Cloud provider definitions now use ``driver`` to refer to the Salt cloud module that
|
|
|
|
provides the underlying functionality to connect to a cloud host, while cloud profiles continue
|
|
|
|
to use ``provider`` to refer to provider configurations that you define.
|
|
|
|
|
2014-02-28 16:43:35 +00:00
|
|
|
Profile configuration
|
2014-03-24 16:10:13 +00:00
|
|
|
---------------------
|
|
|
|
|
2015-05-22 16:06:04 +00:00
|
|
|
Please read :ref:`tutorial-lxc` before anything else.
|
|
|
|
And specially :ref:`tutorial-lxc-profiles`.
|
|
|
|
|
2014-07-14 17:37:13 +00:00
|
|
|
Here are the options to configure your containers:
|
|
|
|
|
2014-02-28 16:43:35 +00:00
|
|
|
|
2015-05-22 16:06:04 +00:00
|
|
|
target
|
2014-02-28 16:43:35 +00:00
|
|
|
Host minion id to install the lxc Container into
|
2015-05-22 16:06:04 +00:00
|
|
|
lxc_profile
|
|
|
|
Name of the profile or inline options for the LXC vm creation/cloning,
|
|
|
|
please see :ref:`tutorial-lxc-profiles-container`.
|
|
|
|
network_profile
|
|
|
|
Name of the profile or inline options for the LXC vm network settings,
|
|
|
|
please see :ref:`tutorial-lxc-profiles-network`.
|
|
|
|
nic_opts
|
2015-11-03 16:48:58 +00:00
|
|
|
Totally optional.
|
2015-05-22 16:06:04 +00:00
|
|
|
Per interface new-style configuration options mappings which will
|
|
|
|
override any profile default option::
|
2015-05-16 22:27:29 +00:00
|
|
|
|
|
|
|
eth0: {'mac': '00:16:3e:01:29:40',
|
|
|
|
'gateway': None, (default)
|
|
|
|
'link': 'br0', (default)
|
|
|
|
'gateway': None, (default)
|
|
|
|
'netmask': '', (default)
|
|
|
|
'ip': '22.1.4.25'}}
|
2014-04-24 22:16:53 +00:00
|
|
|
|
2014-02-28 16:43:35 +00:00
|
|
|
password
|
2015-05-22 16:06:04 +00:00
|
|
|
password for root and sysadmin users
|
2014-02-28 16:43:35 +00:00
|
|
|
dnsservers
|
2015-05-22 16:06:04 +00:00
|
|
|
List of DNS servers to use. This is optional.
|
2014-02-28 16:43:35 +00:00
|
|
|
minion
|
2016-12-15 23:09:27 +00:00
|
|
|
minion configuration (see :ref:`Minion Configuration in Salt Cloud <salt-cloud-config>`)
|
2015-11-18 12:34:22 +00:00
|
|
|
bootstrap_delay
|
|
|
|
specify the time to wait (in seconds) between container creation
|
|
|
|
and salt bootstrap execution. It is useful to ensure that all essential services
|
|
|
|
have started before the bootstrap script is executed. By default there's no
|
|
|
|
wait time between container creation and bootstrap unless you are on systemd
|
|
|
|
where we wait that the system is no more in starting state.
|
2015-05-23 12:45:43 +00:00
|
|
|
bootstrap_shell
|
2015-05-23 12:49:34 +00:00
|
|
|
shell for bootstraping script (default: /bin/sh)
|
2015-05-23 12:45:43 +00:00
|
|
|
script
|
2015-05-23 12:49:34 +00:00
|
|
|
defaults to salt-boostrap
|
2015-05-23 12:45:43 +00:00
|
|
|
script_args
|
|
|
|
arguments which are given to the bootstrap script.
|
|
|
|
the {0} placeholder will be replaced by the path which contains the
|
|
|
|
minion config and key files, eg::
|
|
|
|
|
2015-05-23 12:49:34 +00:00
|
|
|
script_args="-c {0}"
|
2014-02-28 16:43:35 +00:00
|
|
|
|
|
|
|
|
2015-05-22 16:06:04 +00:00
|
|
|
Using profiles:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Note: This example would go in /etc/salt/cloud.profiles or any file in the
|
|
|
|
# /etc/salt/cloud.profiles.d/ directory.
|
|
|
|
devhost10-lxc:
|
|
|
|
provider: devhost10-lxc
|
|
|
|
lxc_profile: foo
|
|
|
|
network_profile: bar
|
|
|
|
minion:
|
|
|
|
master: 10.5.0.1
|
|
|
|
master_port: 4506
|
|
|
|
|
|
|
|
Using inline profiles (eg to override the network bridge):
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
devhost11-lxc:
|
|
|
|
provider: devhost10-lxc
|
|
|
|
lxc_profile:
|
|
|
|
clone_from: foo
|
|
|
|
network_profile:
|
|
|
|
etho:
|
|
|
|
link: lxcbr0
|
|
|
|
minion:
|
|
|
|
master: 10.5.0.1
|
|
|
|
master_port: 4506
|
|
|
|
|
2015-11-18 12:34:22 +00:00
|
|
|
Using a lxc template instead of a clone:
|
2015-05-22 16:06:04 +00:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
devhost11-lxc:
|
|
|
|
provider: devhost10-lxc
|
|
|
|
lxc_profile:
|
|
|
|
template: ubuntu
|
2015-11-18 12:34:22 +00:00
|
|
|
# options:
|
|
|
|
# release: trusty
|
2015-05-22 16:06:04 +00:00
|
|
|
network_profile:
|
|
|
|
etho:
|
2015-11-18 12:34:22 +00:00
|
|
|
link: lxcbr0
|
2015-05-22 16:06:04 +00:00
|
|
|
minion:
|
|
|
|
master: 10.5.0.1
|
|
|
|
master_port: 4506
|
|
|
|
|
|
|
|
Static ip:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Note: This example would go in /etc/salt/cloud.profiles or any file in the
|
|
|
|
# /etc/salt/cloud.profiles.d/ directory.
|
|
|
|
devhost10-lxc:
|
|
|
|
provider: devhost10-lxc
|
|
|
|
nic_opts:
|
|
|
|
eth0:
|
|
|
|
ipv4: 10.0.3.9
|
|
|
|
minion:
|
|
|
|
master: 10.5.0.1
|
|
|
|
master_port: 4506
|
|
|
|
|
|
|
|
DHCP:
|
|
|
|
|
2014-02-28 16:43:35 +00:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
2015-05-19 16:27:35 +00:00
|
|
|
# Note: This example would go in /etc/salt/cloud.profiles or any file in the
|
|
|
|
# /etc/salt/cloud.profiles.d/ directory.
|
2014-02-28 16:43:35 +00:00
|
|
|
devhost10-lxc:
|
|
|
|
provider: devhost10-lxc
|
|
|
|
minion:
|
|
|
|
master: 10.5.0.1
|
|
|
|
master_port: 4506
|
|
|
|
|
2014-03-24 16:10:13 +00:00
|
|
|
Driver Support
|
|
|
|
--------------
|
|
|
|
|
2014-02-28 16:43:35 +00:00
|
|
|
- Container creation
|
2014-03-24 16:10:13 +00:00
|
|
|
- Image listing (LXC templates)
|
2015-05-16 22:27:29 +00:00
|
|
|
- Running container information (IP addresses, etc.)
|
2015-11-05 17:15:30 +00:00
|
|
|
|