--- - name: configure virtual hosts block: - name: create webroot file: path: "{{ server.root }}" state: directory loop: "{{ item.value.server }}" loop_control: loop_var: server - name: configure virtual host template: src: vhost.conf.j2 dest: "{{ nginx_conf_d_path }}/{{ item.key }}.conf" owner: root group: root mode: 0444 notify: reload nginx loop: "{{ nginx_vhosts | dict2items }}"