--- # ---------- # /etc/motd # ---------- - name: (motd.yml) Check if /etc/motd.ORIG exist stat: path: /etc/motd.ORIG register: motd_orig_exist - name: (motd.yml) Check if /etc/motd exist stat: path: /etc/motd register: motd_exist - name: (motd.yml) Backup existing file /etc/motd command: cp -a /etc/motd /etc/motd.ORIG when: - motd_exist.stat.exists == True - motd_orig_exist.stat.exists == False - name: (motd.yml) create /etc/motd shell: figlet {{ ansible_hostname }} > /etc/motd when: motd_orig_exist.stat.exists == False