Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #107 from wkielas/master
Browse files Browse the repository at this point in the history
Add support for plain TCP loadbalancing
  • Loading branch information
jdauphant committed Mar 30, 2016
2 parents 54f228c + c59e79b commit af85239
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 3 deletions.
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ yum_epel_repo: epel
yum_base_repo: base

nginx_official_repo: False
nginx_official_repo_mainline: False

keep_only_specified: False

Expand Down Expand Up @@ -46,6 +47,8 @@ nginx_http_params:
- server_tokens off
- types_hash_max_size 2048

nginx_stream_params: []

nginx_sites:
default:
- listen 80 default_server
Expand All @@ -55,6 +58,7 @@ nginx_sites:
nginx_remove_sites: []

nginx_configs: {}
nginx_stream_configs: {}
nginx_remove_configs: []

nginx_auth_basic_files: {}
Expand Down
8 changes: 8 additions & 0 deletions tasks/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@
notify:
- reload nginx
tags: [configuration,nginx]

- name: Create the configurations for independent config file for streams
template: src=config_stream.conf.j2 dest={{nginx_conf_dir}}/conf.d/stream/{{ item }}.conf
with_items: "{{ nginx_stream_configs.keys() }}"
notify:
- reload nginx
tags: [configuration,nginx]
when: nginx_official_repo_mainline
1 change: 1 addition & 0 deletions tasks/ensure-dirs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- "sites-enabled"
- "auth_basic"
- "conf.d"
- "conf.d/stream"
tags: [configuration,nginx]

- name: Ensure log directory exist
Expand Down
15 changes: 13 additions & 2 deletions tasks/nginx-official-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
apt_repository: repo="deb http://nginx.org/packages/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx"
environment: "{{ nginx_env }}"
tags: [packages,nginx]
when: ansible_os_family == 'Debian'
when: ansible_os_family == 'Debian' and not nginx_official_repo_mainline

- name: Ensure APT official nginx repository (mainline)
apt_repository: repo="deb http://nginx.org/packages/mainline/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx"
environment: "{{ nginx_env }}"
tags: [packages,nginx]
when: ansible_os_family == 'Debian' and nginx_official_repo_mainline

- name: Ensure RPM official nginx key
rpm_key: key=http://nginx.org/keys/nginx_signing.key
Expand All @@ -23,4 +29,9 @@
- name: Ensure zypper official nginx repository
zypper_repository: repo="http://nginx.org/packages/sles/12" name="nginx" disable_gpg_check=yes
environment: "{{ nginx_env }}"
when: ansible_distribution == 'SLES' and ansible_distribution_version == '12'
when: ansible_distribution == 'SLES' and ansible_distribution_version == '12' and not nginx_official_repo_mainline

- name: Ensure zypper official nginx repository (mainline)
zypper_repository: repo="http://nginx.org/packages/mainline/sles/12" name="nginx" disable_gpg_check=yes
environment: "{{ nginx_env }}"
when: ansible_distribution == 'SLES' and ansible_distribution_version == '12' and nginx_official_repo_mainline
9 changes: 9 additions & 0 deletions templates/config_stream.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#{{ ansible_managed }}

{% for v in nginx_stream_configs[item] %}
{% if v.find('\n') != -1 %}
{{v}}
{% else %}
{% if v != "" %}{{ v.replace(";",";\n ").replace(" {"," {\n ").replace(" }"," \n}\n") }}{% if v.find('{') == -1%};
{% endif %}{% endif %}{% endif %}
{% endfor %}
11 changes: 11 additions & 0 deletions templates/nginx.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ http {
include {{ nginx_conf_dir }}/sites-enabled/*;
}

{% if nginx_official_repo_mainline %}
stream {

{% for v in nginx_stream_params %}
{{ v }};
{% endfor %}

include {{ nginx_conf_dir }}/conf.d/stream/*.conf;
}
{% endif %}

{% if nginx_daemon_mode == "off" %}
daemon off;
{% endif %}
6 changes: 5 additions & 1 deletion templates/nginx.repo.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[nginx]
name=nginx repo
{% if nginx_official_repo_mainline %}
baseurl=http://nginx.org/packages/mainline/{{"rhel" if ansible_distribution == "RedHat" else "centos"}}/{{ansible_distribution_version.split('.')[0]}}/{{ansible_architecture}}/
{% else %}
baseurl=http://nginx.org/packages/{{"rhel" if ansible_distribution == "RedHat" else "centos"}}/{{ansible_distribution_version.split('.')[0]}}/{{ansible_architecture}}/
enabled=1
{% endif %}
enabled=1

0 comments on commit af85239

Please sign in to comment.