i have this ansible simple playbook :
where “/home/ec2-user/test1.txt” exists on disk
`
i have this ansible simple playbook :
where “/home/ec2-user/test1.txt” exists on disk
`
i have this ansible simple playbook :
where "/home/ec2-user/test1.txt" exists on disk>
---
-name:check ifexsist
hosts:localhost
gather_facts:false
tasks:\-name:Getproject name shell:"echo 'hhhhhhhh'" register:name\_var \-name:Checkifthetest\.log exists inpath stat: path:"/home/ec2\-user/test1\.txt1" register:log\_result\_1 \-name:CheckifTheTest\.log exists inp\_home stat: path:"/home/ec2\-user/test1\.txt" register:log\_result\_2 when:name\_var\.stdout ismatch\("hhhhhhhh"\) \-set\_fact: my\_result:"\{\{ log\_result\_1\.stat\.exists or \(log\_result\_2 is not skipped and log\_result\_2\.stat\.exists\) \}\}" \-debug: msg:"\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# result\_value \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#" \-debug: var:my\_result \-name:Createtemporary log folder file: path:"/home/ec2\-user/log\_tmp" state:directory when:my\_result\.stat\.exists
>
I expect that the my_result will have the value of the right register in this case log_result_2
No the output is a boolean, variables are evaluated in your expression.
Regards
Racke