Wrong Linode ID with the linode Module

85 views
Skip to first unread message

Iwada Eja

unread,
Sep 22, 2015, 9:44:44 AM9/22/15
to Ansible Project
Please im relatively new with  ansiible and having an issue. 

Using the Linode Module to Create a new Linode instance. The Instance is created but with the wrong linode_id

- name: Create linode machine
      linode: 
        api_key: 'My_Api_key'
        name: server
        plan: 1
        datacenter: 7
        distribution: 140
        password: 'Some_password'
        linode_id: 12345678
        ssh_pub_key: 's......'
        wait: yes
        wait_timeout: 600
        state: present 


I assume the Linode instance is supposed to have an Id of 12345678, but that's not the Linode ID of the created instance. It's been set to an arbitrary  numeric value. 

Please how do i correct this?

Patrick Heeney

unread,
Sep 22, 2015, 1:28:54 PM9/22/15
to Ansible Project
This is sort of a bug with ansible because the linode role is not idempotent. 
I think there are pull requests to fix this in ansible v2, but for the time being 
you will mostly likely have to work around it.

The linode_id does not set the ID at linode. It is to target that linode server
if you need to remove or change it. This means there is no linode_id when
first create it. 

So to work around this issue you need to comment out the ID on first run.
Then you need to most likely need to add this to your linode task: 
`register: linode_server` then add a new task to - debug: var=linode_server
this way you can see the ID that is created. Copy that ID into `linode_id` on
for the next runs of the playbook to be idempotent. Hopefully they can fix this
soon.

Greg DeKoenigsberg

unread,
Sep 22, 2015, 1:59:48 PM9/22/15
to Ansible Project
On Tue, Sep 22, 2015 at 1:28 PM, Patrick Heeney <patric...@gmail.com> wrote:
> This is sort of a bug with ansible because the linode role is not
> idempotent.
> I think there are pull requests to fix this in ansible v2, but for the time
> being
> you will mostly likely have to work around it.

Check:
https://github.com/ansible/ansible-modules-core/search?q=linode&type=Issues

If you don't find an issue or PR here, feel free to file one.

--g
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f3b6bc5a-33ba-4d2f-9ae0-83208ac1e80f%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Greg DeKoenigsberg
Ansible Community Guy

Find out why SD Times named Ansible
their #1 Company to Watch in 2015:
http://sdtimes.com/companies-watch-2015/

Iwada Eja

unread,
Sep 22, 2015, 2:45:18 PM9/22/15
to Ansible Project
Thanks for the reply. Would use the work around. 

Also created an Issue on this as none existed.

Iwada Eja

unread,
Sep 22, 2015, 5:29:17 PM9/22/15
to Ansible Project

One More thing please, Is it possible that after i 
`register: linode_server

I set a varriable to the linode_id value to be used in another playbook?

Brian Coca

unread,
Sep 22, 2015, 6:17:13 PM9/22/15
to Ansible Project
register: linode_return

you should have the linode id as part of that variable.



--
Brian Coca

Patrick Heeney

unread,
Sep 22, 2015, 6:19:54 PM9/22/15
to ansible...@googlegroups.com
Indeed. I actually write the ID to a file and then use {{ lookup("file", "path/to/id") }} later in the playbook. This way I can use it after the playbook finishes in subsequent runs and in other playbooks.

Brian Coca

unread,
Sep 22, 2015, 6:22:44 PM9/22/15
to Ansible Project
you can even write to host_vars/linode_host

linode_id: 2134234

and it becomes a hostvar that is automatically loaded associated to that host.


--
Brian Coca

Iwada Eja

unread,
Sep 22, 2015, 8:12:53 PM9/22/15
to Ansible Project

My goodness!
 Ansible indeed rocks. Issue resolved, plus i understand things better now!
Thanks Guys

Iwada Eja

unread,
Sep 22, 2015, 9:25:26 PM9/22/15
to Ansible Project
For archival Purposes , 

I modified my task thus: 

---
- hosts: 127.0.0.1
  connection: local
  user: root
  tasks:
    - name: Create linode machine
      linode: 
        api_key: 'slsoajsd'
        name: deb
        plan: 1
        datacenter: 7
        distribution: 140
        password: 'sasda'
        #linode_id: '12345678'
        ssh_pub_key: '.....'
        wait: yes
        wait_timeout: 600
        state: present 
      register: linode_return
    - local_action: copy content="{{ linode_return.instance.ipv4 }}" dest=/path/to/file

Was more intrested i getting the ipv4 address of the new instance. You can use

- local_action: copy content="{{ linode_return}}" dest=/path/to/file 

to see the list of all returned values

Brian Coca

unread,
Sep 22, 2015, 9:52:36 PM9/22/15
to Ansible Project
also

- debug: var=linode_return

to just see it on screen




--
Brian Coca
Reply all
Reply to author
Forward
0 new messages