Bahmni Installer failing on "emove crontab jobs for upload directories" task

Hello all–

We have a bahmni build pipeline set up for one of our staging environments that runs the bahmni installer on every commit to our custom implementation config, and, mysteriously, the installer started to fail recently, and the failure doesn’t see to be related at all to changes we are making.

We are using the 0.81-366 version of the installer (which has been working successfully for months), and the problem appears to be occurring when trying to execute the “Remove crontab jobs for upload directories” task in bahmni-backup-upload-directories/tasks/main.yml

Ansible errors are a little cryptic to me, but the underlying error (‘NoneType’ object has no attribute 'strip") appears to be the pyton equivalent of a NPE when it tries to perform an operation on a cron job it has attempted to fetch? It does look like this job does not exist on our server–but assumedly an “state:absent” should just ensure a cron job is absent, not fail if it is absent?

Any thoughts? Has anyone encountered this before? Thanks!

"TASK [bahmni-backup-upload-directories : Remove crontab jobs for upload directories] ***", "task path: /opt/bahmni-installer/bahmni-playbooks/roles/bahmni-backup-upload-directories/tasks/main.yml:31", "An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'strip'", "failed: [localhost] (item=sync_patient_image_cron) => {\"failed\": true, \"item\": \"sync_patient_image_cron\", \"module_stderr\": \"Traceback (most recent call last):\\n File \\\"/tmp/ansible_FYNiQK/ansible_module_cron.py\\\", line 700, in <module>\\n main()\\n File \\\"/tmp/ansible_FYNiQK/ansible_module_cron.py\\\", line 645, in main\\n job = crontab.get_cron_job(minute, hour, day, month, weekday, job, special_time, disabled)\\n File \\\"/tmp/ansible_FYNiQK/ansible_module_cron.py\\\", line 385, in get_cron_job\\n job = job.strip('\\\\r\\\\n')\\nAttributeError: 'NoneType' object has no attribute 'strip'\\n\", \"module_stdout\": \"\", \"msg\": \"MODULE FAILURE\"}", "An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'strip'", "failed: [localhost] (item=sync_document_image_cron) => {\"failed\": true, \"item\": \"sync_document_image_cron\", \"module_stderr\": \"Traceback (most recent call last):\\n File \\\"/tmp/ansible_jrSyiI/ansible_module_cron.py\\\", line 700, in <module>\\n main()\\n File \\\"/tmp/ansible_jrSyiI/ansible_module_cron.py\\\", line 645, in main\\n job = crontab.get_cron_job(minute, hour, day, month, weekday, job, special_time, disabled)\\n File \\\"/tmp/ansible_jrSyiI/ansible_module_cron.py\\\", line 385, in get_cron_job\\n job = job.strip('\\\\r\\\\n')\\nAttributeError: 'NoneType' object has no attribute 'strip'\\n\", \"module_stdout\": \"\", \"msg\": \"MODULE FAILURE\"}", "An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'strip'", "failed: [localhost] (item=sync_uploaded_files_cron) => {\"failed\": true, \"item\": \"sync_uploaded_files_cron\", \"module_stderr\": \"Traceback (most recent call last):\\n File \\\"/tmp/ansible_UOI2EA/ansible_module_cron.py\\\", line 700, in <module>\\n main()\\n File \\\"/tmp/ansible_UOI2EA/ansible_module_cron.py\\\", line 645, in main\\n job = crontab.get_cron_job(minute, hour, day, month, weekday, job, special_time, disabled)\\n File \\\"/tmp/ansible_UOI2EA/ansible_module_cron.py\\\", line 385, in get_cron_job\\n job = job.strip('\\\\r\\\\n')\\nAttributeError: 'NoneType' object has no attribute 'strip'\\n\", \"module_stdout\": \"\", \"msg\": \"MODULE FAILURE\"}", "An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'strip'", "failed: [localhost] (item=sync_uploaded_results_cron) => {\"failed\": true, \"item\": \"sync_uploaded_results_cron\", \"module_stderr\": \"Traceback (most recent call last):\\n File \\\"/tmp/ansible_H7PFxe/ansible_module_cron.py\\\", line 700, in <module>\\n main()\\n File \\\"/tmp/ansible_H7PFxe/ansible_module_cron.py\\\", line 645, in main\\n job = crontab.get_cron_job(minute, hour, day, month, weekday, job, special_time, disabled)\\n File \\\"/tmp/ansible_H7PFxe/ansible_module_cron.py\\\", line 385, in get_cron_job\\n job = job.strip('\\\\r\\\\n')\\nAttributeError: 'NoneType' object has no attribute 'strip'\\n\", \"module_stdout\": \"\", \"msg\": \"MODULE FAILURE\"}", ""

This is an issue with ansible cron module. Please follow the documentation to temporarily fix it (till the new rpm from ansible with the fix is released)

Great, thanks @sravanthi17!

Mark

you are right… “state"absent” ensures that the cron jobs are not present. Since the jobs are not present in your system, it is failing @https://github.com/ansible/ansible-modules-core/blob/devel/system/cron.py#L388