W3cubDocs

/Ansible 2.10

ansible.builtin.apt_repository – Add and remove APT repositories

Note

This module is part of ansible-base and included in all Ansible installations. In most cases, you can use the short module name apt_repository even without specifying the collections: keyword. Despite that, we recommend you use the FQCN for easy linking to the module documentation and to avoid conflicting with other collections that may have the same module name.

New in version 0.7: of ansible.builtin

Synopsis

  • Add or remove an APT repositories in Ubuntu and Debian.

Requirements

The below requirements are needed on the host that executes this module.

  • python-apt (python 2)
  • python3-apt (python 3)

Parameters

Parameter Choices/Defaults Comments
codename
string
added in 2.3 of ansible.builtin
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)
filename
string
added in 2.1 of ansible.builtin
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.
mode
string
added in 1.6 of ansible.builtin
Default:
"0644"
The octal mode for newly created files in sources.list.d
repo
string / required
A source string for the repository.
state
string
    Choices:
  • absent
  • present
A source string state.
update_cache
boolean
    Choices:
  • no
  • yes
Run the equivalent of apt-get update when a change occurs. Cache updates are run after making changes.
update_cache_retries
integer
added in 2.10 of ansible.builtin
Default:
5
Amount of retries if the cache update fails. Also see update_cache_retry_max_delay.
update_cache_retry_max_delay
integer
added in 2.10 of ansible.builtin
Default:
12
Use an exponential backoff delay for each retry (see update_cache_retries) up to this max delay in seconds.
validate_certs
boolean
added in 1.8 of ansible.builtin
    Choices:
  • no
  • yes
If no, SSL certificates for the target repo will not be validated. This should only be used on personally controlled sites using self-signed certificates.

Notes

Note

  • This module works on Debian, Ubuntu and their derivatives.
  • This module supports Debian Squeeze (version 6) as well as its successors.

Examples

- name: Add specified repository into sources list
  apt_repository:
    repo: deb http://archive.canonical.com/ubuntu hardy partner
    state: present

- name: 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

- name: Add source repository into sources list
  apt_repository:
    repo: deb-src http://archive.canonical.com/ubuntu hardy partner
    state: present

- name: Remove specified repository from sources list
  apt_repository:
    repo: deb http://archive.canonical.com/ubuntu hardy partner
    state: absent

- name: Add nginx stable repository from PPA and install its signing key on Ubuntu target
  apt_repository:
    repo: ppa:nginx/stable

- name: Add nginx stable repository from PPA and install its signing key on Debian target
  apt_repository:
    repo: 'ppa:nginx/stable'
    codename: trusty

Authors

  • Alexander Saltanov (@sashka)

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.10/collections/ansible/builtin/apt_repository_module.html