mirror of
https://github.com/kemko/frontend-nginx-role.git
synced 2026-01-01 15:45:43 +03:00
74 lines
1.5 KiB
YAML
74 lines
1.5 KiB
YAML
---
|
|
|
|
- name: "Install nginx repository"
|
|
yum_repository:
|
|
name: "nginx-{{ nginx_branch }}"
|
|
description: "nginx {{ nginx_branch }} repository"
|
|
baseurl: "{{ nginx_repo }}"
|
|
gpgcheck: true
|
|
gpgkey: "https://nginx.org/keys/nginx_signing.key"
|
|
enabled: true
|
|
state: "present"
|
|
tags: ["packages"]
|
|
|
|
- name: "Install nginx package"
|
|
yum:
|
|
name: "nginx-{{ nginx_version }}"
|
|
state: "present"
|
|
tags: ["packages"]
|
|
|
|
- name: Enable and start nginx
|
|
systemd:
|
|
name: nginx
|
|
enabled: true
|
|
state: started
|
|
when: nginx_start
|
|
|
|
- name: Disable and stop nginx
|
|
systemd:
|
|
name: nginx
|
|
enabled: true
|
|
state: started
|
|
when: not nginx_start
|
|
|
|
- name: "Copy main nginx config"
|
|
template:
|
|
src: nginx.conf.j2
|
|
dest: /etc/nginx/nginx.conf
|
|
notify: Reload nginx
|
|
tags: ["configs"]
|
|
|
|
- name: "Copy nginx default server config"
|
|
template:
|
|
src: conf.d/default.conf.j2
|
|
dest: /etc/nginx/conf.d/default.conf
|
|
notify: Reload nginx
|
|
tags: ["configs"]
|
|
|
|
- name: "Download upstreams config"
|
|
get_url:
|
|
url: "{{ nginx_upstreams_url }}"
|
|
dest: "/tmp/nginx_upstreams.yml"
|
|
force: true
|
|
register: "nginx_upstreams_download_result"
|
|
tags:
|
|
- configs
|
|
- upstreams
|
|
|
|
- name: "Read upstreams config for nginx"
|
|
slurp:
|
|
src: "/tmp/nginx_upstreams.yml"
|
|
register: upstreams_slurped
|
|
tags:
|
|
- configs
|
|
- upstreams
|
|
|
|
- name: "Generate nginx upstreams config"
|
|
template:
|
|
src: conf.d/upstreams.conf.j2
|
|
dest: /etc/nginx/conf.d/upstreams.conf
|
|
notify: Reload nginx
|
|
tags:
|
|
- configs
|
|
- upstreams
|