ansible.builtin.apt_repository (v2.6.2) — module

Add and remove APT repositories

| "added in version" 0.7 of ansible.builtin"

Authors: Alexander Saltanov (@sashka)

preview | supported by core

Install Ansible via pip

Install with pip install ansible==2.6.2

Description

Add or remove an APT repositories in Ubuntu and Debian.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Add specified repository into sources list.
- apt_repository:
    repo: deb http://archive.canonical.com/ubuntu hardy partner
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Add specified repository into sources list using specified filename.
- apt_repository:
    repo: deb http://dl.google.com/linux/chrome/deb/ stable main
    state: present
    filename: google-chrome
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Add source repository into sources list.
- apt_repository:
    repo: deb-src http://archive.canonical.com/ubuntu hardy partner
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Remove specified repository from sources list.
- apt_repository:
    repo: deb http://archive.canonical.com/ubuntu hardy partner
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Add nginx stable repository from PPA and install its signing key.
# On Ubuntu target:
- apt_repository:
    repo: ppa:nginx/stable
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# On Debian target
- apt_repository:
    repo: 'ppa:nginx/stable'
    codename: trusty

Inputs

    
mode:
    default: '0644'
    description:
    - The octal mode for newly created files in sources.list.d
    version_added: '1.6'
    version_added_collection: ansible.builtin

repo:
    description:
    - A source string for the repository.
    required: true

state:
    choices:
    - absent
    - present
    default: present
    description:
    - A source string state.

codename:
    description:
    - Override the distribution codename to use for PPA repositories. Should usually only
      be set when working with a PPA on a non-Ubuntu target (e.g. Debian or Mint)
    version_added: '2.3'
    version_added_collection: ansible.builtin

filename:
    description:
    - Sets the name of the source list file in sources.list.d. Defaults to a file name
      based on the repository source url. The .list extension will be automatically added.
    version_added: '2.1'
    version_added_collection: ansible.builtin

update_cache:
    default: 'yes'
    description:
    - Run the equivalent of C(apt-get update) when a change occurs.  Cache updates are
      run after making changes.
    type: bool

validate_certs:
    default: 'yes'
    description:
    - If C(no), SSL certificates for the target repo will not be validated. This should
      only be used on personally controlled sites using self-signed certificates.
    type: bool
    version_added: '1.8'
    version_added_collection: ansible.builtin