apt_repository - Add and remove APT repositories

Author:Alexander Saltanov

Synopsis

Add or remove an APT repositories in Ubuntu and Debian.

Options

parameter required default choices comments
mode no 420
    The octal mode for newly created files in sources.list.d (added in Ansible 1.6)
    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 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.

      Note

      Requires python-apt

      Examples


      # Add specified repository into sources list.
      apt_repository: repo='deb http://archive.canonical.com/ubuntu hardy partner' state=present
      
      # 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'

      Note

      This module works on Debian and Ubuntu and requires python-apt.

      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.

      Table Of Contents

      Previous topic

      apt_key - Add or remove an apt key

      Next topic

      apt_rpm - apt_rpm package manager