1
0
Fork 0
mirror of https://github.com/DO1JLR/ansible_role_nginx.git synced 2024-08-16 16:19:48 +02:00
ansible_role_nginx/tasks/nginx.yml

78 lines
1.8 KiB
YAML
Raw Normal View History

2020-11-02 04:51:35 +01:00
---
- name: Copy main nginx configuration file
become: true
2021-10-18 00:42:23 +02:00
ansible.builtin.template:
src: 'templates/nginx/nginx.conf.j2'
2020-11-02 04:51:35 +01:00
dest: '/etc/nginx/'
owner: root
group: root
mode: 'u=rw,g=r,o=r'
notify:
- systemctl reload nginx
2020-11-02 04:51:35 +01:00
- name: Create 'private' directory
become: true
ansible.builtin.file:
path: '/etc/nginx/private'
state: directory
owner: root
group: root
mode: 'u=rwx,g=rx,o=rx'
- name: Create new dhparam of size '{{ nginx__dhparam_size }}'
become: true
community.crypto.openssl_dhparam:
path: '/etc/nginx/private/dhparam.pem'
size: '{{ nginx__dhparam_size | mandatory }}'
notify:
- systemctl reload nginx
2020-11-02 04:51:35 +01:00
- name: Create 'sites-available' directory
become: true
ansible.builtin.file:
2020-11-02 04:51:35 +01:00
path: '/etc/nginx/sites-available'
state: directory
owner: root
group: root
mode: 'u=rwx,g=rx,o=rx'
- name: Create 'sites-enabled' directory
become: true
ansible.builtin.file:
2020-11-02 04:51:35 +01:00
path: '/etc/nginx/sites-enabled'
state: directory
owner: root
group: root
mode: 'u=rwx,g=rx,o=rx'
# Todo: Reconsider best practices
- name: Remove default site config from package installation
become: true
ansible.builtin.file:
path: '{{ item }}'
state: absent
with_items:
- '/etc/nginx/sites-enabled/default'
- '/etc/nginx/sites-available/default'
2020-11-02 04:51:35 +01:00
- name: Create 'snippets' directory
become: true
ansible.builtin.file:
2020-11-02 04:51:35 +01:00
path: '/etc/nginx/snippets'
state: directory
owner: root
group: root
mode: 'u=rwx,g=rx,o=rx'
- name: Copy nginx snippet files
become: true
ansible.builtin.copy:
2021-02-04 14:35:47 +01:00
src: '{{ nginx__snippet_path }}{{ item }}'
2020-11-02 04:51:35 +01:00
dest: '/etc/nginx/snippets/{{ item }}'
owner: root
group: root
mode: 'u=rw,g=r,o=r'
2021-02-04 14:35:47 +01:00
with_items: '{{ nginx__snippet_files }}'
2020-11-02 04:51:35 +01:00
notify:
- systemctl reload nginx