Powershell Function via Ansible | Get-AnsibleParam: Missing required argument: _raw_params

3,126 views
Skip to first unread message

jesse...@gmail.com

unread,
Jan 27, 2021, 10:41:24 AM1/27/21
to Ansible Project
Executing a rather large playbook revolving around multiple plays to create shares and DFS links, etc.

I've got a play to do the following.
-------------
  - name: Create DFS links
    ansible.windows.win_shell: |
      . C:\scripts\user\dfs_abe_func.ps1

      gf-dfsadd -junction "{{ vol_junction }}" -share_name "{{ share_name }}" -prd_vserver "{{ prd_vserver_fs }}.{{ fqdn }}" -dr_vserver "{{ dr_vserver }}.{{ fqdn }}" -prd_state "{{ prd_state }}" -dr_state "{{ dr_state }}" -rogroup "{{ rogroup }}" -rwgroup "{{ rwgroup }}" -fcgroup "{{ h_defaultfcgroup }}" -defaultrogroup "{{ h_defaultrogroup }}" -defaultrwgroup "{{ h_defaultrwgroup }}"
-------------
Nets the below error.

fatal: [Server.Domain.net]: FAILED! => {
    "changed": false,
    "msg": "Get-AnsibleParam: Missing required argument: _raw_params"
}

I'm passing a bunch of variables built within the play itself, utilizing variables built from other ones, but I don't presume those are related to my issues.

I can post most of the PS function if needed, after its been sanitized a bit.
Looking for ideas :/

jesse...@gmail.com

unread,
Jan 28, 2021, 11:58:30 AM1/28/21
to Ansible Project
Crickets
:(

jbor...@gmail.com

unread,
Jan 28, 2021, 2:28:41 PM1/28/21
to Ansible Project

What Ansible version are you running, does it also fail with the same error if you did just "- ansible.windows.win_shell: echo 'hi'". Does win_command work, what about just "win_shell" and not the FQCN.

jesse...@gmail.com

unread,
Feb 1, 2021, 11:40:20 AM2/1/21
to Ansible Project
I've got this that I'm connecting to, doing a metric ton of other things as well, so I'm positive the connection is functional and working.

ansible 2.9.13
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Aug 13 2020, 07:46:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

-------- Test play


#

  - name: test me
    ansible.windows.win_shell:
    args:
      cmd: echo 'hi'

-------- Results

fatal: [SERVER.DOMAIN.net]: FAILED! => {

jbor...@gmail.com

unread,
Feb 1, 2021, 5:29:27 PM2/1/21
to Ansible Project
The win_shell and win_command modules don't support cmd as an args like command/shell do. It's complaining that the raw missing is missing because you haven't done 'win_shell: my command'.

jesse...@gmail.com

unread,
Feb 2, 2021, 8:38:37 AM2/2/21
to Ansible Project
So pulling this from docs.ansible.com
- name: Run a command under a non-Powershell interpreter (cmd in this case) ansible.windows.
win_shell: echo %HOMEDIR%
args: executable:
cmd
register: homedir_out
-----
That aside, following your precise example

  - ansible.windows.win_shell: echo "HI"
--begin error
ERROR! this task 'ansible.windows.win_shell' has extra params, which is only allowed in the following modules: script, include, meta, include_role, raw, set_fact, win_shell, import_tasks, group_by, import_role, shell, include_vars, win_command, add_host, command, include_tasks

The error appears to be in '/etc/ansible/playbooks/shares/greenfield/greenfield_share_create.yml': line 294, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


  - ansible.windows.win_shell: echo "HI"
    ^ here
--end error

p.s, I hate google groups now.

jesse...@gmail.com

unread,
Feb 2, 2021, 10:33:42 AM2/2/21
to Ansible Project
I managed to net a better result by specifying the collection at the top of the playbook with
  collections:
    - ansible.windows


and making the play

  - name: Hi Jason
    win_shell: echo "HI"

---

continuing on and using the same collection I managed to get the rest of my PS nonsense to work

jbor...@gmail.com

unread,
Feb 2, 2021, 3:19:55 PM2/2/21
to Ansible Project
So your particular error is because you are using an Ansible version that is too old. You are trying to run the 'ansible.windows.win_shell' collection module but Ansible hardcoded in a check to only allow win_shell (the builtin version). This has been fixed in recent Ansible versions (I cannot which but at least 2.10) and in any case the ansible.windows version requires Ansible 2.10+ anyway. So you either need to update your Ansible version or not use the ansible.windows collection on 2.9.

jesse...@gmail.com

unread,
Feb 2, 2021, 3:53:50 PM2/2/21
to Ansible Project
Got it.

I'm attempting to not have to update just yet, we're integrating Rundeck organization wide and I'm hoping to just need to convert into their environment and call it a day.

Thanks again
Reply all
Reply to author
Forward
0 new messages