# Wrong Linode ID with the linode Module

**URL:** <https://forum.ansible.com/t/wrong-linode-id-with-the-linode-module/19323>\
**Category:** Ansible Project\
**Created:** [September 22, 2015, 2:30am UTC](https://forum.ansible.com/t/wrong-linode-id-with-the-linode-module/19323 "2015-09-22T02:30:13Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iwada\_Eja](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@Iwada\_Eja](https://forum.ansible.com/u/Iwada_Eja)\
**Post date:** [September 22, 2015, 2:30am UTC](https://forum.ansible.com/t/wrong-linode-id-with-the-linode-module/19323/1 "2015-09-22T02:30:13Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Patrick\_Heeney](https://avatars.discourse-cdn.com/v4/letter/p/f475e1/32.png) [@Patrick\_Heeney](https://forum.ansible.com/u/Patrick_Heeney)\
**Post date:** [September 22, 2015, 5:28pm UTC](https://forum.ansible.com/t/wrong-linode-id-with-the-linode-module/19323/2 "2015-09-22T17:28:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Greg\_DeKoenigsberg1](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@Greg\_DeKoenigsberg1](https://forum.ansible.com/u/Greg_DeKoenigsberg1)\
**Post date:** [September 22, 2015, 5:59pm UTC](https://forum.ansible.com/t/wrong-linode-id-with-the-linode-module/19323/3 "2015-09-22T17:59:39Z")

</div>

> 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](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

---

<div class="post-metadata">

**Author:** ![Iwada\_Eja](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@Iwada\_Eja](https://forum.ansible.com/u/Iwada_Eja)\
**Post date:** [September 22, 2015, 6:45pm UTC](https://forum.ansible.com/t/wrong-linode-id-with-the-linode-module/19323/4 "2015-09-22T18:45:18Z")

</div>

Thanks for the reply. Would use the work around.

Also created an Issue on this as none existed.

---

<div class="post-metadata">

**Author:** ![Iwada\_Eja](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@Iwada\_Eja](https://forum.ansible.com/u/Iwada_Eja)\
**Post date:** [September 22, 2015, 9:29pm UTC](https://forum.ansible.com/t/wrong-linode-id-with-the-linode-module/19323/5 "2015-09-22T21:29:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [September 22, 2015, 10:17pm UTC](https://forum.ansible.com/t/wrong-linode-id-with-the-linode-module/19323/6 "2015-09-22T22:17:04Z")

</div>

register: linode\_return

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

---

<div class="post-metadata">

**Author:** ![Patrick\_Heeney](https://avatars.discourse-cdn.com/v4/letter/p/f475e1/32.png) [@Patrick\_Heeney](https://forum.ansible.com/u/Patrick_Heeney)\
**Post date:** [September 22, 2015, 10:19pm UTC](https://forum.ansible.com/t/wrong-linode-id-with-the-linode-module/19323/7 "2015-09-22T22:19:43Z")

</div>

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 wrote:

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [September 22, 2015, 10:22pm UTC](https://forum.ansible.com/t/wrong-linode-id-with-the-linode-module/19323/8 "2015-09-22T22:22:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Iwada\_Eja](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@Iwada\_Eja](https://forum.ansible.com/u/Iwada_Eja)\
**Post date:** [September 23, 2015, 12:12am UTC](https://forum.ansible.com/t/wrong-linode-id-with-the-linode-module/19323/9 "2015-09-23T00:12:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Iwada\_Eja](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@Iwada\_Eja](https://forum.ansible.com/u/Iwada_Eja)\
**Post date:** [September 23, 2015, 1:25am UTC](https://forum.ansible.com/t/wrong-linode-id-with-the-linode-module/19323/10 "2015-09-23T01:25:26Z")

</div>

For archival Purposes ,

I modified my task thus:

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [September 23, 2015, 1:52am UTC](https://forum.ansible.com/t/wrong-linode-id-with-the-linode-module/19323/11 "2015-09-23T01:52:25Z")

</div>

also

- debug: var=linode\_return

to just see it on screen
