W3cubDocs

/Ansible

apt_repository - Add and remove APT repositories

Synopsis

Add or remove an APT repositories in Ubuntu and Debian.

Requirements (on host that executes module)

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

Options

parameter required default choices comments
filename
(added in 2.1)
no
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
(added in 1.6)
no 420
The octal mode for newly created files in sources.list.d
repo
yes none
A source string for the repository.
state
no present
  • absent
  • present
A source string state.
update_cache
no yes
  • yes
  • no
Run the equivalent of apt-get update when a change occurs. Cache updates are run after making changes.
validate_certs
(added in 1.8)
no yes
  • yes
  • no
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.

Examples

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

# 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'

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

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

# On Ubuntu target: add nginx stable repository from PPA and install its signing key.
# On Debian target: adding PPA is not available, so it will fail immediately.
apt_repository: repo='ppa:nginx/stable'

Notes

Note

This module works on Debian and Ubuntu.

Note

This module supports Debian Squeeze (version 6) as well as its successors.

Note

This module treats Debian and Ubuntu distributions separately. So PPA could be installed only on Ubuntu machines.

This is a Core Module

For more information on what this means please read Core Modules

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, developing_test_pr and Developing Modules.

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