Ad

Is It Possible To Execute "git Submodule Update" Without "command:" Or "shell:" With Ansible?

- 1 answer

So I've been given the task of updating a certain directory over Ansible and I can't seem to find a way to execute git submodule update with git:.

Is there really no other way to do git submodule update without using command: or shell:?

My current code:

# Command to execute: git remote update
- name: Git Update
  git:
    repo: "{{ git_ssh_key }}"
    dest:  ~/some/directory
    update: yes
    version: master

# Command to execute: git reset --hard origin/master
- name: Git reset
  command: git reset --hard origin/master
  args: 
    chdir: ~/some/directory

# Command to execute: git submodule update
- name: Git Submodule Update
  [Here is where I need your help to execute "git submodule update"]

Any help is greatly appreciated.

Ad

Answer

Add parameter recursive: yes:

# Command to execute: git submodule update
- name: Git Submodule Update
  git:
      repo: "{{ git_ssh_key }}"
      dest:  ~/some/directory
      recursive: yes
      update: yes
      version: master

See the docs at https://docs.ansible.com/ansible/latest/modules/git_module.html

Ad
source: stackoverflow.com
Ad