2020-10-08 16:33:19 -05:00
|
|
|
---
|
|
|
|
- name: Install openresty
|
|
|
|
become: yes
|
|
|
|
package:
|
2022-09-15 14:23:34 -05:00
|
|
|
name: "{{ item }}"
|
2020-10-08 16:33:19 -05:00
|
|
|
state: present
|
2022-09-15 14:23:34 -05:00
|
|
|
loop:
|
|
|
|
- openresty
|
|
|
|
- php-fpm
|
|
|
|
|
|
|
|
- name: Copy PHP config
|
|
|
|
become: yes
|
|
|
|
copy:
|
|
|
|
src: php.ini
|
|
|
|
dest: /etc/php/php.ini
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
|
|
|
|
|
|
|
- name: Copy Webserver config
|
|
|
|
become: yes
|
|
|
|
copy:
|
|
|
|
src: webserver.service
|
|
|
|
dest: /usr/lib/systemd/system/webserver.service
|
|
|
|
owner: http
|
|
|
|
group: http
|
|
|
|
mode: 0660
|
|
|
|
register: servicefile
|
2020-10-08 16:33:19 -05:00
|
|
|
|
2022-09-15 14:23:34 -05:00
|
|
|
- systemd:
|
|
|
|
daemon_reload: true
|
|
|
|
when: servicefile.changed
|
|
|
|
become: yes
|
2020-10-08 16:33:19 -05:00
|
|
|
|
|
|
|
- name: Copy conf.d
|
|
|
|
become: yes
|
|
|
|
copy:
|
2023-10-08 12:28:14 -05:00
|
|
|
src: "conf.d/{{ inventory_hostname }}/"
|
|
|
|
dest: /opt/openresty/nginx/conf.d/
|
2020-10-08 16:33:19 -05:00
|
|
|
owner: http
|
|
|
|
group: http
|
|
|
|
mode: 0660
|
|
|
|
directory_mode: 0770
|
2023-10-08 12:28:14 -05:00
|
|
|
follow: true
|
2022-09-15 14:23:34 -05:00
|
|
|
register: confd
|
2020-10-08 16:33:19 -05:00
|
|
|
|
2022-09-15 14:23:34 -05:00
|
|
|
- name: Copy conf
|
2020-10-08 16:33:19 -05:00
|
|
|
become: yes
|
|
|
|
copy:
|
2022-09-15 14:23:34 -05:00
|
|
|
src: conf/
|
|
|
|
dest: /opt/openresty/nginx/conf/
|
2020-10-08 16:33:19 -05:00
|
|
|
owner: http
|
|
|
|
group: http
|
|
|
|
mode: 0660
|
2023-10-08 12:28:14 -05:00
|
|
|
follow: true
|
2022-09-15 14:23:34 -05:00
|
|
|
register: conf
|
2020-10-08 16:33:19 -05:00
|
|
|
|
2022-12-18 22:21:39 -06:00
|
|
|
- name: Populate security config
|
|
|
|
become: yes
|
|
|
|
template:
|
2023-10-08 12:28:14 -05:00
|
|
|
src: conf/sec.conf.j2
|
2022-12-18 22:21:39 -06:00
|
|
|
dest: /opt/openresty/nginx/conf/sec.conf
|
|
|
|
owner: http
|
|
|
|
group: http
|
|
|
|
mode: 0660
|
2023-10-08 12:28:14 -05:00
|
|
|
register: secconf
|
2022-12-18 22:21:39 -06:00
|
|
|
|
|
|
|
|
2022-09-15 14:23:34 -05:00
|
|
|
- name: Ensure default openresty service file is off.
|
|
|
|
become: yes
|
|
|
|
service:
|
|
|
|
name: openresty
|
|
|
|
state: stopped
|
2022-11-20 20:03:01 -06:00
|
|
|
enabled: no
|
2020-10-08 16:33:19 -05:00
|
|
|
|
|
|
|
- name: Ensure service is started
|
|
|
|
become: yes
|
2022-12-18 22:21:39 -06:00
|
|
|
when: conf.changed or confd.changed or secconf.changed
|
2020-10-08 16:33:19 -05:00
|
|
|
service:
|
2022-11-20 20:03:01 -06:00
|
|
|
name: "{{ item }}"
|
2020-10-08 16:33:19 -05:00
|
|
|
enabled: yes
|
|
|
|
state: restarted
|
2022-09-15 14:23:34 -05:00
|
|
|
loop:
|
|
|
|
- php-fpm
|
|
|
|
- webserver
|