--- - 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 {{ user_name }}/.git exists stat: path: {{ user_name }}/.git register: p - debug: msg: " Path exists and is a directory" when: p.stat.isdir is defined and p.stat.isdir #- name: check if {{ path_init }}/.git exists #shell: ls -ld {{ path_init }}/.git #register: result #ignore_errors: true #- debug: #msg: "{{ result }}" #- name: Initialisiere leeres Repo innerhalb von {{ path_init }} #command: git init {{ path_init }}/ #when: result.stdout == '' - 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 }}"