links: "{{'1.1.1.2:8080,1.1.1.3:8080,1.1.1.4:8080'}}"log: "{{'C:\\Program Files (x86)\\Test\\'}}"- name: Test script script: "{{ role_path }}/files/test.ps1 {{ links }} {{ log }}" register: result- set_fact: test="{{ result.stdout | from_json }}"
- name: Json output local_action: copy content="{{ vars[item] }}" dest="/home/user/ansible/test-{{ item }}-{{ ansible_date_time.date }}.json" with_items: - testfatal: [test]: FAILED! => { "changed": true, "failed": true, "msg": "non-zero return code", "rc": 1, "stderr": "x86 : The term 'x86' is not recognized as the name of a cmdlet, function, \r\nscript file, or operable program. Check the spelling of the name, or if a path \r\nwas included, verify that the path is correct and try again.\r\nAt line:1 char:180\r\n+ ... 1.1.1.3:8080,1.1.1.4:8080 C:\\Program Files (x86)\\test ...\r\n+ ~~~\r\n+ CategoryInfo : ObjectNotFound: (x86:String) [], CommandNotFound \r\nException\r\n+ FullyQualifiedErrorId : CommandNotFoundException\r\n", "stdout": "", "stdout_lines": []}You can construct valid windows paths with spaces if you single quote the path, like this.
app_dir: 'C:\Program Files (x86)\My App Directory'
If you need to build up a path from a variable you may well need to use double quotes and double backslashes, like this.
another_dir: "{{ app_homedir}}\\another\\sub\\directory"
Hope this helps,
Jon
Powershell has a ConvertTo-Json cmdlet that might well simplify your code, but it's worth trying to use the modules as things like idempotency and the ability to use check mode become useful once you have got a few things automated.
Hope this helps as well,
Jon
log: C:\\Program Files (x86)\\Test- name: Test script script: "{{ role_path }}/files/test.ps1 {{ links }} \'{{ log }}\'" register: result- set_fact: test="{{ result.stdout | from_json }}"
- name: Json output local_action: copy content="{{ vars[item] }}" dest="/home/user/ansible/test-{{ item }}-{{ ansible_date_time.date }}.json" with_items: - test