Is it possible to execute "git submodule update" without "command:" or "shell:" with Ansible?
Asked Answered
D

1

6

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.

Diastase answered 28/10, 2019 at 10:2 Comment(0)
C
7

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

Clishmaclaver answered 28/10, 2019 at 12:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.