Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible git module rev-parse

Tags:

git

ansible

Hi I want to execute the following as ansible task to pull the latest commit id on local:

  - name: get latest git commit id
    local_action: "command git rev-parse HEAD"
    register: git_commit_id

but I'm getting a warning because I'm using command. Since git is an ansible core module: http://docs.ansible.com/ansible/git_module.html

How can I execute this using git module?

like image 896
Ankit Avatar asked Oct 31 '22 04:10

Ankit


1 Answers

If you put this in your vars file:

base: "{{ lookup('pipe', 'git rev-parse --show-toplevel') }}"

and then use the variable {{base}} in your playbook that should do it.

like image 101
triangorithm Avatar answered Nov 08 '22 08:11

triangorithm