I’m still pretty new to ansible, so I feel like I am probably doing something really stupid, but I cannot get the assert module to work.
I have ansible version 1.5.3. I’m getting “ERROR: assert is not a legal parameter in an Ansible task or handler” in all my attempts to use an assert. I’ve been searching the docs and all I can find is the doc which gives a snippet example of using assert and my attempts to copy that aren’t working, and I can’t find an actual complete playbook example that includes the use of assert to compare to.
What I’m trying to do, assert may not even be the right approach for. Basically I’m developing a playbook for automated reboots that is very dangerous during production hours and which should only ever be allowed to run on a Saturday during a designated window, and so I want the playbook to include some explicit rules that will prevent it from rebooting when it’s not supposed to, even if some chucklehead accidentally executes it during the week.
Ideally, I’d be able just reference an ansible fact for the day of the week, but I can’t seem to find one? So I’m using the date command to get the day of the week and registering that into a variable. Then I want to abort the playbook when that and another condition are not met.
My test playbook looks like this (the tasks that set commonWeekday and commonResultBackup are in roles/common/tasks/main.yml):
REBOOTGROUP_SAT_10AM.yml: