---
 - name: Install openresty
   become: yes
   package:
     name: openresty
     state: present


 - name: Copy conf.d
   become: yes
   copy:
     src: conf.d
     dest: /opt/openresty/nginx/
     owner: http
     group: http
     mode: 0660
     directory_mode: 0770

 - name: Copy main config
   become: yes
   copy:
     src: nginx.conf
     dest: /opt/openresty/nginx/conf/nginx.conf
     owner: http
     group: http
     mode: 0660
     validate: "/opt/openresty/nginx/sbin/nginx -t -c %s"


 # TODO when openresty is ready to go, populate /usr/lib/systemd/system/webserver.service from /usr/lib/systemd/system/openresty.service

 - name: Ensure service is started
   become: yes
   service:
     name: openresty
     enabled: yes
     state: restarted
