Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add a PPA repository using Ansible?

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   
like image 992
Salim Fadhley Avatar asked Mar 28 '15 16:03

Salim Fadhley


People also ask

How do I manually add PPA repository?

In the APT line field, put the name of the PPA you want to add and then click the Add Source button. The system will then ask you for authentication as only an authorized user can add a repository to Ubuntu. Enter the password for sudo and then click Authenticate.

What is Ansible PPA repository?

PPA description Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.

What is Sudo add-APT-repository PPA?

sudo add-apt-repository <PPA_info> <– This command adds the PPA repository to the list. sudo apt-get update <– This command updates the list of the packages that can be installed on the system.

Where is add-APT-repository?

The add-apt-repository command is included in the software-properties-common package, and the error occurs due to the absence of this package. We can fix this error by installing the software-properties-common package.


1 Answers

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
like image 125
Maycon Vinicius Avatar answered Sep 21 '22 10:09

Maycon Vinicius