Skip to content

Instantly share code, notes, and snippets.

@tomwalsh
Created October 23, 2023 14:29
Show Gist options
  • Save tomwalsh/91fe0c5b579c2687f053a1d9447dd2f6 to your computer and use it in GitHub Desktop.
Save tomwalsh/91fe0c5b579c2687f053a1d9447dd2f6 to your computer and use it in GitHub Desktop.
Ansible playbook checking for docker.gpg on Ubuntu
- name: Check for the Docker GPG key
stat:
path: /etc/apt/trusted.gpg.d/docker.gpg
register: docker_key
- name: Download the Docker GPG key
get_url:
url: https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg
dest: "/tmp/docker.gpg"
mode: '0777'
when: not docker_key.stat.exists
- name: Install the Docker GPG key
command:
cmd: "gpg --dearmor -o /etc/apt/trusted.gpg.d/docker.gpg /tmp/docker.gpg"
when: not docker_key.stat.exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment