I am able to run the below cmd
ansible windows -m raw -u Administrator -c winrm -a “dir”
with group_vars/windows.yml
ansible_user: Administrator
ansible_password: xxxxx
ansible_port: 5986
ansible_connection: winrm
ansible_winrm_server_cert_validation: ignore
I wonder how I can specify group_vars/windows.yml in the api code? The code is something like this now, which works fine on Linux.
def run(self, cmd, hosts, remote_user=‘Administrator’):
play_source = dict(
name = ‘Ansible Win Cli PoC’,
hosts = hosts,
remote_user = remote_user,
gather_facts = ‘no’,
tasks = [
dict(action=dict(module=‘raw’, args=cmd), register=‘shell_out’),
dict(action=dict(module=‘debug’, args=dict(msg=‘{{shell_out.stdout}}’)))
]
)
play = Play().load(play_source, variable_manager=self._variable_manager, loader=self._loader)
tqm = None
try:
tqm = TaskQueueManager(
inventory=self._inventory,
variable_manager=self._variable_manager,
loader=self._loader,
options=self._options,
stdout_callback=‘default’,
passwords=None
)
tqm.run(play)
finally:
if tqm is not None:
tqm.cleanup()