2014-08-17 00:35:57 +03:00
|
|
|
---
|
2023-08-22 21:33:19 +03:00
|
|
|
- name: Remove nginx apt signing key from apt-key
|
2023-08-10 22:44:47 +02:00
|
|
|
ansible.builtin.apt_key:
|
2023-08-23 22:22:51 +03:00
|
|
|
id: "053473772654754373614404074646527257655730117366337542"
|
2023-08-22 21:33:19 +03:00
|
|
|
state: absent
|
|
|
|
tags:
|
|
|
|
- packages
|
|
|
|
- nginx
|
|
|
|
|
|
|
|
- name: Download nginx apt signing key
|
|
|
|
ansible.builtin.get_url:
|
|
|
|
url: https://nginx.org/keys/nginx_signing.key
|
|
|
|
dest: /usr/share/keyrings/nginx_signing.key
|
|
|
|
owner: root
|
|
|
|
group: root
|
2023-08-23 22:22:51 +03:00
|
|
|
mode: "0644"
|
2024-06-25 08:11:59 +03:00
|
|
|
checksum: sha256:55385da31d198fa6a5012d40ae98ecb272a6c4e8fffffba94719ffd3e87de37a
|
2023-08-22 21:33:19 +03:00
|
|
|
register: download_nginx_signing_key
|
|
|
|
tags:
|
2023-08-10 22:44:47 +02:00
|
|
|
- packages
|
2023-08-22 21:33:19 +03:00
|
|
|
- nginx
|
2014-08-17 00:35:57 +03:00
|
|
|
|
2015-05-25 00:15:49 +03:00
|
|
|
- name: Add nginx.org repo
|
2023-08-10 22:44:47 +02:00
|
|
|
ansible.builtin.template:
|
|
|
|
src: nginx_org_sources.list.j2
|
|
|
|
dest: /etc/apt/sources.list.d/nginx_org_sources.list
|
|
|
|
owner: root
|
|
|
|
group: root
|
2023-08-23 22:22:51 +03:00
|
|
|
mode: "0644"
|
2019-03-17 17:29:15 +02:00
|
|
|
register: add_nginx_apt_repository
|
2023-08-10 22:44:47 +02:00
|
|
|
tags:
|
|
|
|
- nginx
|
|
|
|
- packages
|
2014-08-17 00:35:57 +03:00
|
|
|
|
2019-03-17 17:29:15 +02:00
|
|
|
- name: Update apt cache
|
2023-08-22 21:33:19 +03:00
|
|
|
ansible.builtin.apt: # noqa no-handler
|
2022-09-10 22:33:19 +03:00
|
|
|
update_cache: true
|
2023-08-23 22:22:51 +03:00
|
|
|
when: (download_nginx_signing_key.status_code is defined and download_nginx_signing_key.status_code == 200) or add_nginx_apt_repository is changed
|
2019-03-17 17:29:15 +02:00
|
|
|
|
2021-09-27 10:48:24 +03:00
|
|
|
- name: Install nginx
|
2023-08-10 22:44:47 +02:00
|
|
|
ansible.builtin.apt:
|
|
|
|
pkg: nginx
|
|
|
|
cache_valid_time: 3600
|
|
|
|
state: present
|
|
|
|
tags:
|
|
|
|
- nginx
|
|
|
|
- packages
|
2014-08-17 00:35:57 +03:00
|
|
|
|
2017-01-30 15:43:03 +02:00
|
|
|
- name: Copy nginx.conf
|
2023-08-10 22:44:47 +02:00
|
|
|
ansible.builtin.template:
|
|
|
|
src: nginx.conf.j2
|
|
|
|
dest: /etc/nginx/nginx.conf
|
2023-08-23 22:22:51 +03:00
|
|
|
mode: "0644"
|
2023-08-10 22:44:47 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
2017-01-30 15:43:03 +02:00
|
|
|
notify:
|
|
|
|
- reload nginx
|
|
|
|
tags: nginx
|
|
|
|
|
|
|
|
- name: Copy extra nginx configs
|
2023-08-10 22:44:47 +02:00
|
|
|
ansible.builtin.copy:
|
|
|
|
src: "{{ item }}"
|
2023-08-23 22:22:51 +03:00
|
|
|
dest: /etc/nginx/{{ item }}
|
|
|
|
mode: "0644"
|
2023-08-10 22:44:47 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
2018-04-02 15:52:51 +03:00
|
|
|
loop:
|
2015-01-24 13:05:42 +03:00
|
|
|
- extra-security.conf
|
2015-02-10 23:04:28 +03:00
|
|
|
- fastcgi_cache
|
2014-08-17 00:35:57 +03:00
|
|
|
notify:
|
|
|
|
- reload nginx
|
|
|
|
tags: nginx
|
|
|
|
|
|
|
|
- name: Remove default nginx vhost
|
2023-08-10 22:44:47 +02:00
|
|
|
ansible.builtin.file:
|
|
|
|
path: /etc/nginx/conf.d/default.conf
|
|
|
|
state: absent
|
2014-08-17 00:35:57 +03:00
|
|
|
tags: nginx
|
|
|
|
|
2015-02-19 18:49:39 +03:00
|
|
|
- name: Create fastcgi cache dir
|
2023-08-10 22:44:47 +02:00
|
|
|
ansible.builtin.file:
|
|
|
|
path: /var/cache/nginx/cached/fastcgi
|
|
|
|
state: directory
|
|
|
|
owner: nginx
|
|
|
|
group: nginx
|
2023-08-23 22:22:51 +03:00
|
|
|
mode: "0755"
|
2016-04-15 12:29:35 +03:00
|
|
|
tags: nginx
|
2014-08-17 00:35:57 +03:00
|
|
|
|
2017-10-03 15:02:38 +03:00
|
|
|
- name: Configure nginx virtual hosts
|
2022-09-10 18:09:12 +03:00
|
|
|
ansible.builtin.include_tasks: vhosts.yml
|
2015-12-10 00:14:47 +02:00
|
|
|
when: nginx_vhosts is defined
|
2014-08-27 20:03:34 +03:00
|
|
|
tags: nginx
|
|
|
|
|
2018-04-26 17:09:09 +03:00
|
|
|
- name: Configure WordPress
|
2022-09-10 18:09:12 +03:00
|
|
|
ansible.builtin.include_tasks: wordpress.yml
|
2018-04-26 17:09:09 +03:00
|
|
|
when: nginx_vhosts is defined
|
|
|
|
tags: wordpress
|
|
|
|
|
2015-06-04 23:30:06 +03:00
|
|
|
- name: Configure blank nginx vhost
|
2023-08-10 22:44:47 +02:00
|
|
|
ansible.builtin.template:
|
|
|
|
src: blank-vhost.conf.j2
|
|
|
|
dest: "{{ nginx_confd_path }}/blank-vhost.conf"
|
2023-08-23 22:22:51 +03:00
|
|
|
mode: "0644"
|
2023-08-10 22:44:47 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
2015-06-04 23:30:06 +03:00
|
|
|
notify:
|
|
|
|
- reload nginx
|
2015-06-06 00:05:09 +03:00
|
|
|
tags: nginx
|
2015-06-04 23:30:06 +03:00
|
|
|
|
2014-08-17 00:35:57 +03:00
|
|
|
- name: Configure munin vhost
|
2023-08-10 22:44:47 +02:00
|
|
|
ansible.builtin.copy:
|
|
|
|
src: munin.conf
|
|
|
|
dest: /etc/nginx/conf.d/munin.conf
|
2023-08-23 22:22:51 +03:00
|
|
|
mode: "0644"
|
2023-08-10 22:44:47 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
2014-08-17 00:35:57 +03:00
|
|
|
notify:
|
|
|
|
- reload nginx
|
|
|
|
tags: nginx
|
|
|
|
|
2016-06-27 19:13:20 +03:00
|
|
|
- name: Start and enable nginx service
|
2023-08-10 22:44:47 +02:00
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: nginx
|
|
|
|
state: started
|
|
|
|
enabled: true
|
2014-08-17 00:35:57 +03:00
|
|
|
tags: nginx
|
2014-08-27 20:00:42 +03:00
|
|
|
|
2018-04-26 17:12:22 +03:00
|
|
|
- name: Configure Let's Encrypt
|
2022-09-10 18:09:12 +03:00
|
|
|
ansible.builtin.include_tasks: letsencrypt.yml
|
2018-04-26 11:00:47 +03:00
|
|
|
tags: letsencrypt
|
|
|
|
|
2014-08-27 20:00:42 +03:00
|
|
|
# vim: set ts=2 sw=2:
|