How to add apt key with --recv-keys instead of --recv?

8.1k views Asked by At

I want to install facebook osquery with ansible. The instructions for ubuntu are as follows:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C9D8B80B
...

Unfortunately setting the id to C9D8B80B doesn't work. In tasks:

- name: Add repository key
  apt_key: keyserver=keyserver.ubuntu.com id=C9D8B80B state=present

The command fails:

TASK: [osquery | Add repository key] ****************************************** 
failed: [x.x.x.x] => {"cmd": "apt-key adv --keyserver keyserver.ubuntu.com --recv C9D8B80B", "failed": true, "rc": 2}

The difference is --recv C9D8B80B vs --recv-keys C9D8B80B.

Which ansible apt_key option corresponds to --recv-keys?

1

There are 1 answers

1
AJcodez On BEST ANSWER

Nevermind, it was a sudo issue. Presumably --recv and --recv-key and --recv-keys are the same option.

The full stack trace is:

stderr: gpg: requesting key C9D8B80B from hkp server keyserver.ubuntu.com
gpg: no writable keyring found: eof
gpg: error reading `[stream]': general error
gpg: Total number processed: 0

To fix added sudo: yes to playbook.