- hosts: gitserver
  vars:
    domain: "forge.myforge.fr"
    git_repos: /home/git
    git_user: git
  vars_prompt:
    - name: repo_name
      prompt: "What is the name of the new repository's you need to create?"
      private: false

  tasks:
    - name: make a bare repo named "{{ repo_name }}"
      ansible.builtin.shell: "git init --bare --shared {{ repo_name }}.git"
      args:
        chdir: "{{ git_repos }}"
        creates: "{{ repo_name }}.git"
      become_user: "{{ git_user }}"

    - name: Change repo's group and permissions
      ansible.builtin.file:
        path: "{{ git_repos }}/{{ repo_name }}.git"
        state: directory
        group: git
        mode: '0770'
        recurse: yes
