I'm using the following ansible playbook to deploy my applications and I would like to add a tagging role so I can automatically add/update a tag to mark the current commit as the one that has been deployed.
Attempt
My current attempt is as follow, based on How can I move a tag on a git branch to a different commit?:
---
- name: Removes the tag in local repository.
shell: git tag -d {{git_deploy_tag}}
tags: [tagging]
- name: Removes the tag in remote repository.
shell: git push origin :refs/tags/{{git_deploy_tag}}
tags: [tagging]
- name: Adds the tag to different commit (HEAD).
shell: git tag {{git_deploy_tag}} HEAD
tags: [tagging]
- name: Pushes the changes to the remote repository.
shell: git push origin {{git_branch}} --tags
tags: [tagging]
Problem
This role is run on the remote host that doesn't have access to the git repository, and I intend to keep it so. I was unable to run the role on my local machine following Run command on the Ansible host.
Question
How do I run the tagging role locally (other roles should run on the remote). Fabric script have a local()
method