qs.rst 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. .. _salt-cloud-qs:
  2. =====================
  3. Salt Cloud Quickstart
  4. =====================
  5. Salt Cloud is built-in to Salt, and the easiest way to run Salt Cloud is
  6. directly from your Salt Master.
  7. Note that if you installed Salt via `Salt Bootstrap`_, it may not have
  8. automatically installed salt-cloud for you. Use your distribution's package
  9. manager to install the ``salt-cloud`` package from the same repo that you
  10. used to install Salt. These repos will automatically be setup by Salt Bootstrap.
  11. Alternatively, the ``-L`` option can be passed to the `Salt Bootstrap`_ script when
  12. installing Salt. The ``-L`` option will install ``salt-cloud`` and the required
  13. ``libcloud`` package.
  14. .. _`Salt Bootstrap`: https://github.com/saltstack/salt-bootstrap
  15. This quickstart walks you through the basic steps of setting up a cloud host
  16. and defining some virtual machines to create.
  17. .. note:: Salt Cloud has its own process and does not rely on the Salt Master,
  18. so it can be installed on a standalone minion instead of your Salt Master.
  19. Define a Provider
  20. -----------------
  21. The first step is to add the credentials for your cloud host. Credentials and
  22. other settings provided by the cloud host are stored in provider configuration
  23. files. Provider configurations contain the details needed to connect to a cloud
  24. host such as EC2, GCE, Rackspace, etc., and any global options that you want
  25. set on your cloud minions (such as the location of your Salt Master).
  26. On your Salt Master, browse to ``/etc/salt/cloud.providers.d/`` and create
  27. a file called ``<provider>.conf``, replacing ``<provider>`` with
  28. ``ec2``, ``softlayer``, and so on. The name helps you identify the contents,
  29. and is not important as long as the file ends in ``.conf``.
  30. Next, browse to the :ref:`Provider specifics <cloud-provider-specifics>` and
  31. add any required settings for your cloud host to this file. Here is an example
  32. for Amazon EC2:
  33. .. code-block:: yaml
  34. my-ec2:
  35. driver: ec2
  36. # Set the EC2 access credentials (see below)
  37. #
  38. id: 'HJGRYCILJLKJYG'
  39. key: 'kdjgfsgm;woormgl/aserigjksjdhasdfgn'
  40. # Make sure this key is owned by root with permissions 0400.
  41. #
  42. private_key: /etc/salt/my_test_key.pem
  43. keyname: my_test_key
  44. securitygroup: default
  45. # Optional: Set up the location of the Salt Master
  46. #
  47. minion:
  48. master: saltmaster.example.com
  49. The required configuration varies between cloud hosts so make sure you read the
  50. provider specifics.
  51. List Cloud Provider Options
  52. ---------------------------
  53. You can now query the cloud provider you configured for available locations,
  54. images, and sizes. This information is used when you set up VM profiles.
  55. .. code-block:: console
  56. salt-cloud --list-locations <provider_name> # my-ec2 in the previous example
  57. salt-cloud --list-images <provider_name>
  58. salt-cloud --list-sizes <provider_name>
  59. Replace ``<provider_name>`` with the name of the provider configuration you defined.
  60. Create VM Profiles
  61. ------------------
  62. On your Salt Master, browse to ``/etc/salt/cloud.profiles.d/`` and create
  63. a file called ``<profile>.conf``, replacing ``<profile>`` with
  64. ``ec2``, ``softlayer``, and so on. The file must end in ``.conf``.
  65. You can now add any custom profiles you'd like to define to this file. Here are
  66. a few examples:
  67. .. code-block:: yaml
  68. micro_ec2:
  69. provider: my-ec2
  70. image: ami-d514f291
  71. size: t1.micro
  72. medium_ec2:
  73. provider: my-ec2
  74. image: ami-d514f291
  75. size: m3.medium
  76. large_ec2:
  77. provider: my-ec2
  78. image: ami-d514f291
  79. size: m3.large
  80. Notice that the ``provider`` in our profile matches the provider name that we
  81. defined? That is how Salt Cloud knows how to connect to a cloud host to
  82. create a VM with these attributes.
  83. Create VMs
  84. ----------
  85. VMs are created by calling ``salt-cloud`` with the following options:
  86. .. code-block:: console
  87. salt-cloud -p <profile> <name1> <name2> ...
  88. For example:
  89. .. code-block:: bash
  90. salt-cloud -p micro_ec2 minion1 minion2
  91. Destroy VMs
  92. -----------
  93. Add a ``-d`` and the minion name you provided to destroy:
  94. .. code-block:: bash
  95. salt-cloud -d minion1 minion2
  96. Query VMs
  97. ---------
  98. You can view details about the VMs you've created using ``--query``:
  99. .. code-block:: bash
  100. salt-cloud --query
  101. Cloud Map
  102. ---------
  103. Now that you know how to create and destoy individual VMs, next you should
  104. learn how to use a cloud map to create a number of VMs at once.
  105. Cloud maps let you define a map of your infrastructure and quickly provision
  106. any number of VMs. On subsequent runs, any VMs that do not exist are created,
  107. and VMs that are already configured are left unmodified.
  108. See :ref:`Cloud Map File <salt-cloud-map>`.