I have an application which creates a directory actually named %UserProfile%. I cannot figure how to make Ansible understand and work with that name.
I want to amongst other things create directory D:\Downloads\CloneApp\cloneapptorun\Backup\Windows Documents\%UserProfile%.
I cannot find the way to tell ansible to do that which works. I have tried many combinations. Below code is the base structure I use:
- name: Create local staging cloneapp package directory
win_file:
path: "{{ remote_cloneapp_package_folder }}"
state: directory
- name: Create local staging cloneapp package userprofile documents documents directory
win_file:
path: /unsafe "{{ remote_cloneapp_package_folder }}\\Backup\Windows Documents\\{%raw%}%UserProfile%{%endraw%}"
state: directory
Giving:
fatal: [192.168.2.96]: FAILED! => {"changed": false, "msg": "Get-AnsibleParam: Parameter 'path' has an invalid path '/unsafe \"c:\\Downloads\\CloneApp\\cloneapptorun\\\\Backup\\Windows Documents\\\\C:\\Users\\mbengtss\"' specified."}
I have tried many combinations on the last path part. Like:
path: "{{ remote_cloneapp_package_folder }}\Backup\Windows Documents\{%raw%}.%UserProfile.%{%endraw%}"
Giving incorrect syntax, not runnable, directly from ansible
path: '{{ remote_cloneapp_package_folder }}\Backup\Windows Documents{{ %raw% }}%UserProfile%{{ %endraw% }}'
Giving: fatal: [192.168.2.96]: FAILED! => {"msg": "template error while templating string: unexpected '%'. String: {{ remote_cloneapp_package_folder }}\Backup\Windows Documents\{{ %raw% }}%UserProfile%{{ %endraw% }}"}
path: {{ remote_cloneapp_package_folder }}\Backup\Windows Documents{{ % }}UserProfile{{ % }}
Giving: fatal: [192.168.2.96]: FAILED! => {"msg": "template error while templating string: unexpected '%'. String: {{ remote_cloneapp_package_folder }}\Backup\Windows Documents\{{ % }}UserProfile{{ % }}"}
path: '{{ remote_cloneapp_package_folder }}\Backup\Windows Documents\%UserProfile%'
Giving: fatal: [192.168.2.96]: FAILED! => {"changed": false, "msg": "The given path's format is not supported."}
path: '"{{ remote_cloneapp_package_folder }}\Backup\Windows Documents\%UserProfile%"'
Giving: fatal: [192.168.2.96]: FAILED! => {"changed": false, "msg": "The given path's format is not supported."}
path: "{{ remote_cloneapp_package_folder }}\Backup\Windows Documents\\%UserProfile\%"
Giving: incorrect syntax, not runnable, directly from ansible
None of the tries lead to Ansible creating the wanted directory, although the first directory part is created as wanted.
How do I define the last path string so it works? I do want the directory to remain as it is called. So the question is not about changing directory name, it is about getting Ansible to understand and create the directory name as it is currently named.
--- Mats ---