Migrated to ansible roles
This commit is contained in:
10
roles/nginx-loadbalancer/meta/main.yml
Normal file
10
roles/nginx-loadbalancer/meta/main.yml
Normal file
@ -0,0 +1,10 @@
|
||||
galaxy_info:
|
||||
author: strNophix
|
||||
description: Nginx Loadbalancer Role
|
||||
|
||||
license: MIT
|
||||
min_ansible_version: 2.1
|
||||
|
||||
galaxy_tags: []
|
||||
|
||||
dependencies: []
|
24
roles/nginx-loadbalancer/tasks/main.yml
Normal file
24
roles/nginx-loadbalancer/tasks/main.yml
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
# tasks file for nginx-loadbalancer
|
||||
- name: Install nginx
|
||||
package:
|
||||
name: nginx
|
||||
state: present
|
||||
update_cache: yes
|
||||
become: true
|
||||
- name: Move config to vm
|
||||
ansible.builtin.template:
|
||||
src: ./templates/loadbalancer.cfg.j2
|
||||
dest: /etc/nginx/sites-available/nginx.cfg
|
||||
become: true
|
||||
- name: Enable loadbalancer config
|
||||
file:
|
||||
src: /etc/nginx/sites-available/nginx.cfg
|
||||
dest: /etc/nginx/sites-enabled/default
|
||||
state: link
|
||||
become: true
|
||||
- name: Restart nginx
|
||||
service:
|
||||
name: nginx
|
||||
state: restarted
|
||||
become: true
|
13
roles/nginx-loadbalancer/templates/loadbalancer.cfg.j2
Normal file
13
roles/nginx-loadbalancer/templates/loadbalancer.cfg.j2
Normal file
@ -0,0 +1,13 @@
|
||||
upstream app {
|
||||
{% for host in groups['webserver'] %}
|
||||
server {{ host }}:80;
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
location / {
|
||||
proxy_pass http://app;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user