# Can't get gpg key accepted automatically for new repo on CentOS 7

**URL:** <https://forum.ansible.com/t/cant-get-gpg-key-accepted-automatically-for-new-repo-on-centos-7/23746>\
**Category:** Ansible Project\
**Created:** [February 16, 2017, 4:23pm UTC](https://forum.ansible.com/t/cant-get-gpg-key-accepted-automatically-for-new-repo-on-centos-7/23746 "2017-02-16T16:23:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luke2](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@luke2](https://forum.ansible.com/u/luke2)\
**Post date:** [February 16, 2017, 4:23pm UTC](https://forum.ansible.com/t/cant-get-gpg-key-accepted-automatically-for-new-repo-on-centos-7/23746/1 "2017-02-16T16:23:04Z")

</div>

Here’s the play I’ve tried:

`

- hosts: eliza  
tags:
- grafana  
roles:
- role: service\_restart

tasks:

- name: Add grafana repository  
yum\_repository:  
name: grafana  
description: grafana  
baseurl: [https://packagecloud.io/grafana/stable/el/6/$basearch](https://packagecloud.io/grafana/stable/el/6/$basearch)  
gpgcheck: True  
repo\_gpgcheck: True  
gpgkey: [https://packagecloud.io/gpg.key](https://packagecloud.io/gpg.key) [https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana](https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana)  
sslcacert: /etc/pki/tls/certs/ca-bundle.crt

- rpm\_key:  
state: present  
key: “{{ item }}”  
with\_items:

- [https://packagecloud.io/gpg.key](https://packagecloud.io/gpg.key)

- [https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana](https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana)

- name: Install grafana  
package:  
name: grafana

`

This results is:

`

[vagrant@jolly ansible-repo]$ ./run-ansible-vagrant playbooks/prometheus/grafana.yml

PLAY [eliza] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [eliza]

TASK [Add grafana repository] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [eliza]

TASK [rpm\_key] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [eliza] =\> (item=[https://packagecloud.io/gpg.key](https://packagecloud.io/gpg.key))  
changed: [eliza] =\> (item=[https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana](https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana))

TASK [Install grafana] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [eliza]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: “Failure talking to yum: failure: repodata/repomd.xml from grafana: [Errno 256] No more mirrors to try.\n[https://packagecloud.io/grafana/stable/el/6/x86\_64/repodata/repomd.xml:](https://packagecloud.io/grafana/stable/el/6/x86_64/repodata/repomd.xml:) [Errno -1] repomd.xml signature could not be verified for grafana”}

NO MORE HOSTS LEFT \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
eliza : ok=3 changed=2 unreachable=0 failed=1

[vagrant@jolly ansible-repo]$

`

If I run ‘yum -y install grafana’ it works and accepts the gpg keys. How am I supposed to do this correctly in ansible?

---

<div class="post-metadata">

**Author:** ![luke2](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@luke2](https://forum.ansible.com/u/luke2)\
**Post date:** [March 28, 2017, 9:41pm UTC](https://forum.ansible.com/t/cant-get-gpg-key-accepted-automatically-for-new-repo-on-centos-7/23746/2 "2017-03-28T21:41:38Z")

</div>

There’s a issue open for this exact case: [https://github.com/ansible/ansible/issues/20711](https://github.com/ansible/ansible/issues/20711)
