- name: ensure git is installed
  package:
    name: git
  when: ansible_distribution != "MacOSX"
  register: git_install

- name: set git global user.email if not already set
  shell: git config --global user.email || git config --global user.email "noreply@example.com"

- name: set git global user.name if not already set
  shell: git config --global user.name  || git config --global user.name  "Ansible Test Runner"

- name: Create a directory for installing collections and creating git repositories
  file:
    path: '{{ item }}'
    state: directory
  loop:
    - '{{ galaxy_dir }}/ansible_collections'
    - '{{ galaxy_dir }}/development/ansible_test'
