Using SaltStack with Linode Cloud
Lately I added some parts about using Salt Cloud to create and manipulate Cloud VMs in SaltStack For DevOps Book, that’s why I would like to share with you a quickstart to create Linode Cloud VMs using SaltStack.
Linode (a portmanteau of the words linux and node) is a virtual private server/cloud hosting provider offering SSD Linux servers and simple management tools.
We will be using the Linode 1GB server with Salt Cloud.
Follow those steps to set up a Linode key that will be used with Salt Cloud:
– Go to Linode site
– Create a free account
– After confirming the account from your email, log in
– Click on ‘My Profile’
– Re-authenticate to unlock the settings
– Click on ‘API keys’
– Generate a key (I gave it the name ‘salt_cloud_demo’)
Note that you should save the generated key in your local machine since you will not be able to view it again in the web manager.
Note that I use this file structure when I work with Salt Cloud:
/etc/salt/ ├── cloud ├── cloud.conf.d/ ├── cloud.deploy.d/ ├── cloud.maps.d/ ├── cloud.profiles.d/
Let’s set up the provider configuration file for Linode:
As you can see in the next configuration, we are using the apikey provided by Linode with the password.
You should also configure the ssh_pubkey that you are using on your machine (in this example, I am executing Salt Cloud command from my local machine on a remote Linode server).
linode-config: provider: linode apikey: O61KWcOQ password: ************* ssh_pubkey: ssh-rsa xzt4Gg3WjHZgFvRU8EMUyVSxwwilKogg0TK0BkbY0gq+IADKMxhuq9yW4OnxlWcO+n2VkdaFZlAIh+/Sll7HdfmBclvGbw== root@eonSpider ssh_key_file: /root/.ssh/id_rsa
If you don’t have a public key, generate a key pair (public/private) using this command:
Now let’s create a Salt Cloud Profile file:
ubuntu_linode: provider: linode-config size: Linode 1024 image: Ubuntu 14.04 LTS location: Frankfurt, DE minion: master: 20a1:e35:9beb:6a00:2293:522a:2400:b57f # This is an IP v6, you can use your IP v4 also 🙂 grains: role: testing_server
Nice ! Let’s start our machine ‘testing_server‘ based on ‘ubuntu_linode‘ profile:
sudo salt-cloud -p ubuntu_linode testing_server
Let’s start two machines:
sudo salt-cloud -p ubuntu_linode testing_server_1 testing_server_2
Now we had two Linode machines with the following configuration:
* INFO: System Information: * INFO: CPU: GenuineIntel * INFO: CPU Arch: x86_64 * INFO: OS Name: Linux * INFO: OS Version: 4.4.0-x86_64-linode63 * INFO: Distribution: Ubuntu 14.04
Note that using Salt Cloud Maps could help you to create infrastructures instead of creating just some VMs, you should give it a try if you want to use SaltStack for managing Cloud VMs.
Well, this was just a quickstart, I am working on other examples that I will publish in SaltStack For DevOps book, do not hesitate if you have suggestions 🙂