Skip to content

Instantly share code, notes, and snippets.

@zztopper
Forked from roib20/apt-repo-playbook.yaml
Last active May 20, 2025 12:43
Show Gist options
  • Select an option

  • Save zztopper/120cc57ecb48fb5c4708c965a8cbcfd1 to your computer and use it in GitHub Desktop.

Select an option

Save zztopper/120cc57ecb48fb5c4708c965a8cbcfd1 to your computer and use it in GitHub Desktop.
Example usages of the new `deb822_repository` Ansible module
---
- hosts: localhost
connection: local
gather_facts: true
tasks:
- name: Add APT repositories
when: ansible_os_family == 'Debian'
become: true
block:
- name: Add VSCode APT repository
ansible.builtin.deb822_repository:
name: vscode
types: [deb]
uris: "https://packages.microsoft.com/repos/code"
signed_by: "https://packages.microsoft.com/keys/microsoft.asc"
suites: [stable]
components: [main]
state: present
enabled: yes
- name: Add google APT repository
ansible.builtin.deb822_repository:
name: google
types: [deb]
uris:
- "http://dl.google.com/linux/chrome/deb"
- "http://dl.google.com/linux/earth/deb"
signed_by: "https://dl.google.com/linux/linux_signing_key.pub"
suites: [stable]
components: [main]
state: present
enabled: yes
- name: Add Kubernetes APT repository
ansible.builtin.deb822_repository:
name: kubernetes
types: [deb]
uris: "https://apt.kubernetes.io"
signed_by: "https://packages.cloud.google.com/apt/doc/apt-key.gpg"
suites: [kubernetes-xenial]
components: [main]
state: present
enabled: yes
- name: Add google-cloud-cli APT repository
ansible.builtin.deb822_repository:
name: google-cloud-cli
types: [deb]
uris: "https://packages.cloud.google.com/apt"
signed_by: "https://packages.cloud.google.com/apt/doc/apt-key.gpg"
suites: [cloud-sdk]
components: [main]
state: present
enabled: yes
- name: Add Microsoft prod APT repository (Debian)
when: ansible_distribution == 'Debian'
ansible.builtin.deb822_repository:
name: packages-microsoft-com-prod
types: [deb]
uris: "https://packages.microsoft.com/{{ ansible_distribution|lower }}/{{ ansible_distribution_major_version }}/prod"
signed_by: "https://packages.microsoft.com/keys/microsoft.asc"
suites: ["{{ ansible_distribution_release|lower }}"]
components: [main]
state: present
enabled: yes
- name: Add Microsoft prod APT repository (Ubuntu)
when: ansible_distribution == 'Ubuntu'
ansible.builtin.deb822_repository:
name: packages-microsoft-com-prod
types: [deb]
uris: "https://packages.microsoft.com/{{ ansible_distribution|lower }}/{{ ansible_distribution_version }}/prod"
signed_by: "https://packages.microsoft.com/keys/microsoft.asc"
suites: ["{{ ansible_distribution_release|lower }}"]
components: [main]
state: present
enabled: yes
- name: Add Tailscale stable APT repository
ansible.builtin.deb822_repository:
name: tailscale-stable
types: [deb]
uris: "https://pkgs.tailscale.com/stable/{{ ansible_distribution|lower }}"
signed_by: "https://pkgs.tailscale.com/stable/{{ ansible_distribution|lower }}/{{ ansible_distribution_release|lower }}.asc"
suites: ["{{ ansible_distribution_release|lower }}"]
components: [main]
state: present
enabled: yes
- name: Add Hashicorp Stable APT repository
ansible.builtin.deb822_repository:
name: hashicorp
types: [deb]
uris: "https://apt.releases.hashicorp.com"
signed_by: "https://apt.releases.hashicorp.com/gpg"
suites: ["{{ ansible_distribution_release|lower }}"]
components: [main]
state: present
enabled: yes
- name: Add Docker Module Repository
ansible.builtin.deb822_repository:
name: docker
types: [deb]
uris: "https://download.docker.com/linux/{{ ansible_distribution | lower }}"
signed_by: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg"
suites: ["{{ ansible_distribution_release | lower }}"]
components: [stable]
state: present
enabled: yes
- name: Add Proxmox Repository.
ansible.builtin.deb822_repository:
name: proxmox
types: [deb]
architectures: amd64
uris: "http://download.proxmox.com/{{ ansible_distribution | lower }}/pve"
signed_by: "https://enterprise.proxmox.com/{{ ansible_distribution | lower }}/proxmox-release-{{ ansible_distribution_release | lower }}.gpg"
suites: ["{{ ansible_distribution_release | lower }}"]
components: [pve-no-subscription]
state: present
enabled: true
- name: Add Gitlab Repository.
ansible.builtin.deb822_repository:
name: gitlab
types: [deb]
uris: "https://packages.gitlab.com/gitlab/gitlab-ee/{{ ansible_distribution | lower }}"
signed_by: "https://packages.gitlab.com/gitlab/gitlab-ee/gpgkey"
suites: ["{{ ansible_distribution_release | lower }}"]
components: [main]
state: present
enabled: true
- name: Add Gitlab Runner Repository.
ansible.builtin.deb822_repository:
name: gitlab-runner
types: [deb]
uris: "https://packages.gitlab.com/runner/gitlab-runner/{{ ansible_distribution | lower }}"
signed_by: "https://packages.gitlab.com/runner/gitlab-runner/gpgkey"
suites: ["{{ ansible_distribution_release | lower }}"]
components: [main]
state: present
enabled: true
- name: Add Kubernetes APT repository
ansible.builtin.deb822_repository:
name: kubernetes
types: [deb]
uris: "https://pkgs.k8s.io/core:/stable:/v1.29/deb/"
signed_by: "https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key"
suites: [/]
state: present
enabled: yes
- name: Add Docker APT repository
ansible.builtin.deb822_repository:
name: docker
state: present
types: [deb]
uris: "https://download.docker.com/linux/{{ ansible_distribution|lower }}"
suites: ["{{ ansible_distribution_release|lower }}"]
components: [stable]
signed_by: "https://download.docker.com/linux/debian/gpg"
enabled: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment