Versioning servers provisioned by Ansible

Hi,

I´ve been assigned a task where I should be able to version our servers which are being provisioned by ansible. The ansible setup on the controller machine is located in a Git repo. I have ansible logging configured on the controller.
Now I was toying with the idea that it would be nice to perhaps push the last ansible command run and/or the git commit id to each server as I provision. This could obviously be done as a task but then I have to remember to include it or run the whole playbook each time.
I was hoping for a more elegant solution where maybe a callback plugin would be triggered on each execution which would retrieve the git commit id of the repo and then pushing it somehow to each server.
This way I could on any given server run a command which told me ansible commands executed against this server and/or associated git tags/hashes.

I´ve briefly looked at the http://docs.ansible.com/ansible/developing_plugins.html but it´s a lot of material to get though just to pick up and push a git commit to server atomatically.

Anyone have any good examples to start off with or comments if this is a good way to go about versioning?

Regards,
Henning

​If it's a task that is part of your playbook, I don't see the problem with
how to forget that?

Using tags, you could mark that task with the special 'all' tag., so that
task will always run, regardless of which specific tags you target.

Serge

Nice :slight_smile:
I did not know about the special tags that force a task to be run. So the combination of an initial lookup using a shell command on controller and always tag on task will do nicely.

Thanks

the special tag is 'always', 'all' is the default value of --tags
which makes it run all tagged and untagged tasks.