How do I add apt key by id from a keyserver - Ansible

0 votes

I'm trying to add apt key by id from a keyserver. But I don't exactly know to do this?

Can I have a sample playbook?

Also, I know there is a module called apt_key that I can use, I just don't know to use it. 

Feb 11, 2019 in Ansible by Altis
3,350 views

1 answer to this question.

0 votes

Hey @Altis, you can use the module apt_key. I've given an example, have a look and come back if you need more help

- name: Add an apt key by id from a keyserver
  apt_key:
    keyserver: keyserver.ubuntu.com
    id: 36A1D7869245C8950F966E92D8576A8BA88D21E9

- name: Add an Apt signing key, uses whichever key is at the URL
  apt_key:
    url: https://ftp-master.debian.org/keys/archive-key-6.0.asc
    state: present

- name: Add an Apt signing key, will not download if present
  apt_key:
    id: 473041FA
    url: https://ftp-master.debian.org/keys/archive-key-6.0.asc
    state: present

- name: Remove a Apt specific signing key, leading 0x is valid
  apt_key:
    id: 0x473041FA
    state: absent

# Use armored file since utf-8 string is expected. Must be of "PGP PUBLIC KEY BLOCK" type.
- name: Add a key from a file on the Ansible server.
  apt_key:
    data: "{{ lookup('file', 'apt.asc') }}"
    state: present

- name: Add an Apt signing key to a specific keyring file
  apt_key:
    id: 473041FA
    url: https://ftp-master.debian.org/keys/archive-key-6.0.asc
    keyring: /etc/apt/trusted.gpg.d/debian.gpg

- name: Add Apt signing key on remote server to keyring
  apt_key:
    id: 473041FA
    file: /tmp/apt.gpg
    state: present
answered Feb 11, 2019 by Kyra

Related Questions In Ansible

0 votes
1 answer

How do I wget a file from web server using shell in the ansible playbook

Hey Ayaan, you could probably use this ...READ MORE

answered Jan 24, 2019 in Ansible by Anushri
3,868 views
0 votes
1 answer

How do I execute a shell script and then use the result in ansible

This can work out for you: - name: ...READ MORE

answered Apr 11, 2018 in Ansible by shubham
• 7,340 points
6,512 views
0 votes
1 answer

How do I add ssh authorized keys in ansible playbook?

Hey @kailash use the authorized_key plugin that ...READ MORE

answered Feb 12, 2019 in Ansible by Kyra
1,252 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,520 views
+2 votes
1 answer
0 votes
1 answer

How do I get an ENV variable and store it into a local variable - Ansible

Hey @Ninja, that is possible. What you ...READ MORE

answered Jan 24, 2019 in Ansible by Thomas
2,005 views
0 votes
1 answer

How do I get a list of all Ansible variables?

Ansible by default gathers facts about machines ...READ MORE

answered Jan 31, 2019 in Ansible by Mahir
5,623 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP