From 9c40b1b2ffffba9c259c3a0d065b0ba835360437 Mon Sep 17 00:00:00 2001 From: Amin Vakil Date: Fri, 10 Jul 2020 21:12:49 +0430 Subject: [PATCH] Replace filename with file in apt_key (#70492) * Replace filename with file from apt_key check one is internal variable, the other is actual parameter used and required for parameter check. --- ...-replace-filename-with-file-in-apt_key.yml | 2 ++ .../rst/porting_guides/porting_guide_2.11.rst | 2 +- lib/ansible/modules/apt_key.py | 2 +- .../targets/apt_key/tasks/file.yml | 30 +++++++++++++++++++ .../targets/apt_key/tasks/main.yml | 3 ++ test/sanity/ignore.txt | 1 - 6 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/70492-replace-filename-with-file-in-apt_key.yml create mode 100644 test/integration/targets/apt_key/tasks/file.yml diff --git a/changelogs/fragments/70492-replace-filename-with-file-in-apt_key.yml b/changelogs/fragments/70492-replace-filename-with-file-in-apt_key.yml new file mode 100644 index 00000000000..a638dd2edcb --- /dev/null +++ b/changelogs/fragments/70492-replace-filename-with-file-in-apt_key.yml @@ -0,0 +1,2 @@ +bugfixes: + - apt_key - Specifying ``file`` as mutually exclusive with ``data``, ``keyserver``, ``url`` (https://github.com/ansible/ansible/pull/70492). diff --git a/docs/docsite/rst/porting_guides/porting_guide_2.11.rst b/docs/docsite/rst/porting_guides/porting_guide_2.11.rst index d6e1968b493..7768dfc8d8d 100644 --- a/docs/docsite/rst/porting_guides/porting_guide_2.11.rst +++ b/docs/docsite/rst/porting_guides/porting_guide_2.11.rst @@ -37,7 +37,7 @@ No notable changes Modules ======= -No notable changes +* The ``apt_key`` module has explicitly defined ``file`` as mutually exclusive with ``data``, ``keyserver`` and ``url``. They cannot be used together anymore. Modules removed diff --git a/lib/ansible/modules/apt_key.py b/lib/ansible/modules/apt_key.py index d8bb6e15435..40341a5c8bf 100644 --- a/lib/ansible/modules/apt_key.py +++ b/lib/ansible/modules/apt_key.py @@ -274,7 +274,7 @@ def main(): state=dict(type='str', default='present', choices=['absent', 'present']), ), supports_check_mode=True, - mutually_exclusive=(('data', 'filename', 'keyserver', 'url'),), + mutually_exclusive=(('data', 'file', 'keyserver', 'url'),), ) key_id = module.params['id'] diff --git a/test/integration/targets/apt_key/tasks/file.yml b/test/integration/targets/apt_key/tasks/file.yml new file mode 100644 index 00000000000..db66d22617e --- /dev/null +++ b/test/integration/targets/apt_key/tasks/file.yml @@ -0,0 +1,30 @@ +- name: Get Fedora GPG Key + get_url: + url: https://getfedora.org/static/fedora.gpg + dest: /tmp/fedora.gpg + +- name: Run apt_key with both file and keyserver + apt_key: + file: /tmp/fedora.gpg + keyserver: keys.gnupg.net + id: 97A1AE57C3A2372CCA3A4ABA6C13026D12C944D0 + register: both_file_keyserver + ignore_errors: true + +- name: Run apt_key with file only + apt_key: + file: /tmp/fedora.gpg + register: only_file + +- name: Run apt_key with keyserver only + apt_key: + keyserver: keys.gnupg.net + id: 97A1AE57C3A2372CCA3A4ABA6C13026D12C944D0 + register: only_keyserver + +- name: validate results + assert: + that: + - 'both_file_keyserver is failed' + - 'only_file.changed' + - 'not only_keyserver.changed' diff --git a/test/integration/targets/apt_key/tasks/main.yml b/test/integration/targets/apt_key/tasks/main.yml index a268b2b978d..2a6e19e486d 100644 --- a/test/integration/targets/apt_key/tasks/main.yml +++ b/test/integration/targets/apt_key/tasks/main.yml @@ -26,3 +26,6 @@ - include: 'apt_key.yml' when: ansible_distribution in ('Ubuntu', 'Debian') + +- include: 'file.yml' + when: ansible_distribution in ('Ubuntu', 'Debian') diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt index 9952f2c351f..18cf80e6bd1 100644 --- a/test/sanity/ignore.txt +++ b/test/sanity/ignore.txt @@ -107,7 +107,6 @@ lib/ansible/modules/apt.py validate-modules:doc-default-does-not-match-spec lib/ansible/modules/apt.py validate-modules:parameter-invalid lib/ansible/modules/apt.py validate-modules:parameter-type-not-in-doc lib/ansible/modules/apt.py validate-modules:undocumented-parameter -lib/ansible/modules/apt_key.py validate-modules:mutually_exclusive-unknown lib/ansible/modules/apt_key.py validate-modules:parameter-type-not-in-doc lib/ansible/modules/apt_key.py validate-modules:undocumented-parameter lib/ansible/modules/apt_repository.py validate-modules:doc-default-does-not-match-spec