I don’t know if there is another way to do what I am trying to do.
My case of use would be to be able to use the same roles/playbooks to mantain the configuration along all my servers and for the AMI creation. In the case of an ami creation I don’t want the services to start o restart, I don’t want to execute a restart when copying the config file.
Is there any other way to do taht without skiping handlers?
I tried with a “when” statement on the handler definition (with a variable defined by me) but id didn’t seem to work either, the handler is executed anyway, and the AMI creation fails for that.
name: Start a enable beaver
service: name=beaver.sh enabled=yes state=started
I call an ansible playbook which calls the beaver role with:
/usr/local/bin/ansible-playbook /tmp/ansible-local/php.yml --extra-vars ‘flag_not_restart=1’ -c local -i /tmp/ansible-local/localhost.inv
If I debug the “flag_not_restart” I can see it exist and is “1”.
And yet the “restart beaver” handler is called and executed.