I want to change the permission of the file based on it’s extension using ansible, for example I have directory test
and within this directory I have a lot of shell script(.sh) and python(.py) files. I want to change the permission of shell script to 0700 and python files to 0644. Can you please help me that how I can achieve this. Thanks
something like this?:
- find: path=test/
register: testfiles
- file: path={{item.path}} mode={{ ((item.path|splitext)[0] in ['sh',
'py'])|ternary('0700','0644') }}
with_items: "{{testfiles.files}}"
Brain your example change the permission to 0644 to all the files regardless of extension, can you please help me to modified the provided example. Thanks
i whipped it up from memory, not tested at all, i see you probably
need to change the 0 to a 1, but it was meant as a hint not the actual
solution.