This module is now deprecated as a different Linode module has been integrated into Ansible core.
A simple way to manage Linodes via Ansible. Supports creating, destroying, shutting down, rebooting and starting a Linode.
Copy the library directly into the directory where your Playbooks are located.
> cp -R library /etc/ansible/company_name/
parameter | required | default | choices | comments |
---|---|---|---|---|
datacenter | no | String or id representing the Linode's datacenter (http://www.linode.com/api/utility/avail.datacenters) | ||
name | yes | Name/label/hostname of the Linode instance | ||
kernel | no | String or id representing the kernel for the configuration profile (http://www.linode.com/api/utility/avail.kernels) | ||
swap_disk_size | no | Size of swap disk in MB | ||
root_disk_size | no | Size of root disk in MB | ||
root_ssh_key | no | Optionally include an ssh key for root | ||
payment_term | no | 1 |
|
Length of time in months for payment term |
state | yes |
|
Present will create the Linode if it doesn't exist, absent will destroy it (be careful!), shutdown, booted and rebooted will perform the action the name implies, all except rebooted are idempotent actions | |
display_group | no | Optionally specify which display group to place the Linode in | ||
plan | no | String or id representing the Linode plan (http://www.linode.com/api/utility/avail.linodeplans) | ||
timeout | no | 120 | optionally specify a timeout period in seconds to wait | |
distribution | no | String or id representing the OS on your server (http://www.linode.com/api/utility/avail.distributions) | ||
api_key | yes | API key use to manage your Linodes | ||
root_password | no | String representing the root password for the Linode (only changed at node creation) | ||
wait | no | wait for Linode instance to be in state 'booted' before returning |
- Create a new Linode called 'server_name' on the Linode 512 payment plan, does nothing if device already exists
local_action: linode_manager api_key=1234 name=server_name plan='Linode 512' datacenter=Tokyo payment_term=1 kernel=3.7.5-linode48 state=present root_disk_size=24320 swap_disk_size=256 root_password=hunter2 wait=true
- Restart a Linode called webserver01 and wait for it to finish booting
local_action: linode_manager name=webserver01 wait=yes
Requires python-linode available via pip.
> sudo pip install python-linode
- Only supports the creation of 1 disk from a distribution
- No support for NodeBalancer, StackScripts and DNS (again, perhaps a separate module should tackle this?)
Unfortunately, due to the way modules are imported into Ansible, it is difficult to implement unit tests for them. So, I've automated the process of testing through a number of subprocess.call commands to ansible/hacking/test-module command. To run them, you'll need a valid Linode API key, and a willingness to spend a couple of dollars building boxes and tearing them down. Hopefully one day Linode will have a Sandbox, negating the need for this but until then...
To run the tests:
- Clone the Ansible repo and make the test-module script executable
> git clone git@github.com:ansible/ansible.git
> chmod +x ansible/hacking/test-module
- Create the private.py file and update it with your API key and details
> cp private-example.py private.py
> vi private.py
- Run test_scripts.py (by default, the scripts will charge your account, so be careful!)
> python test_scripts