mirror of
https://github.com/ansible/ansible.git
synced 2026-08-03 08:03:05 +02:00
winrm - Add explicit env vars to pass into kinit (#75256)
* winrm - Add explicit env vars to pass into kinit * Add ini entry and don't override existing env vars
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
minor_changes:
|
||||
- winrm - Allow explicit environment variables to be passed through to the ``kinit`` call for Kerberos authentication
|
||||
@@ -92,6 +92,21 @@ DOCUMENTATION = """
|
||||
vars:
|
||||
- name: ansible_winrm_kinit_args
|
||||
version_added: '2.11'
|
||||
kinit_env_vars:
|
||||
description:
|
||||
- A list of environment variables to pass through to C(kinit) when getting the Kerberos authentication ticket.
|
||||
- By default no environment variables are passed through and C(kinit) is run with a blank slate.
|
||||
- The environment variable C(KRB5CCNAME) cannot be specified here as it's used to store the temp Kerberos
|
||||
ticket used by WinRM.
|
||||
type: list
|
||||
elements: str
|
||||
default: []
|
||||
ini:
|
||||
- section: winrm
|
||||
key: kinit_env_vars
|
||||
vars:
|
||||
- name: ansible_winrm_kinit_env_vars
|
||||
version_added: '2.12'
|
||||
kerberos_mode:
|
||||
description:
|
||||
- kerberos usage mode.
|
||||
@@ -306,6 +321,12 @@ class Connection(ConnectionBase):
|
||||
os.environ["KRB5CCNAME"] = krb5ccname
|
||||
krb5env = dict(KRB5CCNAME=krb5ccname)
|
||||
|
||||
# Add any explicit environment vars into the krb5env block
|
||||
kinit_env_vars = self.get_option('kinit_env_vars')
|
||||
for var in kinit_env_vars:
|
||||
if var not in krb5env and var in os.environ:
|
||||
krb5env[var] = os.environ[var]
|
||||
|
||||
# Stores various flags to call with kinit, these could be explicit args set by 'ansible_winrm_kinit_args' OR
|
||||
# '-f' if kerberos delegation is requested (ansible_winrm_kerberos_delegation).
|
||||
kinit_cmdline = [self._kinit_cmd]
|
||||
|
||||
Reference in New Issue
Block a user