--- - block: - name: Add default page configuration file template: src: etc/nginx/sites-available/vhost.j2 dest: "/etc/nginx/sites-available/{{ item.key }}" owner: root group: root mode: 0640 with_dict: nginx_vhosts notify: __nginx_reload - name: Enable default page file: src: "/etc/nginx/sites-available/{{ item.key }}" dest: "/etc/nginx/sites-enabled/{{ item.key }}" owner: root group: root state: link with_dict: nginx_vhosts notify: __nginx_reload when: nginx_vhosts is defined become: True become_user: root