to set the account's password under ``ansible_become_pass`` if the
to set the account's password under ``ansible_become_pass`` if the
become_user has a password.
become_user has a password.
Become Flags
------------
Ansible 2.5 adds the ``become_flags`` parameter to the ``runas`` become method. This parameter can be set using the ``become_flags`` task directive or set in Ansible's configuration using ``ansible_become_flags``. The two valid values that are initially supported for this parameter are ``logon_type`` and ``logon_flags``.
..Note:: These flags should only be set when becoming a normal user account, not a local service account like LocalSystem.
The key ``logon_type`` sets the type of logon operation to perform. The value
can be set to one of the following:
* ``interactive``: The default logon type. The process will be run under a
context that is the same as when running a process locally. This bypasses all
WinRM restrictions and is the recommended method to use.
* ``batch``: Runs the process under a batch context that is similar to a
scheduled task with a password set. This should bypass most WinRM
restrictions and is useful if the ``become_user`` is not allowed to log on
interactively.
* ``new_credentials``: Runs under the same credentials as the calling user, but
outbound connections are run under the context of the ``become_user`` and
``become_password``, similar to ``runas.exe /netonly``. The ``logon_flags``
flag should also be set to ``netcredentials_only``. Use this flag if
the process needs to access a network resource (like an SMB share) using a
different set of credentials.
* ``network``: Runs the process under a network context without any cached
credentials. This results in the same type of logon session as running a
normal WinRM process without credential delegation, and operates under the same
restrictions.
* ``network_cleartext``: Like the ``network`` logon type, but instead caches
the credentials so it can access network resources. This is the same type of
logon session as running a normal WinRM process with credential delegation.
- name:verify newer hosts worked with become + async
- name:verify newer hosts worked with become + async
assert:
assert:
that:
that:
- whoami_out is successful
- whoami_out is successful
when:os_version.stdout_lines[0] == "True"
when:os_version.stdout_lines[0] == "async"
- name:test failure with string become invalid key
vars:*become_vars
win_whoami:
become_flags:logon_type=batch invalid_flags=a
become_method:runas
register:failed_flags_invalid_key
failed_when:failed_flags_invalid_key.msg != "become_flags key 'invalid_flags' is not a valid runas flag, must be 'logon_type' or 'logon_flags'"
- name:test failure with invalid logon_type
vars:*become_vars
win_whoami:
become_flags:logon_type=invalid
register:failed_flags_invalid_type
failed_when:"failed_flags_invalid_type.msg != \"become_flags logon_type value 'invalid' is not valid, valid values are: interactive, network, batch, service, unlock, network_cleartext, new_credentials\""
- name:test failure with invalid logon_flag
vars:*become_vars
win_whoami:
become_flags:logon_flags=with_profile,invalid
register:failed_flags_invalid_flag
failed_when:"failed_flags_invalid_flag.msg != \"become_flags logon_flags value 'invalid' is not valid, valid values are: with_profile, netcredentials_only\""
# Server 2008 doesn't work with network and network_cleartext, there isn't really a reason why you would want this anyway
- name:become different types
vars:*become_vars
win_whoami:
become_flags:logon_type={{item.type}}
register:become_logon_type
when:not ((item.type == 'network' or item.type == 'network_cleartext') and os_version.stdout_lines[0] == "old-gramps")
failed_when:become_logon_type.logon_type != item.actual and become_logon_type.sid != user_limited_result.sid