I need to write an ansible script to solve the below requirement. i am trying to write script, few steps i have written but i am having some doubt how to lsit all the files older than 7 days, once we got the list of fies we need to send those files “*.merged” to a specific mail id, below are few steps which I have initiated . not sure that is right or wrong. Request you to suggest the steps.
REQUIREMENT:
monitoring the “*.merged” files older than 7 days and delete those files after sending the list of files to the Mail id
In linux we are using " ls -l /prod/HDOP/data//bigplay.na/yarn/nm/usercache" to display all the Cache Files as ".merged"
we need to find all the files older than 7 days and make a list
Send a mail having list of files which is older than 7 days to XXX@gmail.com on a weekly basis.
5.we need to delete all files older than 7 days ,Once we have sent those file list to XXX@gmail.com
Can some one please look into below ansible codes ,and let me know whether it’s correct or we need to modify anywhere, as I am new to ansible and currently I don’t have access to test the code.
REQUIREMENT:
monitoring the “*.merged” files older than 7 days and delete those files after sending the list of files to the Mail id
In linux we are using " ls -l /prod/HDOP/data//bigplay.na/yarn/nm/usercache" to display all the Cache Files as ".merged"
we need to find all the files older than 7 days and make a list
Send a mail having list of files which is older than 7 days to XXX@gmail.com on a weekly basis.
5.we need to delete all files older than 7 days ,Once we have sent those file list to XXX@gmail.com
Not sure what you mean by "I don't have access to test the code".
Instead of guessing what might have happened if you ran the playbook,
just run it.
If you are concerned with accidentally removing files, use the
'--check' option for ansible-playbook.
Ansible will report any issues, usually in a easy to understand
fashion so you can fix the code.