Below is my ansible script -
- name: To delete files
hosts: current
gather_facts: true
tasks:
- name: Check for the right folder
win_shell: |
if (Test-Path -Path 'C:\Program Files (x86)\MF\LGG\bin') {
Write-Output "LGG"
setx PATH "$env:path;C:\Program Files (x86)\MF\LGG\bin" -m
}
else {
Write-Output "LRR"
setx PATH "$env:path;C:\Program Files (x86)\MF\LRR\bin" -m
}
register: actualpath
- name: print output
debug:
msg: "output is {{ actualpath.stdout_lines }} "
- debug: var=actualpath.stdout
My plan here is to capture the output given from the above and run another set of commands based on the output i.e. LRR or LGG
But when i try to print the output, i see it different formats like below -
TASK [print output] ************************************************************
ok: [xxx] => {
"msg": "output is [u'LGG', u'', u'SUCCESS: Specified value was saved.'] "
}
TASK [debug] *******************************************************************
ok: [xxx] => {
"actualpath.stdout": "LGG\r\n\r\nSUCCESS: Specified value was saved.\r\n"
}
How to make sure i only get whatever i am printing or how to trim the value and save it in the register?