Kapisi/roles/WebServer/tasks/main.yml
2023-10-08 12:28:14 -05:00

86 lines
1.5 KiB
YAML

---
- name: Install openresty
become: yes
package:
name: "{{ item }}"
state: present
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
- systemd:
daemon_reload: true
when: servicefile.changed
become: yes
- name: Copy conf.d
become: yes
copy:
src: "conf.d/{{ inventory_hostname }}/"
dest: /opt/openresty/nginx/conf.d/
owner: http
group: http
mode: 0660
directory_mode: 0770
follow: true
register: confd
- name: Copy conf
become: yes
copy:
src: conf/
dest: /opt/openresty/nginx/conf/
owner: http
group: http
mode: 0660
follow: true
register: conf
- name: Populate security config
become: yes
template:
src: conf/sec.conf.j2
dest: /opt/openresty/nginx/conf/sec.conf
owner: http
group: http
mode: 0660
register: secconf
- name: Ensure default openresty service file is off.
become: yes
service:
name: openresty
state: stopped
enabled: no
- name: Ensure service is started
become: yes
when: conf.changed or confd.changed or secconf.changed
service:
name: "{{ item }}"
enabled: yes
state: restarted
loop:
- php-fpm
- webserver