diff --git a/ansible/roles/nginx/tasks/main.yml b/ansible/roles/nginx/tasks/main.yml index 9fb84b9..ceca079 100644 --- a/ansible/roles/nginx/tasks/main.yml +++ b/ansible/roles/nginx/tasks/main.yml @@ -3,11 +3,21 @@ apt: name: nginx -- name: Start and enable nginx service - service: +- 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 - state: started - enabled: true + create_home: false - name: Create nginx.conf file template: @@ -35,6 +45,19 @@ 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