--- - name: Install nginx apt: name: nginx - name: Remove nginx from init.d (may conflict with systemd service) file: path: /etc/init.d/nginx state: absent when: is_docker - name: Update rc.d to reflect init.d removal command: cmd: update-rc.d nginx remove when: is_docker - name: Create nginx user user: name: nginx create_home: false - name: Create nginx.conf file template: src: nginx.conf.jinja2 dest: /etc/nginx/nginx.conf owner: root group: root mode: 0644 notify: - Reload nginx - name: Create sites-available directory file: path: /etc/nginx/sites-available state: directory owner: root group: root mode: 0755 - name: Create sites-enabled directory file: path: /etc/nginx/sites-enabled state: directory owner: root group: root mode: 0744 - name: Disable nginx default site file: path: /etc/nginx/sites-enabled/default state: absent notify: - Reload nginx - name: Start and enable nginx service systemd_service: name: nginx state: started enabled: true - name: Add logrotate config copy: src: logrotate dest: /etc/logrotate.d/nginx owner: root group: root mode: 0644