1
0

lxc.rst 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. .. _config_lxc:
  2. ========================
  3. Getting Started With LXC
  4. ========================
  5. The LXC module is designed to install Salt in an LXC container on a controlled
  6. and possibly remote minion.
  7. In other words, Salt will connect to a minion, then from that minion:
  8. - Provision and configure a container for networking access
  9. - Use those modules to deploy salt and re-attach to master.
  10. - :mod:`lxc runner <salt.runners.lxc>`
  11. - :mod:`lxc module <salt.modules.lxc>`
  12. - :mod:`seed <salt.modules.config>`
  13. Limitations
  14. -----------
  15. - You can only act on one minion and one provider at a time.
  16. - Listing images must be targeted to a particular LXC provider (nothing will be
  17. outputted with ``all``)
  18. Operation
  19. ---------
  20. Salt's LXC support does use :mod:`lxc.init <salt.modules.lxc.init>`
  21. via the :mod:`lxc.cloud_init_interface <salt.modules.lxc.cloud_init_interface>`
  22. and seeds the minion via :mod:`seed.mkconfig <salt.modules.seed.mkconfig>`.
  23. You can provide to those lxc VMs a profile and a network profile like if
  24. you were directly using the minion module.
  25. Order of operation:
  26. - Create the LXC container on the desired minion (clone or template)
  27. - Change LXC config options (if any need to be changed)
  28. - Start container
  29. - Change base passwords if any
  30. - Change base DNS configuration if necessary
  31. - Wait for LXC container to be up and ready for ssh
  32. - Test SSH connection and bailout in error
  33. - Upload deploy script and seeds, then re-attach the minion.
  34. Provider configuration
  35. ----------------------
  36. Here is a simple provider configuration:
  37. .. code-block:: yaml
  38. # Note: This example goes in /etc/salt/cloud.providers or any file in the
  39. # /etc/salt/cloud.providers.d/ directory.
  40. devhost10-lxc:
  41. target: devhost10
  42. driver: lxc
  43. .. note::
  44. .. versionchanged:: 2015.8.0
  45. The ``provider`` parameter in cloud provider definitions was renamed to ``driver``. This
  46. change was made to avoid confusion with the ``provider`` parameter that is used in cloud profile
  47. definitions. Cloud provider definitions now use ``driver`` to refer to the Salt cloud module that
  48. provides the underlying functionality to connect to a cloud host, while cloud profiles continue
  49. to use ``provider`` to refer to provider configurations that you define.
  50. Profile configuration
  51. ---------------------
  52. Please read :ref:`tutorial-lxc` before anything else.
  53. And specially :ref:`tutorial-lxc-profiles`.
  54. Here are the options to configure your containers:
  55. target
  56. Host minion id to install the lxc Container into
  57. lxc_profile
  58. Name of the profile or inline options for the LXC vm creation/cloning,
  59. please see :ref:`tutorial-lxc-profiles-container`.
  60. network_profile
  61. Name of the profile or inline options for the LXC vm network settings,
  62. please see :ref:`tutorial-lxc-profiles-network`.
  63. nic_opts
  64. Totally optional.
  65. Per interface new-style configuration options mappings which will
  66. override any profile default option::
  67. eth0: {'mac': '00:16:3e:01:29:40',
  68. 'gateway': None, (default)
  69. 'link': 'br0', (default)
  70. 'gateway': None, (default)
  71. 'netmask': '', (default)
  72. 'ip': '22.1.4.25'}}
  73. password
  74. password for root and sysadmin users
  75. dnsservers
  76. List of DNS servers to use. This is optional.
  77. minion
  78. minion configuration (see :ref:`Minion Configuration in Salt Cloud <salt-cloud-config>`)
  79. bootstrap_delay
  80. specify the time to wait (in seconds) between container creation
  81. and salt bootstrap execution. It is useful to ensure that all essential services
  82. have started before the bootstrap script is executed. By default there's no
  83. wait time between container creation and bootstrap unless you are on systemd
  84. where we wait that the system is no more in starting state.
  85. bootstrap_shell
  86. shell for bootstraping script (default: /bin/sh)
  87. script
  88. defaults to salt-boostrap
  89. script_args
  90. arguments which are given to the bootstrap script.
  91. the {0} placeholder will be replaced by the path which contains the
  92. minion config and key files, eg::
  93. script_args="-c {0}"
  94. Using profiles:
  95. .. code-block:: yaml
  96. # Note: This example would go in /etc/salt/cloud.profiles or any file in the
  97. # /etc/salt/cloud.profiles.d/ directory.
  98. devhost10-lxc:
  99. provider: devhost10-lxc
  100. lxc_profile: foo
  101. network_profile: bar
  102. minion:
  103. master: 10.5.0.1
  104. master_port: 4506
  105. Using inline profiles (eg to override the network bridge):
  106. .. code-block:: yaml
  107. devhost11-lxc:
  108. provider: devhost10-lxc
  109. lxc_profile:
  110. clone_from: foo
  111. network_profile:
  112. etho:
  113. link: lxcbr0
  114. minion:
  115. master: 10.5.0.1
  116. master_port: 4506
  117. Using a lxc template instead of a clone:
  118. .. code-block:: yaml
  119. devhost11-lxc:
  120. provider: devhost10-lxc
  121. lxc_profile:
  122. template: ubuntu
  123. # options:
  124. # release: trusty
  125. network_profile:
  126. etho:
  127. link: lxcbr0
  128. minion:
  129. master: 10.5.0.1
  130. master_port: 4506
  131. Static ip:
  132. .. code-block:: yaml
  133. # Note: This example would go in /etc/salt/cloud.profiles or any file in the
  134. # /etc/salt/cloud.profiles.d/ directory.
  135. devhost10-lxc:
  136. provider: devhost10-lxc
  137. nic_opts:
  138. eth0:
  139. ipv4: 10.0.3.9
  140. minion:
  141. master: 10.5.0.1
  142. master_port: 4506
  143. DHCP:
  144. .. code-block:: yaml
  145. # Note: This example would go in /etc/salt/cloud.profiles or any file in the
  146. # /etc/salt/cloud.profiles.d/ directory.
  147. devhost10-lxc:
  148. provider: devhost10-lxc
  149. minion:
  150. master: 10.5.0.1
  151. master_port: 4506
  152. Driver Support
  153. --------------
  154. - Container creation
  155. - Image listing (LXC templates)
  156. - Running container information (IP addresses, etc.)