--- - name: Add nginx repository apt_repository: repo='deb http://nginx.org/packages/ubuntu/ precise nginx' state=present update_cache=yes tags: [nginx, repo] - name: Add nginx repository signing key apt_key: url=http://nginx.org/keys/nginx_signing.key id=7BD9BF62 state=present tags: [nginx, repo] - name: Install nginx apt: pkg=nginx state=latest tags: [nginx, install] - name: Ensure nginx config directories exist file: path={{ item }} state=directory with_items: - /etc/nginx - /etc/nginx/sites-available - /etc/nginx/sites-enabled tags: [nginx] - name: Remove default nginx configs file: path=/etc/nginx/sites-available/default state=absent with_items: - /etc/nginx/sites-available/default - /etc/nginx/sites-enabled/default - /etc/nginx/conf.d notify: restart nginx tags: [nginx, config] - name: Allow tcp/80 and tcp/443 for HTTP ufw: rule=allow insert={{ item.num }} proto=tcp port={{ item.port }} with_items: - { num: 1, port: 80 } - { num: 2, port: 443 } sudo: true tags: [nginx, ufw]