# apt\_key problem on Ubuntu?

**URL:** <https://forum.ansible.com/t/apt-key-problem-on-ubuntu/12858>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [May 23, 2013, 2:03pm UTC](https://forum.ansible.com/t/apt-key-problem-on-ubuntu/12858 "2013-05-23T14:03:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frans\_Kuipers](https://avatars.discourse-cdn.com/v4/letter/f/94ad74/32.png) [@Frans\_Kuipers](https://forum.ansible.com/u/Frans_Kuipers)\
**Post date:** [May 23, 2013, 2:03pm UTC](https://forum.ansible.com/t/apt-key-problem-on-ubuntu/12858/1 "2013-05-23T14:03:56Z")

</div>

In my playbook I have the action:  
apt\_key: url=[https://keyserver.ubuntu.com](https://keyserver.ubuntu.com) id=0xcbcb082a1bb943db state=present

It times out on: _File "/home/vagrant/.ansible/tmp/ansible-1369317219.32-261093913648844/apt\_key", line 104, in download\_key_

When I use this action:  
command: apt-key adv --recv-keys --keyserver [keyserver.ubuntu.com](http://keyserver.ubuntu.com) 0xcbcb082a1bb943db

Is is working well, but then it is always state=changed.

Am I doing something wrong in the apt\_key parameters (the examples are for debian), or is it not working on Ubuntu (12.04)?

– Frans

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [May 23, 2013, 2:09pm UTC](https://forum.ansible.com/t/apt-key-problem-on-ubuntu/12858/2 "2013-05-23T14:09:26Z")

</div>

What version of Ansible are you using and can you please paste the full output of running the apt\_key module?

(The command module is going to return state=changed every time, since you didn’t supply creates= nor removes=. That’s working fine)

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [May 23, 2013, 2:15pm UTC](https://forum.ansible.com/t/apt-key-problem-on-ubuntu/12858/3 "2013-05-23T14:15:38Z")

</div>

​Are you sure about that http url? I'm also getting a timeout​ browsing to  
it. AFAICS they don't support secure http

Also, on the top of my head, I think you need to point the full url to the  
key you need:  
e.g.:

[http://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0xCBCB082A1BB943DB](http://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0xCBCB082A1BB943DB)

The id is only used to check if the key is already present, not to download  
it.

Serge

---

<div class="post-metadata">

**Author:** ![Frans\_Kuipers](https://avatars.discourse-cdn.com/v4/letter/f/94ad74/32.png) [@Frans\_Kuipers](https://forum.ansible.com/u/Frans_Kuipers)\
**Post date:** [May 23, 2013, 3:02pm UTC](https://forum.ansible.com/t/apt-key-problem-on-ubuntu/12858/4 "2013-05-23T15:02:48Z")

</div>

Thanks both for your replies.

I am using ansible 1.2 (development branch from 2 days ago).

Thanks Serge, your reply enalble me to solve my problem. The [keyserver.ubuntu.com](http://keyserver.ubuntu.com) doesn’t support https.

This is working for me now:  
apt\_key: url=[http://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0xCBCB082A1BB943DB](http://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0xCBCB082A1BB943DB) state=present

I tried it with  
apt\_key: url=[http://keyserver.ubuntu.com](http://keyserver.ubuntu.com) id=0xCBCB082A1BB943DB state=present

But then the error is:

> TASK: [General | Install mariaDB apt key.] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> failed: [drupal7.vm3.local] =\> {“cmd”: “apt-key add -”, “failed”: true, “item”: “”, “rc”: 2}  
> stderr: gpg: no valid OpenPGP data found.
> 
> msg: gpg: no valid OpenPGP data found.
> 
> FATAL: all hosts have already failed – aborting

My problem is solved, thanks!  
– Frans
