Ansible can't pass correct path to win_package module

Viewed 317

I can't manage to pass correct path to win_package module, ansible keeps adding escape character

 - name: Install package
      win_package:
        path: C:\folder\packagename

FAILED! => {"changed": false, "msg": "the file at the local path C:\\folder\\package cannot be reached"

same error for

 - name: Install package
      win_package:
        path: "C:\\folder\\packagename" 

Single backslashes causes ERROR! Syntax Error while loading YAML. found unknown escape character

The documentation says, but first way should be working, but it's not the case

- name: Install 7zip and use a file version for the installation check
  win_package:
    path: C:\temp\7z.exe

Is it some unexpected way that passing this parameter works, my error or confusing log message?

1 Answers

Ansible's default stdout callback escapes strings during output, the value has not been modified. Your issue is not being caused by this output escaping.

ec2-user@pandora ~ $ ansible-playbook test.yml

PLAY [localhost] ***************************************************************

TASK [debug] *******************************************************************
ok: [localhost] => {
    "msg": "C:\\foo\\bar"
}

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

ec2-user@pandora ~ $ ANSIBLE_STDOUT_CALLBACK=community.general.yaml ansible-playbook test.yml

PLAY [localhost] ***************************************************************

TASK [debug] *******************************************************************
ok: [localhost] => 
  msg: C:\foo\bar

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