11

I'm trying to add a new repository to a server so that I can install Java by Ansible. Unfortunately whenever I try to run the playbook it fails because of a GPG error. Can somebody explain what is going wrong here and what I need to do in order to fix this?

I'm using Ansible 1.7.2 and currently only connecting to localhost.

I have a very simple Playbook that looks like this:

- hosts: home
  tasks:
   - name: Add repositories
     apt_repository: repo='ppa:webupd8team/java' state=present

When I try to execute it, I get the following error:

sal@bobnit:~/Workspace$ ansible-playbook --ask-sudo-pass basic.yml 
sudo password: 

PLAY [home] ******************************************************************* 

GATHERING FACTS *************************************************************** 
ok: [localhost]

TASK: [Add repositories] ****************************************************** 
failed: [localhost] => {"cmd": "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 7B2C3B0889BF5709A105D03AC2518248EEA14886", "failed": true, "rc": 2}
stderr: gpg: requesting key EEA14886 from hkp server keyserver.ubuntu.com
gpg: no writable keyring found: eof
gpg: error reading `[stream]': general error
gpg: Total number processed: 0

stdout: Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.HKDOSZnVQP --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/steam.gpg --keyring /etc/apt/trusted.gpg.d/ubuntu-x-swat_ubuntu_x-updates.gpg --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 7B2C3B0889BF5709A105D03AC2518248EEA14886

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

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/sal/basic.retry

localhost                  : ok=1    changed=0    unreachable=0    failed=1   
1
  • 3
    You found your answer, so some tips: apt_repository is great, it's a good idea to use apt_key too. If you are installing from that repo right after, use update_cache=yes in the apt_repository arguments. Mar 28, 2015 at 21:12

2 Answers 2

9

Use a option validate_certs with no

  - name: Adicionando PPA do php 7.1
    apt_repository:
      validate_certs: no
      repo: 'ppa:ondrej/php'
      state: present
2

Oh, this seems to have been entirely caused by me forgetting the -s option!

Without this it wasn't using sudo.

3
  • 6
    where did you added the '-s' option?
    – squiter
    Nov 30, 2015 at 22:02
  • In my playbook I use sudo: yes in the task itself.
    – Robert
    Aug 7, 2016 at 20:02
  • 2
    Just a note for future Ansible versions - if sudo: yes doesn't work for you, try the become : yes Sep 8, 2016 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.