- name: Install monit apt: name=monit state=present - name: Register monit config files template: src=monitrc.j2 dest=/etc/monitrc mode=700 register: web_interface_monit_config - name: Register monit config files template: src={{ item }}.j2 dest=/etc/monit/conf.d/{{ item }} mode=u=rw,g=r,o=r with_items: - web_interface register: web_interface_monit_config - name: Reload Monit command: bash -lc "monit reload" when: web_interface_monit_config.changed - name: Give deployer user access to monit lineinfile: 'dest=/etc/sudoers state=present line="{{ deployer_user.name }} ALL = (ALL) ALL, NOPASSWD: /usr/bin/monit"'