From 864c2591b6f0861321009e89462d1baaef9ea39a Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 21 Jan 2022 12:48:42 -0500 Subject: [PATCH] Use explicit keyword for plugin config (#75158) * go back to keyword being explicit for plugin configs instead of using option name as implicit match * switch spec to singular, no changes needed since no one used --- lib/ansible/cli/doc.py | 2 +- lib/ansible/config/manager.py | 6 ++++++ lib/ansible/plugins/become/runas.py | 4 ++++ lib/ansible/plugins/become/su.py | 6 ++++++ lib/ansible/plugins/become/sudo.py | 6 ++++++ lib/ansible/plugins/connection/paramiko_ssh.py | 2 ++ lib/ansible/plugins/connection/psrp.py | 4 ++++ lib/ansible/plugins/connection/ssh.py | 4 ++++ lib/ansible/plugins/connection/winrm.py | 4 ++++ lib/ansible/plugins/doc_fragments/shell_common.py | 2 ++ lib/ansible/plugins/doc_fragments/shell_windows.py | 2 ++ 11 files changed, 41 insertions(+), 1 deletion(-) diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py index c264aff4fcb..d46120b49db 100755 --- a/lib/ansible/cli/doc.py +++ b/lib/ansible/cli/doc.py @@ -1069,7 +1069,7 @@ class DocCLI(CLI, RoleMixin): suboptions.append((subkey, opt.pop(subkey))) conf = {} - for config in ('env', 'ini', 'yaml', 'vars', 'keywords'): + for config in ('env', 'ini', 'yaml', 'vars', 'keyword'): if config in opt and opt[config]: # Create a copy so we don't modify the original (in case YAML anchors have been used) conf[config] = [dict(item) for item in opt.pop(config)] diff --git a/lib/ansible/config/manager.py b/lib/ansible/config/manager.py index 2f09cfa3a9b..fe56c063e8f 100644 --- a/lib/ansible/config/manager.py +++ b/lib/ansible/config/manager.py @@ -462,6 +462,12 @@ class ConfigManager(object): origin = 'var: %s' % origin # use playbook keywords if you have em + if value is None and defs[config].get('keyword') and keys: + value, origin = self._loop_entries(keys, defs[config]['keyword']) + origin = 'keyword: %s' % origin + + # automap to keywords + # TODO: deprecate these in favor of explicit keyword above if value is None and keys: if config in keys: value = keys[config] diff --git a/lib/ansible/plugins/become/runas.py b/lib/ansible/plugins/become/runas.py index e742211e0e3..1913824faa9 100644 --- a/lib/ansible/plugins/become/runas.py +++ b/lib/ansible/plugins/become/runas.py @@ -25,6 +25,8 @@ DOCUMENTATION = """ env: - name: ANSIBLE_BECOME_USER - name: ANSIBLE_RUNAS_USER + keyword: + - name: become_user required: True become_flags: description: Options to pass to runas, a space delimited list of k=v pairs @@ -40,6 +42,8 @@ DOCUMENTATION = """ env: - name: ANSIBLE_BECOME_FLAGS - name: ANSIBLE_RUNAS_FLAGS + keyword: + - name: become_flags become_pass: description: password ini: diff --git a/lib/ansible/plugins/become/su.py b/lib/ansible/plugins/become/su.py index 90ef6eaee44..e12a1bc892a 100644 --- a/lib/ansible/plugins/become/su.py +++ b/lib/ansible/plugins/become/su.py @@ -26,6 +26,8 @@ DOCUMENTATION = """ env: - name: ANSIBLE_BECOME_USER - name: ANSIBLE_SU_USER + keyword: + - name: become_user become_exe: description: Su executable default: su @@ -40,6 +42,8 @@ DOCUMENTATION = """ env: - name: ANSIBLE_BECOME_EXE - name: ANSIBLE_SU_EXE + keyword: + - name: become_exe become_flags: description: Options to pass to su default: '' @@ -54,6 +58,8 @@ DOCUMENTATION = """ env: - name: ANSIBLE_BECOME_FLAGS - name: ANSIBLE_SU_FLAGS + keyword: + - name: become_flags become_pass: description: Password to pass to su required: False diff --git a/lib/ansible/plugins/become/sudo.py b/lib/ansible/plugins/become/sudo.py index 9b6ded7db0c..778e7afeabe 100644 --- a/lib/ansible/plugins/become/sudo.py +++ b/lib/ansible/plugins/become/sudo.py @@ -26,6 +26,8 @@ DOCUMENTATION = """ env: - name: ANSIBLE_BECOME_USER - name: ANSIBLE_SUDO_USER + keyword: + - name: become_user become_exe: description: Sudo executable default: sudo @@ -40,6 +42,8 @@ DOCUMENTATION = """ env: - name: ANSIBLE_BECOME_EXE - name: ANSIBLE_SUDO_EXE + keyword: + - name: become_exe become_flags: description: Options to pass to sudo default: -H -S -n @@ -54,6 +58,8 @@ DOCUMENTATION = """ env: - name: ANSIBLE_BECOME_FLAGS - name: ANSIBLE_SUDO_FLAGS + keyword: + - name: become_flags become_pass: description: Password to pass to sudo required: False diff --git a/lib/ansible/plugins/connection/paramiko_ssh.py b/lib/ansible/plugins/connection/paramiko_ssh.py index 4692d099864..85337d7cf66 100644 --- a/lib/ansible/plugins/connection/paramiko_ssh.py +++ b/lib/ansible/plugins/connection/paramiko_ssh.py @@ -44,6 +44,8 @@ DOCUMENTATION = """ - section: paramiko_connection key: remote_user version_added: '2.5' + keyword: + - name: remote_user password: description: - Secret used to either login the ssh server or as a passphrase for ssh keys that require it diff --git a/lib/ansible/plugins/connection/psrp.py b/lib/ansible/plugins/connection/psrp.py index 1003a416f5e..1a386d1889d 100644 --- a/lib/ansible/plugins/connection/psrp.py +++ b/lib/ansible/plugins/connection/psrp.py @@ -34,6 +34,8 @@ options: vars: - name: ansible_user - name: ansible_psrp_user + keyword: + - name: remote_user remote_password: description: Authentication password for the C(remote_user). Can be supplied as CLI option. type: str @@ -52,6 +54,8 @@ options: vars: - name: ansible_port - name: ansible_psrp_port + keyword: + - name: port protocol: description: - Set the protocol to use for the connection. diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index 87d80794c23..f6fc24c3ddb 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -197,6 +197,8 @@ DOCUMENTATION = ''' vars: - name: ansible_port - name: ansible_ssh_port + keyword: + - name: port remote_user: description: - User name with which to login to the remote server, normally set by the remote_user keyword. @@ -211,6 +213,8 @@ DOCUMENTATION = ''' - name: ansible_ssh_user cli: - name: user + keyword: + - name: remote_user pipelining: env: - name: ANSIBLE_PIPELINING diff --git a/lib/ansible/plugins/connection/winrm.py b/lib/ansible/plugins/connection/winrm.py index d4929e924b6..5aad5ee560d 100644 --- a/lib/ansible/plugins/connection/winrm.py +++ b/lib/ansible/plugins/connection/winrm.py @@ -34,6 +34,8 @@ DOCUMENTATION = """ vars: - name: ansible_user - name: ansible_winrm_user + keyword: + - name: remote_user type: str remote_password: description: Authentication password for the C(remote_user). Can be supplied as CLI option. @@ -52,6 +54,8 @@ DOCUMENTATION = """ - name: ansible_port - name: ansible_winrm_port default: 5986 + keyword: + - name: port type: integer scheme: description: diff --git a/lib/ansible/plugins/doc_fragments/shell_common.py b/lib/ansible/plugins/doc_fragments/shell_common.py index 9ca9ece6db1..c1c7f0b15a1 100644 --- a/lib/ansible/plugins/doc_fragments/shell_common.py +++ b/lib/ansible/plugins/doc_fragments/shell_common.py @@ -64,6 +64,8 @@ options: default: [{}] description: - List of dictionaries of environment variables and their values to use when executing commands. + keyword: + - name: environment admin_users: type: list default: ['root', 'toor'] diff --git a/lib/ansible/plugins/doc_fragments/shell_windows.py b/lib/ansible/plugins/doc_fragments/shell_windows.py index ddb573fc71b..e4d648c7af3 100644 --- a/lib/ansible/plugins/doc_fragments/shell_windows.py +++ b/lib/ansible/plugins/doc_fragments/shell_windows.py @@ -43,6 +43,8 @@ options: description: - List of dictionaries of environment variables and their values to use when executing commands. + keyword: + - name: environment type: list default: [{}] """