# Versioning servers provisioned by Ansible

**URL:** <https://forum.ansible.com/t/versioning-servers-provisioned-by-ansible/19562>\
**Category:** Ansible Developer\
**Created:** [October 20, 2015, 1:33pm UTC](https://forum.ansible.com/t/versioning-servers-provisioned-by-ansible/19562 "2015-10-20T13:33:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henning\_Juva](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@Henning\_Juva](https://forum.ansible.com/u/Henning_Juva)\
**Post date:** [October 20, 2015, 1:33pm UTC](https://forum.ansible.com/t/versioning-servers-provisioned-by-ansible/19562/1 "2015-10-20T13:33:30Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [October 20, 2015, 1:38pm UTC](https://forum.ansible.com/t/versioning-servers-provisioned-by-ansible/19562/2 "2015-10-20T13:38:47Z")

</div>

​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

---

<div class="post-metadata">

**Author:** ![Henning\_Juva](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@Henning\_Juva](https://forum.ansible.com/u/Henning_Juva)\
**Post date:** [October 20, 2015, 2:28pm UTC](https://forum.ansible.com/t/versioning-servers-provisioned-by-ansible/19562/3 "2015-10-20T14:28:27Z")

</div>

Nice 🙂  
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

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [October 20, 2015, 3:20pm UTC](https://forum.ansible.com/t/versioning-servers-provisioned-by-ansible/19562/4 "2015-10-20T15:20:15Z")

</div>

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