New feature: upstream state (remove upstream if needed)

pull/22/head
Emilien Mantel 2016-05-11 17:21:52 +02:00
parent 4dcb5f44c6
commit af3930a58a
3 changed files with 18 additions and 0 deletions

View File

@ -11,6 +11,7 @@ Upstream params
- `name`: upstream name. Can be use in vhost with *proxy_pass http://upstream_name*
- `params`: list of param (hash, zone...)
- `servers`: each upstream MUST have at least 1 server
- `state`: Optional. Can be 'absent' or 'present'
Server params
-------------
@ -38,4 +39,5 @@ nginx_upstreams:
max_conns: 150
weight: 10
down: false
state: 'present'
```

View File

@ -12,4 +12,13 @@
src=etc/nginx/upstream/upstream.conf.j2
dest={{ nginx_etc_dir }}/conf.d/upstream-{{ item.name }}.conf
with_items: "{{ nginx_upstreams }}"
when: item.state is not defined or item.state == 'present'
notify: reload nginx
- name: FILE | Delete other upstreams
file: >
path={{ nginx_etc_dir }}/conf.d/upstream-{{ item.name }}.conf
state=absent
with_items: "{{ nginx_upstreams }}"
when: item.state is defined and item.state == 'absent'
notify: reload nginx

View File

@ -24,6 +24,13 @@
max_conns: 150
weight: 10
down: false
- name: 'test-absent'
servers:
- path: '127.0.0.1:80'
max_conns: 150
weight: 10
down: false
state: 'absent'
nginx_htpasswd:
- name: 'hello'
description: 'Please login!'