linode.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. ===========================
  2. Getting Started With Linode
  3. ===========================
  4. Linode is a public cloud host with a focus on Linux instances.
  5. Dependencies
  6. ============
  7. This driver requires the Python ``requests`` library to be installed.
  8. Provider Configuration
  9. ======================
  10. Configuration Options
  11. ---------------------
  12. .. glossary::
  13. ``apikey``
  14. **(Required)** The key to use to authenticate with the Linode API.
  15. ``password``
  16. **(Required)** The default password to set on new VMs. Must be 8 characters with at least one lowercase, uppercase, and numeric.
  17. ``api_version``
  18. The version of the Linode API to interact with. Defaults to ``v3``.
  19. ``poll_interval``
  20. The rate of time in milliseconds to poll the Linode API for changes. Defaults to ``500``.
  21. ``ratelimit_sleep``
  22. The time in seconds to wait before retrying after a ratelimit has been enforced. Defaults to ``0``.
  23. Example Configuration
  24. ---------------------
  25. Set up the provider cloud configuration file at ``/etc/salt/cloud.providers`` or
  26. ``/etc/salt/cloud.providers.d/*.conf``.
  27. .. code-block:: yaml
  28. my-linode-provider:
  29. driver: linode
  30. api_version: v4
  31. apikey: f4ZsmwtB1c7f85Jdu43RgXVDFlNjuJaeIYV8QMftTqKScEB2vSosFSr...
  32. password: F00barbaz
  33. For use with APIv3 (deprecated):
  34. .. code-block:: yaml
  35. my-linode-provider-v3:
  36. driver: linode
  37. apikey: f4ZsmwtB1c7f85Jdu43RgXVDFlNjuJaeIYV8QMftTqKScEB2vSosFSr...
  38. password: F00barbaz
  39. Profile Configuration
  40. =====================
  41. Configuration Options
  42. ---------------------
  43. .. glossary::
  44. ``image``
  45. **(Required)** The image to deploy the boot disk from. This should be an image ID
  46. (e.g. ``linode/ubuntu16.04``); official images start with ``linode/``. For APIv3,
  47. this would be an image label (i.e. Ubuntu 16.04). See `listing images <#listing-images>`_
  48. for more options.
  49. ``location``
  50. **(Required)** The location of the VM. This should be a Linode region
  51. (e.g. ``us-east``). For APIv3, this would be a datacenter location
  52. (e.g. ``Newark, NJ, USA``). See `listing locations <#listing-locations>`_ for
  53. more options.
  54. ``size``
  55. **(Required)** The size of the VM. This should be a Linode instance type ID
  56. (e.g. ``g6-standard-2``). For APIv3, this would be a plan ID (e.g. ``Linode 2GB``).
  57. See `listing sizes <#listing-sizes>`_ for more options.
  58. ``password`` (overrides provider)
  59. **(*Required)** The default password for the VM. Must be provided at the profile
  60. or provider level.
  61. ``assign_private_ip``
  62. .. versionadded:: 2016.3.0
  63. Whether or not to assign a private key to the VM. Defaults to ``False``.
  64. ``cloneform``
  65. The name of the Linode to clone from.
  66. ``disk_size``
  67. **(Deprecated)** The amount of disk space to allocate for the OS disk. This has no
  68. effect with APIv4; the size of the boot disk will be the remainder of disk space
  69. after the swap partition is allocated.
  70. ``ssh_interface``
  71. .. versionadded:: 2016.3.0
  72. The interface with which to connect over SSH. Valid options are ``private_ips`` or
  73. ``public_ips``. Defaults to ``public_ips``.
  74. If specifying ``private_ips``, the Linodes must be hosted within the same data center
  75. and have the Network Helper enabled on your entire account. The instance that is
  76. running the Salt-Cloud provisioning command must also have a private IP assigned to it.
  77. Newer accounts created on Linode have the Network Helper setting enabled by default,
  78. account-wide. Legacy accounts do not have this setting enabled by default. To enable
  79. the Network Helper on your Linode account, please see `Linode's Network Helper`_
  80. documentation.
  81. ``ssh_pubkey``
  82. The public key to authorize for SSH with the VM.
  83. ``swap``
  84. The amount of disk space to allocate for the swap partition. Defaults to ``256``.
  85. .. _Linode's Network Helper: https://www.linode.com/docs/platform/network-helper/#what-is-network-helper
  86. Example Configuration
  87. ---------------------
  88. Set up a profile configuration in ``/etc/salt/cloud.profiles.d/``:
  89. .. code-block:: yaml
  90. my-linode-profile:
  91. provider: my-linode-provider
  92. size: g6-standard-1
  93. image: linode/alpine3.12
  94. location: us-east
  95. The ``my-linode-profile`` can be realized now with a salt command:
  96. .. code-block:: bash
  97. salt-cloud -p my-linode-profile my-linode-instance
  98. This will create a salt minion instance named ``my-linode-instance`` in Linode. If the command was
  99. executed on the salt-master, its Salt key will automatically be signed on the master.
  100. Once the instance has been created with a salt-minion installed, connectivity to
  101. it can be verified with Salt:
  102. .. code-block:: bash
  103. salt my-linode-instance test.version
  104. A more advanced configuration utlizing all of the configuration options might look like:
  105. .. code-block:: yaml
  106. my-linode-profile-advanced:
  107. provider: my-linode-provider
  108. size: g6-standard-3
  109. image: linode/alpine3.10
  110. location: eu-west
  111. password: bogus123X
  112. assign_private_ip: true
  113. ssh_interface: private_ips
  114. ssh_pubkey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQAB...
  115. swap_size: 512
  116. A legacy configuration for use with APIv3 might look like:
  117. .. code-block:: yaml
  118. my-linode-profile-v3:
  119. provider: my-linode-provider-v3
  120. size: Nanode 1GB
  121. image: Alpine 3.12
  122. location: Fremont, CA, USA
  123. Migrating to APIv4
  124. ==================
  125. Linode APIv3 has been deprecated and will be shutdown in the coming months. You can opt-in to using
  126. APIv4 by setting the ``api_version`` provider configuration option to ``v4``.
  127. When switching to APIv4, you will also need to generate a new token. See
  128. `here <https://www.linode.com/docs/platform/api/getting-started-with-the-linode-api/#create-an-api-token>`_
  129. for more information.
  130. Notable Changes
  131. ---------------
  132. **Move from label references to ID references.** The profile configuration parameters ``location``,
  133. ``size``, and ``image`` have moved from accepting label based references to IDs. See the
  134. `profile configuration <#profile-configuration>`_ section for more details.
  135. **The ``disk_size`` profile configuration parameter has been deprecated.** The parameter will not be taken into
  136. account when creating new VMs while targeting APIv4. See the ``disk_size`` description under the
  137. `profile configuration <#profile-configuration>`_ section for more details.
  138. **The ``boot`` function no longer requires a ``config_id``.** A config can be inferred by the API instead when booting.
  139. **The ``clone`` function has renamed parameters to match convention.** The old version of these parameters will not
  140. be supported when targeting APIv4.
  141. * ``datacenter_id`` has been deprecated in favor of ``location``.
  142. * ``plan_id`` has been deprecated in favor of ``size``.
  143. **The ``get_plan_id`` function has been deprecated and will not be supported by APIv4.** IDs are now the only way
  144. of referring to a "plan" (or type/size).
  145. Query Utilities
  146. ===============
  147. Listing Sizes
  148. -------------
  149. Available sizes can be obtained by running one of:
  150. .. code-block:: bash
  151. salt-cloud --list-sizes my-linode-provider
  152. salt-cloud -f avail_sizes my-linode-provider
  153. This will list all Linode sizes/types which can be referenced in VM profiles.
  154. .. code-block:: bash
  155. my-linode-config:
  156. g6-standard-1:
  157. ----------
  158. class:
  159. standard
  160. disk:
  161. 51200
  162. gpus:
  163. 0
  164. id:
  165. g6-standard-1
  166. label:
  167. Linode 2GB
  168. memory:
  169. 2048
  170. network_out:
  171. 2000
  172. price:
  173. ----------
  174. hourly:
  175. 0.015
  176. monthly:
  177. 10.0
  178. successor:
  179. None
  180. transfer:
  181. 2000
  182. vcpus:
  183. 1
  184. addons:
  185. ----------
  186. backups:
  187. ----------
  188. price:
  189. ----------
  190. hourly:
  191. 0.004
  192. monthly:
  193. 2.5
  194. ...SNIP...
  195. Listing Images
  196. --------------
  197. Available images can be obtained by running one of:
  198. .. code-block:: bash
  199. salt-cloud --list-images my-linode-provider
  200. salt-cloud -f avail_images my-linode-provider
  201. This will list all Linode images which can be referenced in VM profiles.
  202. Official images are available under the ``linode`` namespace.
  203. .. code-block:: bash
  204. my-linode-config:
  205. ----------
  206. linode:
  207. ----------
  208. linode/alpine3.10:
  209. ----------
  210. created:
  211. 2019-06-20T17:17:11
  212. created_by:
  213. linode
  214. deprecated:
  215. False
  216. description:
  217. None
  218. eol:
  219. 2021-05-01T04:00:00
  220. expiry:
  221. None
  222. id:
  223. linode/alpine3.10
  224. is_public:
  225. True
  226. label:
  227. Alpine 3.10
  228. size:
  229. 300
  230. type:
  231. manual
  232. vendor:
  233. Alpine
  234. ...SNIP...
  235. Listing Locations
  236. -----------------
  237. Available locations can be obtained by running one of:
  238. .. code-block:: bash
  239. salt-cloud --list-locations my-linode-provider
  240. salt-cloud -f avail_locations my-linode-provider
  241. This will list all Linode regions which can be referenced in VM profiles.
  242. .. code-block:: bash
  243. my-linode-config:
  244. ----------
  245. linode:
  246. ----------
  247. us-east:
  248. ----------
  249. capabilities:
  250. - Linodes
  251. - NodeBalancers
  252. - Block Storage
  253. - Object Storage
  254. - GPU Linodes
  255. - Kubernetes
  256. country:
  257. us
  258. id:
  259. us-east
  260. status:
  261. ok
  262. ...SNIP...
  263. Cloning
  264. =======
  265. To clone a Linode, add a profile with a ``clonefrom`` key, and a ``script_args: -C``.
  266. ``clonefrom`` should be the name of the Linode that is the source for the clone.
  267. ``script_args: -C`` passes a -C to the salt-bootstrap script, which only configures
  268. the minion and doesn't try to install a new copy of salt-minion. This way the minion
  269. gets new keys and the keys get pre-seeded on the master, and the ``/etc/salt/minion``
  270. file has the right minion 'id:' declaration.
  271. Cloning requires a post 2015-02-01 salt-bootstrap.
  272. It is safest to clone a stopped machine. To stop a machine run
  273. .. code-block:: bash
  274. salt-cloud -a stop machine_to_clone
  275. To create a new machine based on another machine, add an entry to your linode
  276. cloud profile that looks like this:
  277. .. code-block:: yaml
  278. li-clone:
  279. provider: my-linode-config
  280. clonefrom: machine_to_clone
  281. script_args: -C -F
  282. Then run salt-cloud as normal, specifying ``-p li-clone``. The profile name can
  283. be anything; It doesn't have to be ``li-clone``.
  284. ``clonefrom:`` is the name of an existing machine in Linode from which to clone.
  285. ``Script_args: -C -F`` is necessary to avoid re-deploying Salt via salt-bootstrap.
  286. ``-C`` will just re-deploy keys so the new minion will not have a duplicate key
  287. or minion_id on the Master, and ``-F`` will force a rewrite of the Minion config
  288. file on the new Minion. If ``-F`` isn't provided, the new Minion will have the
  289. ``machine_to_clone``'s Minion ID, instead of its own Minion ID, which can cause
  290. problems.
  291. .. note::
  292. `Pull Request #733`_ to the salt-bootstrap repo makes the ``-F`` argument
  293. non-necessary. Once that change is released into a stable version of the
  294. Bootstrap Script, the ``-C`` argument will be sufficient for the ``script_args``
  295. setting.
  296. .. _Pull Request #733: https://github.com/saltstack/salt-bootstrap/pull/733
  297. If the ``machine_to_clone`` does not have Salt installed on it, refrain from using
  298. the ``script_args: -C -F`` altogether, because the new machine will need to have
  299. Salt installed.