reigster is not working with ansible git task

2020-05-07 02:45发布

问题:

I want to debug git task in my ansible play-book.When I am using register keyword for that but it is throwing me error .This is my playbook code

- git: 
        repo: http://<git url>/<user>/<repo>
        dest: /home/atul/Workplace/test-ansible
        version: "{{ GIT_TAG }}"
        refspec: '+refs/tags/{{GIT_TAG}}:refs/remotes/origin/tags/{{GIT_TAG}}'
        update: no
        register: cloned 

I am getting this error

TASK [git] ************************************************************************************************************************************
fatal: [host]: FAILED! => {"changed": false, "failed": true, "msg": "Unsupported parameters for (git) module: register. Supported parameters include: accept_hostkey,bare,clone,depth,dest,executable,force,key_file,recursive,reference,refspec,remote,repo,ssh_opts,track_submodules,umask,update,verify_commit,version"}
    to retry, use: --limit @/home/atul/Workplace/infra-automation/scripts/iquippo-build.retry

PLAY RECAP ************************************************************************************************************************************

回答1:

register is a task parameter, not module parameter, so mind the padding:

- git: 
        repo: http://<git url>/<user>/<repo>
        dest: /home/atul/Workplace/test-ansible
        version: "{{ GIT_TAG }}"
        refspec: '+refs/tags/{{GIT_TAG}}:refs/remotes/origin/tags/{{GIT_TAG}}'
        update: no
  register: cloned 


标签: git ansible