mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 14:41:23 -07:00
apt_key: PEP8 compliancy and documentation changes (#33427)
This PR includes: - PEP8 compliancy changes - Documentation changes
This commit is contained in:
parent
84ace7acc3
commit
c4ef5bb922
2 changed files with 26 additions and 27 deletions
|
@ -23,9 +23,9 @@ short_description: Add or remove an apt key
|
||||||
description:
|
description:
|
||||||
- Add or remove an I(apt) key, optionally downloading it.
|
- Add or remove an I(apt) key, optionally downloading it.
|
||||||
notes:
|
notes:
|
||||||
- doesn't download the key unless it really needs it
|
- Doesn't download the key unless it really needs it.
|
||||||
- as a sanity check, downloaded key id must match the one specified
|
- As a sanity check, downloaded key id must match the one specified.
|
||||||
- best practice is to specify the key id and the url
|
- Best practice is to specify the key id and the URL.
|
||||||
options:
|
options:
|
||||||
id:
|
id:
|
||||||
description:
|
description:
|
||||||
|
@ -41,7 +41,7 @@ options:
|
||||||
- The path to a keyfile on the remote server to add to the keyring.
|
- The path to a keyfile on the remote server to add to the keyring.
|
||||||
keyring:
|
keyring:
|
||||||
description:
|
description:
|
||||||
-The path to specific keyring file in /etc/apt/trusted.gpg.d/
|
- The path to specific keyring file in /etc/apt/trusted.gpg.d/
|
||||||
version_added: "1.3"
|
version_added: "1.3"
|
||||||
url:
|
url:
|
||||||
description:
|
description:
|
||||||
|
@ -121,7 +121,7 @@ def find_needed_binaries(module):
|
||||||
|
|
||||||
apt_key_bin = module.get_bin_path('apt-key', required=True)
|
apt_key_bin = module.get_bin_path('apt-key', required=True)
|
||||||
|
|
||||||
### FIXME: Is there a reason that gpg and grep are checked? Is it just
|
# FIXME: Is there a reason that gpg and grep are checked? Is it just
|
||||||
# cruft or does the apt .deb package not require them (and if they're not
|
# cruft or does the apt .deb package not require them (and if they're not
|
||||||
# installed, /usr/bin/apt-key fails?)
|
# installed, /usr/bin/apt-key fails?)
|
||||||
module.get_bin_path('gpg', required=True)
|
module.get_bin_path('gpg', required=True)
|
||||||
|
@ -174,7 +174,7 @@ def all_keys(module, keyring, short_format):
|
||||||
results = []
|
results = []
|
||||||
lines = to_native(out).split('\n')
|
lines = to_native(out).split('\n')
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if (line.startswith("pub") or line.startswith("sub")) and not "expired" in line:
|
if (line.startswith("pub") or line.startswith("sub")) and "expired" not in line:
|
||||||
tokens = line.split()
|
tokens = line.split()
|
||||||
code = tokens[1]
|
code = tokens[1]
|
||||||
(len_type, real_code) = code.split("/")
|
(len_type, real_code) = code.split("/")
|
||||||
|
@ -261,28 +261,28 @@ def remove_key(module, key_id, keyring):
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
id=dict(required=False, default=None),
|
id=dict(type='str'),
|
||||||
url=dict(required=False),
|
url=dict(type='str'),
|
||||||
data=dict(required=False),
|
data=dict(type='str'),
|
||||||
file=dict(required=False, type='path'),
|
file=dict(type='path'),
|
||||||
key=dict(required=False),
|
key=dict(type='str'),
|
||||||
keyring=dict(required=False, type='path'),
|
keyring=dict(type='path'),
|
||||||
validate_certs=dict(default='yes', type='bool'),
|
validate_certs=dict(type='bool', default=True),
|
||||||
keyserver=dict(required=False),
|
keyserver=dict(type='str'),
|
||||||
state=dict(required=False, choices=['present', 'absent'], default='present')
|
state=dict(type='str', default='present', choices=['absent', 'present']),
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
mutually_exclusive=(('filename', 'keyserver', 'data', 'url'),),
|
mutually_exclusive=(('data', 'filename', 'keyserver', 'url'),),
|
||||||
)
|
)
|
||||||
|
|
||||||
key_id = module.params['id']
|
key_id = module.params['id']
|
||||||
url = module.params['url']
|
url = module.params['url']
|
||||||
data = module.params['data']
|
data = module.params['data']
|
||||||
filename = module.params['file']
|
filename = module.params['file']
|
||||||
keyring = module.params['keyring']
|
keyring = module.params['keyring']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
keyserver = module.params['keyserver']
|
keyserver = module.params['keyserver']
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
fingerprint = short_key_id = key_id
|
fingerprint = short_key_id = key_id
|
||||||
short_format = False
|
short_format = False
|
||||||
|
@ -304,7 +304,7 @@ def main():
|
||||||
if fingerprint and fingerprint in keys:
|
if fingerprint and fingerprint in keys:
|
||||||
module.exit_json(changed=False)
|
module.exit_json(changed=False)
|
||||||
elif fingerprint and fingerprint not in keys and module.check_mode:
|
elif fingerprint and fingerprint not in keys and module.check_mode:
|
||||||
### TODO: Someday we could go further -- write keys out to
|
# TODO: Someday we could go further -- write keys out to
|
||||||
# a temporary file and then extract the key id from there via gpg
|
# a temporary file and then extract the key id from there via gpg
|
||||||
# to decide if the key is installed or not.
|
# to decide if the key is installed or not.
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
|
@ -322,7 +322,7 @@ def main():
|
||||||
changed = False
|
changed = False
|
||||||
keys2 = all_keys(module, keyring, short_format)
|
keys2 = all_keys(module, keyring, short_format)
|
||||||
if len(keys) != len(keys2):
|
if len(keys) != len(keys2):
|
||||||
changed=True
|
changed = True
|
||||||
|
|
||||||
if fingerprint and fingerprint not in keys2:
|
if fingerprint and fingerprint not in keys2:
|
||||||
module.fail_json(msg="key does not seem to have been added", id=key_id)
|
module.fail_json(msg="key does not seem to have been added", id=key_id)
|
||||||
|
|
|
@ -258,7 +258,6 @@ lib/ansible/modules/packaging/language/gem.py
|
||||||
lib/ansible/modules/packaging/language/maven_artifact.py
|
lib/ansible/modules/packaging/language/maven_artifact.py
|
||||||
lib/ansible/modules/packaging/language/pear.py
|
lib/ansible/modules/packaging/language/pear.py
|
||||||
lib/ansible/modules/packaging/os/apk.py
|
lib/ansible/modules/packaging/os/apk.py
|
||||||
lib/ansible/modules/packaging/os/apt_key.py
|
|
||||||
lib/ansible/modules/packaging/os/apt_repository.py
|
lib/ansible/modules/packaging/os/apt_repository.py
|
||||||
lib/ansible/modules/packaging/os/dpkg_selections.py
|
lib/ansible/modules/packaging/os/dpkg_selections.py
|
||||||
lib/ansible/modules/packaging/os/homebrew.py
|
lib/ansible/modules/packaging/os/homebrew.py
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue