deb822_repository: add include, exclude parameters (#86171)

This commit is contained in:
FestplattenSchnitzel 2025-12-05 18:21:09 +01:00 committed by GitHub
parent ca6dc93dcc
commit e25cc345fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 103 additions and 0 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- deb822_repository - add include and exclude parameter arguments (https://github.com/ansible/ansible/issues/86155)

View file

@ -62,6 +62,22 @@ options:
description:
- Tells APT whether the source is enabled or not.
type: bool
exclude:
description:
- Controls which packages C(APT) should exclude from the repository.
- Mutually exclusive with O(include).
- This option is supported by apt>=3.1.0.
type: list
elements: str
version_added: '2.21'
include:
description:
- Controls which packages C(APT) should use from the repository.
- Mutually exclusive with O(exclude).
- This option is supported by apt>=3.1.0.
type: list
elements: str
version_added: '2.21'
inrelease_path:
description:
- Determines the path to the C(InRelease) file, relative to the normal
@ -419,6 +435,14 @@ def main():
'enabled': {
'type': 'bool',
},
'exclude': {
'elements': 'str',
'type': 'list',
},
'include': {
'elements': 'str',
'type': 'list',
},
'inrelease_path': {
'type': 'str',
},
@ -480,6 +504,9 @@ def main():
'default': 'present',
},
},
mutually_exclusive=[
['exclude', 'include']
],
supports_check_mode=True,
)

View file

@ -34,6 +34,80 @@
name: ansible-test local
state: absent
- block:
- name: Remove repo
deb822_repository:
name: debian
state: absent
- deb822_repository:
name: debian
types: deb
uris: file:{{ repodir }}
suites: stable
components:
- main
architectures: all
exclude:
- foo
trusted: yes
register: deb822_add_repo
- name: Update apt cache
apt:
update_cache: yes
when: deb822_add_repo is changed
- name: Install package from local repo
apt:
name: foo=1.0.0
register: deb822_install_pkg_exclude
ignore_errors: true
- name: Check if package was not installed
shell: dpkg-query -l foo
register: deb822_install_pkg_exclude_result
ignore_errors: true
- assert:
that:
- deb822_install_pkg_exclude is failed
- "'no packages found matching foo' in deb822_install_pkg_exclude_result.stderr"
- deb822_repository:
name: debian
types: deb
uris: file:{{ repodir }}
suites: stable
components:
- main
architectures: all
include:
- foobar
trusted: yes
register: deb822_add_repo
- name: Update apt cache
apt:
update_cache: yes
when: deb822_add_repo is changed
- name: Install package from local repo
apt:
name: foobar=1.0.1
register: deb822_install_pkg_include
- name: Check if package was installed
shell: dpkg-query -l foobar
register: deb822_install_pkg_include_result
when: (ansible_facts["distribution"] == 'Ubuntu' and ansible_facts["distribution_version"] is version('25.10', '>=')) or (ansible_lsb["id"] == 'Debian' and 'sid' in ansible_lsb["description"] )
always:
- name: Remove repo
deb822_repository:
name: debian
state: absent
- assert:
that:
- deb822_install_repo is changed