ansible / ansible.builtin / v2.16.5 / module / apt_repository Add and remove APT repositories | "added in version" 0.7 of ansible.builtin" Authors: Alexander Saltanov (@sashka)ansible.builtin.apt_repository (v2.16.5) — module
pip
Install with pip install ansible-core==2.16.5
Add or remove an APT repositories in Ubuntu and Debian.
- name: Add specified repository into sources list ansible.builtin.apt_repository: repo: deb http://archive.canonical.com/ubuntu hardy partner state: present
- name: Add specified repository into sources list using specified filename ansible.builtin.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 ansible.builtin.apt_repository: repo: deb-src http://archive.canonical.com/ubuntu hardy partner state: present
- name: Remove specified repository from sources list ansible.builtin.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 ansible.builtin.apt_repository: repo: ppa:nginx/stable
- name: Add nginx stable repository from PPA and install its signing key on Debian target ansible.builtin.apt_repository: repo: 'ppa:nginx/stable' codename: trusty
- name: One way to avoid apt_key once it is removed from your distro block: - name: somerepo |no apt key ansible.builtin.get_url: url: https://download.example.com/linux/ubuntu/gpg dest: /etc/apt/keyrings/somerepo.asc - name: somerepo | apt source ansible.builtin.apt_repository: repo: "deb [arch=amd64 signed-by=/etc/apt/keyrings/myrepo.asc] https://download.example.com/linux/ubuntu {{ ansible_distribution_release }} stable" state: present
mode: description: - The octal mode for newly created files in sources.list.d. - Default is what system uses (probably 0644). type: raw version_added: '1.6' version_added_collection: ansible.builtin repo: description: - A source string for the repository. required: true type: str state: choices: - absent - present default: present description: - A source string state. type: str 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 (for example, Debian or Mint). type: str 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. type: str version_added: '2.1' version_added_collection: ansible.builtin update_cache: aliases: - 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 V(false), 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 install_python_apt: default: true description: - Whether to automatically try to install the Python apt library or not, if it is not already installed. Without this library, the module does not work. - Runs C(apt-get install python-apt) for Python 2, and C(apt-get install python3-apt) for Python 3. - Only works with the system Python 2 or Python 3. If you are using a Python on the remote that is not the system Python, set O(install_python_apt=false) and ensure that the Python apt library for your Python version is installed some other way. type: bool update_cache_retries: default: 5 description: - Amount of retries if the cache update fails. Also see O(update_cache_retry_max_delay). type: int version_added: '2.10' version_added_collection: ansible.builtin update_cache_retry_max_delay: default: 12 description: - Use an exponential backoff delay for each retry (see O(update_cache_retries)) up to this max delay in seconds. type: int version_added: '2.10' version_added_collection: ansible.builtin
repo: description: A source string for the repository returned: always sample: deb https://artifacts.elastic.co/packages/6.x/apt stable main type: str sources_added: description: List of sources added returned: success, sources were added sample: - /etc/apt/sources.list.d/artifacts_elastic_co_packages_6_x_apt.list type: list version_added: '2.15' version_added_collection: ansible.builtin sources_removed: description: List of sources removed returned: success, sources were removed sample: - /etc/apt/sources.list.d/artifacts_elastic_co_packages_6_x_apt.list type: list version_added: '2.15' version_added_collection: ansible.builtin