apt_key problem on Ubuntu?

In my playbook I have the action:
apt_key: url=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 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

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)

​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

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

Serge

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 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 state=present

I tried it with
apt_key: url=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