--- - name: Check if custom sapenv.sh exists stat: path: "{{ pas_sapenv_custom_path }}" register: custom_sapenv_stats - name: Create copy of original .sapenv.sh file copy: src: "{{ pas_sapenv_original_path }}" dest: "{{ pas_sapenv_custom_path }}" remote_src: yes when: custom_sapenv_stats.stat.exists is false - name: Remove all "tset" statements from the file. PS! This is important when calling Ansible from Jenkins lineinfile: path: "{{ pas_sapenv_custom_path }}" state: absent regexp: "tset -I -Q" when: custom_sapenv_stats.stat.exists is false - name: Check if custom dbenv.sh exists stat: path: "{{ pas_dbenv_custom_path }}" register: custom_sapenv_stats - name: Create copy of original .dbenv.sh file copy: src: "{{ pas_dbenv_original_path }}" dest: "{{ pas_dbenv_custom_path }}" remote_src: yes when: custom_sapenv_stats.stat.exists is false - name: Remove all "tset" statements from the file. PS! This is important when calling Ansible from Jenkins lineinfile: path: "{{ pas_dbenv_custom_path }}" state: absent regexp: "tset -I -Q" when: custom_sapenv_stats.stat.exists is false