Local_action module failed.

106 views
Skip to first unread message

Yuri

unread,
Mar 22, 2016, 11:06:09 AM3/22/16
to Ansible Project
Hello,

(Ansible version:2.0.0)


I tried to execute the following playbook.

-------
- name: test
  hosts: remote_windows_host
  vars:
    ansible_ssh_user: XXX
    ansible_ssh_pass: XXX
    ansible_ssh_port: XXXX
    ansible_connection: winrm
  tasks:
    - name: setup(remote windows host)
      setup:
    - name: sleep(local linux host)
      local_action: command sleep 5
-------

Then, the task "sleep(local linux host)" was failed.
The results in debug mode is as follows.


----------
TASK [sleep(local linux host)] *************************************************
task path: XXXXXXXXXXXXXXXXXXXXXXXXXX.yml:12
<localhost> ESTABLISH WINRM CONNECTION FOR USER: XXX on PORT XXXX TO localhost
fatal: [XX.XX.XXX.XXX]: FAILED! => {"failed": true, "msg": "ERROR! ssl: 500 WinRMTransport. Tunnel connection failed: 403 Forbidden"}
----------

Even though using local_action module, why does it try to connect to localhost with winrm?
How can I do so that LOCAL CONNECTION is used? (And not defining vars in inventory file.)


Thanks a lot for any help.


Message has been deleted

Uditha Desilva

unread,
Mar 22, 2016, 12:28:21 PM3/22/16
to Ansible Project
What's wrong with doing it via inventory?

I suppose you could try explicitly setting 

hostvars.['localhost'].ansible_connection_method="local"

as a workaround.

Uditha.

Yuri

unread,
Mar 23, 2016, 12:38:48 AM3/23/16
to Ansible Project
Thank you for reply.

> What's wrong with doing it via inventory?

Installed OS in a host varies by timing, so I'm trying to prepare the following two playbooks.
playbook_windows.yml : "ansible_connection: winrm" in vars section
playbook_linux.yml : "ansible_connection: ssh" in vars section
This is why I don't want to doing it via inventory.

> I suppose you could try explicitly setting 
> hostvars.['localhost'].ansible_connection_method="local"
> as a workaround.

I tried the following playbook, but  invalid variable name error occuerd.
-------
- name: test
  hosts: remote_windows_host
  vars:
    ansible_ssh_user: XXX
    ansible_ssh_pass: XXX
    ansible_ssh_port: XXXX
    ansible_connection: winrm
    hostvars['localhost'].ansible_connection: local      <-- added

  tasks:
    - name: setup(remote windows host)
      setup:
    - name: sleep(local linux host)
      local_action: command sleep 5
-------

-------
ERROR! Invalid variable name in vars specified for Play: hostvars['localhost'].ansible_connection is not a valid variable name
-------

Could you tell me what is wrong?


2016年3月23日水曜日 1時28分21秒 UTC+9 Uditha Desilva:

Uditha Desilva

unread,
Mar 23, 2016, 9:26:32 AM3/23/16
to Ansible Project
That doesn't seem to be an argument vs. making it an inventory variable (specifically, a group variable, if you're creating a group of windows hosts) -- otherwise how are you distinguishing between your managed systems at all? separate inventory files?

setting the hostvar entry doesn't seem to be supported because templating is essentially a one-way process.
Reply all
Reply to author
Forward
0 new messages