--- - name: is evomaintenance installed? stat: path: "/usr/share/scripts/evomaintenance.sh" register: evomaintenance_script check_mode: no - name: "Add evomaintenance trap for '{{ user.name }}'" lineinfile: state: present dest: '/home/{{ user.name }}/.profile' insertafter: EOF line: 'trap "sudo /usr/share/scripts/evomaintenance.sh" 0' when: evomaintenance_script.stat.exists