1
0

digitalocean.rst 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. =================================
  2. Getting Started With DigitalOcean
  3. =================================
  4. DigitalOcean is a public cloud host that specializes in Linux instances.
  5. Configuration
  6. =============
  7. Using Salt for DigitalOcean requires a ``personal_access_token``, an ``ssh_key_file``,
  8. and at least one SSH key name in ``ssh_key_names``. More ``ssh_key_names`` can be added
  9. by separating each key with a comma. The ``personal_access_token`` can be found in the
  10. DigitalOcean web interface in the "Apps & API" section. The SSH key name can be found
  11. under the "SSH Keys" section.
  12. .. code-block:: yaml
  13. # Note: This example is for /etc/salt/cloud.providers or any file in the
  14. # /etc/salt/cloud.providers.d/ directory.
  15. my-digitalocean-config:
  16. driver: digitalocean
  17. personal_access_token: xxx
  18. ssh_key_file: /path/to/ssh/key/file
  19. ssh_key_names: my-key-name,my-key-name-2
  20. location: New York 1
  21. .. note::
  22. .. versionchanged:: 2015.8.0
  23. The ``provider`` parameter in cloud provider definitions was renamed to ``driver``. This
  24. change was made to avoid confusion with the ``provider`` parameter that is used in cloud profile
  25. definitions. Cloud provider definitions now use ``driver`` to refer to the Salt cloud module that
  26. provides the underlying functionality to connect to a cloud host, while cloud profiles continue
  27. to use ``provider`` to refer to provider configurations that you define.
  28. Profiles
  29. ========
  30. Cloud Profiles
  31. ~~~~~~~~~~~~~~
  32. Set up an initial profile at ``/etc/salt/cloud.profiles`` or in the
  33. ``/etc/salt/cloud.profiles.d/`` directory:
  34. .. code-block:: yaml
  35. digitalocean-ubuntu:
  36. provider: my-digitalocean-config
  37. image: 14.04 x64
  38. size: 512MB
  39. location: New York 1
  40. private_networking: True
  41. backups_enabled: True
  42. ipv6: True
  43. create_dns_record: True
  44. userdata_file: /etc/salt/cloud.userdata.d/setup
  45. tags:
  46. - tag1
  47. - tag2
  48. - tag3
  49. Locations can be obtained using the ``--list-locations`` option for the ``salt-cloud``
  50. command:
  51. .. code-block:: bash
  52. # salt-cloud --list-locations my-digitalocean-config
  53. my-digitalocean-config:
  54. ----------
  55. digitalocean:
  56. ----------
  57. Amsterdam 1:
  58. ----------
  59. available:
  60. False
  61. features:
  62. [u'backups']
  63. name:
  64. Amsterdam 1
  65. sizes:
  66. []
  67. slug:
  68. ams1
  69. ...SNIP...
  70. Sizes can be obtained using the ``--list-sizes`` option for the ``salt-cloud``
  71. command:
  72. .. code-block:: bash
  73. # salt-cloud --list-sizes my-digitalocean-config
  74. my-digitalocean-config:
  75. ----------
  76. digitalocean:
  77. ----------
  78. 512MB:
  79. ----------
  80. cost_per_hour:
  81. 0.00744
  82. cost_per_month:
  83. 5.0
  84. cpu:
  85. 1
  86. disk:
  87. 20
  88. id:
  89. 66
  90. memory:
  91. 512
  92. name:
  93. 512MB
  94. slug:
  95. None
  96. ...SNIP...
  97. Images can be obtained using the ``--list-images`` option for the ``salt-cloud``
  98. command:
  99. .. code-block:: bash
  100. # salt-cloud --list-images my-digitalocean-config
  101. my-digitalocean-config:
  102. ----------
  103. digitalocean:
  104. ----------
  105. 10.1:
  106. ----------
  107. created_at:
  108. 2015-01-20T20:04:34Z
  109. distribution:
  110. FreeBSD
  111. id:
  112. 10144573
  113. min_disk_size:
  114. 20
  115. name:
  116. 10.1
  117. public:
  118. True
  119. ...SNIP...
  120. Profile Specifics:
  121. ------------------
  122. ssh_username
  123. ------------
  124. If using a FreeBSD image from DigitalOcean, you'll need to set the ``ssh_username``
  125. setting to ``freebsd`` in your profile configuration.
  126. .. code-block:: yaml
  127. digitalocean-freebsd:
  128. provider: my-digitalocean-config
  129. image: 10.2
  130. size: 512MB
  131. ssh_username: freebsd
  132. userdata_file
  133. ~~~~~~~~~~~~~
  134. .. versionadded:: 2016.11.6
  135. Use `userdata_file` to specify the userdata file to upload for use with
  136. cloud-init if available.
  137. .. code-block:: yaml
  138. my-openstack-config:
  139. # Pass userdata to the instance to be created
  140. userdata_file: /etc/salt/cloud-init/packages.yml
  141. .. code-block:: yaml
  142. my-do-config:
  143. # Pass userdata to the instance to be created
  144. userdata_file: /etc/salt/cloud-init/packages.yml
  145. userdata_template: jinja
  146. If no ``userdata_template`` is set in the cloud profile, then the master
  147. configuration will be checked for a :conf_master:`userdata_template` value.
  148. If this is not set, then no templating will be performed on the
  149. userdata_file.
  150. To disable templating in a cloud profile when a
  151. :conf_master:`userdata_template` has been set in the master configuration
  152. file, simply set ``userdata_template`` to ``False`` in the cloud profile:
  153. .. code-block:: yaml
  154. my-do-config:
  155. # Pass userdata to the instance to be created
  156. userdata_file: /etc/salt/cloud-init/packages.yml
  157. userdata_template: False
  158. Miscellaneous Information
  159. =========================
  160. .. note::
  161. DigitalOcean's concept of ``Applications`` is nothing more than a
  162. pre-configured instance (same as a normal Droplet). You will find examples
  163. such ``Docker 0.7 Ubuntu 13.04 x64`` and ``Wordpress on Ubuntu 12.10``
  164. when using the ``--list-images`` option. These names can be used just like
  165. the rest of the standard instances when specifying an image in the cloud
  166. profile configuration.
  167. .. note::
  168. If your domain's DNS is managed with DigitalOcean, and your minion name
  169. matches your DigitalOcean managed DNS domain, you can automatically create
  170. A and AAA records for newly created droplets. Use ``create_dns_record: True``
  171. in your config to enable this. Adding ``delete_dns_record: True`` to also
  172. delete records when a droplet is destroyed is optional. Due to limitations
  173. in salt-cloud design, the destroy code does not have access to the VM config
  174. data. WHETHER YOU ADD ``create_dns_record: True`` OR NOT, salt-cloud WILL
  175. attempt to delete your DNS records if the minion name matches. This will
  176. prevent advertising any recycled IP addresses for destroyed minions.
  177. .. note::
  178. If you need to perform the bootstrap using the local interface for droplets,
  179. this can be done by setting ``ssh_interface: private`` in your config. By
  180. default the salt-cloud script would run on the public interface however if firewall
  181. is preventing the connection to the Droplet over the public interface you might need
  182. to set this option to connect via private interface. Also, to use this feature
  183. ``private_networking: True`` must be set in the config.
  184. .. note::
  185. Additional documentation is available from `DigitalOcean <https://www.digitalocean.com/community/tutorials/automated-provisioning-of-digitalocean-cloud-servers-with-salt-cloud-on-ubuntu-12-04>`_.