How do I create a linode instance using Ansible.

This module currently exists for creating Linode server via Linode API.

Unfortunately, it is unclear which API version works with it. Can anyone provide insight please? Using the currently api version results in errors that point to endpoint mismatch but as this is my first time using Linode I am not sure how to proceed.

Thank you.

5 Replies

As linode-python is listed in the requirements it appears to be using our APIv3. The Python library for our APIv4 is linode_api4-python.

Could you try using the Linode APIv3 and let me know if it works for you?

Hi,

Sorry for hijacking the question but I'd have a related question.
Using the following playbook I'm able to create a new Linode with ansible and the linode_module mentioned above, but I have no clear idea on how to get the numerical list of allowed values for e.g. distribution (or datacenter, where I've used 4 hoping for UK, but seems it's Atlanta ;-) )

---
- name: Create a Linode server
  hosts: localhost
  connection: local
  gather_facts: false

  tasks:
  - name: Get the Linode API key
    shell: security find-generic-password -l linode-api -a linode -w
    register: LINODE_API_KEY

  - name: debug
    debug:
      msg: "API is {{ LINODE_API_KEY.stdout }}"

  - name: create linode server via Linode API
    linode:
      api_key: '{{ LINODE_API_KEY.stdout }}'
      name: attila
      plan: 1
      datacenter: 4
      distribution: 2
      state: present
    delegate_to: localhost

@mjones, so having spent a week battling back and forth between v3 & v4 docs, and all the various infrastructure touchpoint I have to work with, (terraform, ansible, etc), I have decided to leave some product feedback.

I found it really difficult to find some the basic information on how v3 endpoints translates to v4 - datacenter, plans, image, etc. I think it is really bad form to not maintain the docs for v3 esp. since almost all the working sdks/plugins for linode still depend on v3.

Take this simple example, your docs for v3 states:

creating a Linode is as simple as:

linode.create(DatacenterID, PlanID, PaymentTerm)

yet I can't seem to find information on all the possible values for any of the above.

Further more, attempting to investigate how the endpoints might have changed using the instructions here results in errors like this:

curl https://api.linode.com/?api_key=$LINODE_V3_API_KEY&api_action=avail.datacenters

[1] 33988

 {"ACTION":"","DATA":{},"ERRORARRAY":[{"ERRORMESSAGE":"No action was requested","ERRORCODE":2}]}

Looking through the changelog does not yield much better results either.

This is such bad user experience (if I wasn't being forced to use your product by my boss, I would have switched). Please do better.

I covered some of the history and the newer Linode APIv4 Ansible module support in this question/answer:

https://www.linode.com/community/questions/18235/how-do-i-deploy-linodes-using-ansible#answer-68914

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct