Skip to content
A Linode module for Ansible (deprecated).
Python
Find file
Failed to load latest commit information.
library Fixed documentation string and added generated version to readme
.gitignore Ignoring pyc files and the ansible/ directory
README.markdown
private-example.py Added readme and example file
test_scripts.py Added private_ip to tests

README.markdown

Linode Module for Ansible (deprecated)

This module is now deprecated as a different Linode module has been integrated into Ansible core.

Overview

A simple way to manage Linodes via Ansible. Supports creating, destroying, shutting down, rebooting and starting a Linode.

Installation

Copy the library directly into the directory where your Playbooks are located.

> cp -R library /etc/ansible/company_name/

Options

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
              • 1
              • 12
              • 24
              Length of time in months for payment term
              state yes
              • present
              • absent
              • rebooted
              • shutdown
              • booted
              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

                            Examples

                            • 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
                            

                            Dependencies

                            Requires python-linode available via pip.

                            > sudo pip install python-linode

                            Limitations

                            • 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?)

                            Tests

                            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
                            
                            Something went wrong with that request. Please try again.