rundeck-plugins / ansible-plugin

Ansible Integration for Rundeck
MIT License
331 stars 100 forks source link

Using `ansible_shell_type: cmd` in inventory breaks `gather-hosts.yml` #290

Open edorgeville opened 3 years ago

edorgeville commented 3 years ago

Hi, I am trying to get an inventory containing Windows hosts running in Rundeck. They are setup using the following guide: https://docs.ansible.com/ansible/latest/user_guide/windows_setup.html#configuring-ansible-for-ssh-on-windows The hosts are accessible using ansible-playbook. Consider the following inventory file inventory.yml:

all:
  vars:
    ansible_connection: ssh
    ansible_shell_type: cmd
    ansible_user: user
    ansible_password: password
  hosts:
    server1:
      ansible_host: 192.168.1.100

Now, if I try using this inventory as an Ansible Resource Model Source, the node server1 does not show up in the Nodes tab. image

Digging into the logs, I found this:


PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [server1]

TASK [Ensure tmpdir data directory] ********************************************
fatal: [server1]: UNREACHABLE! => {"changed": false, "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: PowerShell 
-NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand UwBlAHQALQBTAHQAcgBpAGMAdABNAG8AZABlACAALQBWAGUAcgBzAGkAbwBuACAATABhAHQAZQBzAHQACgAkAHQAbQBwAF8AcABhAHQAaAAgAD0AIABbAFMAeQBzAHQAZQBtAC4ARQBuAHYAaQByAG8AbgBtAGUAbgB0AF0AOgA6AEUAeABwAGEAbgBkAEUAbgB2AGkAcgBvAG4AbQBlAG4AdABWAGEAcgBpAGEAYgBsAGUAcwAoACcAJQBUAEUATQBQACUAJwApAAoAJAB0AG0AcAAgAD0AIABOAGUAdwAtAEkAdABlAG0AIAAtAFQAeQBwAGUAIABEAGkAcgBlAGMAdABvAHIAeQAgAC0AUABhAHQAaAAgACQAdABtAHAAXwBwAGEAdABoACAALQBOAGEAbQBlACAAJwBhAG4AcwBpAGIAbABlAC0AdABtAHAALQAxADYAMAA4ADEANQAwADgANQAxAC4ANQA1ADMANwAyADYANwAtADEAMgA5ADUAOQAwADIANgA5ADcAMwA1ADEAMgA4ACcACgBXAHIAaQB0AGUALQBPAHUAdABwAHUAdAAgAC0ASQBuAHAAdQB0AE8AYgBqAGUAYwB0ACAAJAB0AG0AcAAuAEYAdQBsAGwATgBhAG0AZQAKAEkAZgAgACgALQBuAG8AdAAgACQAPwApACAAewAgAEkAZgAgACgARwBlAHQALQBWAGEAcgBpAGEAYgBsAGUAIABMAEEAUwBUAEUAWABJAFQAQwBPAEQARQAgAC0ARQByAHIAbwByAEEAYwB0AGkAbwBuACAAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQBuAHUAZQApACAAewAgAGUAeABpAHQAIAAkAEwAQQBTAFQARQBYAEkAVABDAE8ARABFACAAfQAgAEUAbABzAGUAIAB7ACAAZQB4AGkAdAAgADEAIAB9ACAAfQA=, exited with result 127", "unreachable": true}

NO MORE HOSTS LEFT *************************************************************

PLAY RECAP *********************************************************************
server1          : ok=1    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0

I had a look at the source of the logs, the gather-hosts.yml file.

It seems delegate_to: localhost is used to run the tasks on the master node (Linux), but the line ansible_shell_type: cmd in my inventory makes it so the task is executed as CMD/Powershell, which fails.

I searched for a workaround but don't seem to find any. Changing the shell type in the inventory doesn't work as my hosts are indeed using cmd as a default shell. A good solution I see would be to to specify the shell type at a task or playbook level in gather-hosts.yml, enforcing sh for locally running tasks; but I haven't found anything about this in the Ansible docs.

Any help is appreciated! Thank you

stefanwerner87 commented 11 months ago

any news on this issue? we are facing the same problem..

@edorgeville have you found a workaround?

edorgeville commented 11 months ago

@stefanwerner87 Unfortunately, I think ended up not using Rundeck

edorgeville commented 11 months ago

Also, it was 3 years ago and I cannot remember what I had for lunch yesterday 🥴