salt/doc/topics/cloud/lxc.rst

189 lines
5.0 KiB
ReStructuredText
Raw Normal View History

.. _config_lxc:
========================
2014-02-28 16:43:35 +00:00
Getting Started With LXC
========================
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
In other words, Salt will connect to a minion, then from that minion:
- Provision and configure a container for networking access
- Use those modules to deploy salt and re-attach to master.
- :mod:`lxc runner <salt.runners.lxc>`
- :mod:`lxc module <salt.modules.lxc>`
- :mod:`seed <salt.modules.config>`
2014-02-28 16:43:35 +00:00
Limitations
-----------
2014-02-28 16:43:35 +00:00
- You can only act on one minion and one provider at a time.
- Listing images must be targeted to a particular LXC provider (nothing will be
outputted with ``all``)
2014-02-28 16:43:35 +00:00
.. warning::
On pre **2015.5.2**, you need to specify explitly the network bridge
2014-02-28 16:43:35 +00:00
Operation
---------
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
Order of operation:
2014-02-28 16:43:35 +00:00
- Create the LXC container on the desired minion (clone or template)
- Change LXC config options (if any need to be changed)
- Start container
- Change base passwords if any
- Change base DNS configuration if necessary
- Wait for LXC container to be up and ready for ssh
- Test SSH connection and bailout in error
- Upload deploy script and seeds, then re-attach the minion.
2014-02-28 16:43:35 +00:00
Provider configuration
----------------------
Here is a simple provider configuration:
2014-02-28 16:43:35 +00:00
.. code-block:: yaml
# 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
driver: lxc
2014-02-28 16:43:35 +00:00
Profile configuration
---------------------
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
target
2014-02-28 16:43:35 +00:00
Host minion id to install the lxc Container into
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
Totally optionnal.
Per interface new-style configuration options mappings which will
override any profile default option::
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-02-28 16:43:35 +00:00
password
password for root and sysadmin users
2014-02-28 16:43:35 +00:00
dnsservers
List of DNS servers to use. This is optional.
2014-02-28 16:43:35 +00:00
minion
minion configuration (see :doc:`Minion Configuration in Salt Cloud </topics/cloud/config>`)
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
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
Template instead of a clone:
.. code-block:: yaml
devhost11-lxc:
provider: devhost10-lxc
lxc_profile:
template: ubuntu
network_profile:
etho:
link: lxcbr0
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
# 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
Driver Support
--------------
2014-02-28 16:43:35 +00:00
- Container creation
- Image listing (LXC templates)
- Running container information (IP addresses, etc.)