Add playbooks/nginx.yml
This commit is contained in:
90
playbooks/nginx.yml
Normal file
90
playbooks/nginx.yml
Normal file
@@ -0,0 +1,90 @@
|
||||
- name: install nginx from official repo
|
||||
hosts: alma
|
||||
become: true
|
||||
|
||||
tasks:
|
||||
- name: configure official nginx repo
|
||||
yum_repository:
|
||||
name: nginx-stable
|
||||
description: nginx stable
|
||||
baseurl: https://nginx.org/packages/centos/$releasever/$basearch/
|
||||
enabled: true
|
||||
gpgcheck: true
|
||||
gpgkey: https://nginx.org/keys/nginx_signing.key
|
||||
module_hotfixes: true
|
||||
|
||||
- name: install nginx
|
||||
dnf:
|
||||
name: nginx
|
||||
state: present
|
||||
|
||||
- name: enable and start nginx
|
||||
service:
|
||||
name: nginx
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: install php and modules
|
||||
dnf:
|
||||
name:
|
||||
- php
|
||||
- php-fpm
|
||||
- php-opcache
|
||||
|
||||
- name: enable and start php-fpm
|
||||
service:
|
||||
name: php-fpm
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: remove default config
|
||||
ansible.builtin.file:
|
||||
path: /etc/nginx/conf.d/default.conf
|
||||
state: absent
|
||||
|
||||
- name: replace base nginx configuration
|
||||
copy:
|
||||
src: ../config/nginx
|
||||
dest: /etc/nginx/nginx.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- name: create directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
loop:
|
||||
- /etc/nginx/sites-available
|
||||
- /etc/nginx/sites-enabled
|
||||
|
||||
- name: make tobiastime available
|
||||
copy:
|
||||
src: ../nginx/tobiastime
|
||||
dest: /etc/nginx/sites-available/tobiastime
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- name: make tobiastime enabled
|
||||
file:
|
||||
src: /etc/nginx/sites-available/tobiastime
|
||||
dest: /etc/nginx/sites-enabled/tobiastime
|
||||
state: link
|
||||
|
||||
- name: copy tobiastime
|
||||
ansible.builtin.synchronize:
|
||||
src: ../nginx/tobiastime_data
|
||||
dest: /var/www
|
||||
recursive: yes
|
||||
|
||||
- name: copy snippets
|
||||
ansible.builtin.synchronize:
|
||||
src: ../nginx/snippets
|
||||
dest: /etc/nginx/
|
||||
recursive: yes
|
||||
|
||||
- name: Reload nginx
|
||||
systemd:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
Reference in New Issue
Block a user