--- - name: needrestart | install apt: name: needrestart state: present update_cache: true - name: needrestart | configure auto restart copy: dest: /etc/needrestart/conf.d/override.conf content: | $nrconf{restart} = 'a'; mode: '0644' - name: needrestart | configure exclusions template: src: needrestart_exclude.j2 dest: /etc/needrestart/conf.d/exclude.conf mode: '0644' when: needrestart_exclude is defined