Git, unsupported parameter for module: refspec

Hi all,

I’m trying to use the Ansible Git module to deploy an application repository in Git using a Git tag. I’m thinking I need to use the refspec parameter to define the tag. The following task works without the refspec parameter.

tasks: - name: update | application repogit: repo={{ repo_url }} dest={{ deploy_to }} version={{ branch }} accept_hostkey=yes

However, the following play with the refspec parameter

tag_name: "v2015.11.1" ... ``tasks:`` ``- name: update | application repo`` git: repo={{ repo_url }} dest={{ deploy_to }} version={{ branch }} refspec=refs/tags{{ tag_name }} accept_hostkey=yes

throws the following error upon deploy.

TASK: [update | application repo] ********************************************* failed: [x.x.x.x] => {"failed": true} msg: unsupported parameter for module: refspec

http://docs.ansible.com/ansible/git_module.html says refspec was added in 1.9.

I’m running

$ ansible --version ansible 1.9.2 (detached HEAD f974ff6972) last updated 2015/12/07 14:19:33 (GMT -700) lib/ansible/modules/core: (detached HEAD ea913bada2) last updated 2015/12/07 14:19:33 (GMT -700) lib/ansible/modules/extras: (detached HEAD f291e9fcc3) last updated 2015/12/07 14:19:33 (GMT -700) v2/ansible/modules/core: (detached HEAD 85c8a892c8) last updated 2015/12/07 14:19:33 (GMT -700) v2/ansible/modules/extras: (detached HEAD 70ea058563) last updated 2015/12/07 14:19:33 (GMT -700) configured module search path = None

I tried

ansible$ git checkout stable-2.0 ansible$ git submodule update --init --recursive

I’m still getting the same error.

I may not be using the right syntax to define the refspec value, however it seems like the refspec parameter should be recognized.

Questions:

Why isn’t the refpec paramter recognized?
Is there another way to use the Git playbook to deploy a tagged location on a Git repo?

If not I’ll try something like

command: cd {{deploy_to}} && git checkout tags/{{ tag_name }} && git checkout develop && git merge {{ tag_name }}

Thanks,
Paul

This of course works.

command: bash -lc "cd {{deploy_to}} && git checkout tags/{{ tag_name }}"

Removing the version parameter from the git task gave the same error message, "msg: unsupported parameter for module: refspec" I thought perhaps having both a version and a refspec might have been causing the error.


git: repo={{ repo_url }} dest={{ deploy_to }} refspec=refs/tags/{{ tag_name }} accept_hostkey=yes

Sheesh, I missed in the documentation that the version parameter will take a tag name as an argument. Problem solved.