---
  - name: Install git via yum in latest version
    become: yes
    become_user: root
    yum:
      name: git.x86_64
      state: latest
      disable_gpg_check: true
      
  - name: check if {{ path_init }} exists
    become: yes
    file:
      path: "{{ path_init }}"
      owner: "{{ user_name }}"
      group: "{{ user_group }}"
      mode: '0755'
      state: directory

  - name: Copy file .gitignore with owner and permissions 
    copy:
      src: ./files/gitignore
      dest: "{{ path_init }}/.gitignore"
      owner: "{{ user_name }}"
      group: "{{ user_group }}"
      mode: '0644'
      
  - name: check if {{ path_init }}/.git exists
    stat:
      path: "{{ path_init }}/.git"
    register: p
    changed_when: false
    
  - debug:
      msg: " Path exists not and is not a directory"
    when: p.stat.exists == false
      
  - name: Initialisiere leeres Repo innerhalb von {{ path_init }}
    command: git init {{ path_init }}/
    when: p.stat.exists == false
    
  - name: commit changes to git
    shell: |
      git add .
      git -c user.name='{{ user_name }} Playbook' -c user.email='{{ user_name }}@playbook' commit -m "Initialisiere GIT"
      exit 0
    args:
      chdir: "{{ path_init }}"
    when: p.stat.exists == false


      

















