generated from dmitriysafronov/ansible_role-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dmitriy Safronov <zimniy@cyberbrain.pw>
- Loading branch information
1 parent
3415f4a
commit 93d5387
Showing
7 changed files
with
119 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# ansible_role-template | ||
# ansible_role-nginx_stream | ||
|
||
Install & configure nginx stream module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- name: (Re)start nginx service | ||
ansible.builtin.systemd: | ||
state: restarted | ||
enabled: true | ||
daemon_reload: true | ||
name: "nginx.service" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
collections: [] | ||
dependencies: [] | ||
galaxy_info: | ||
author: template | ||
description: template | ||
author: Dmitriy Safronov | ||
description: Install & configure nginx stream module. | ||
license: Apache-2.0 | ||
min_ansible_version: "2.16" | ||
namespace: template | ||
role_name: template | ||
namespace: dmitriysafronov | ||
role_name: nginx_stream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
|
||
- name: Install nginx stream module | ||
ansible.builtin.package: | ||
name: "{{ nginx_stream.variant | default('libnginx-mod-stream') }}" | ||
state: present | ||
|
||
- name: Create nginx streams directories | ||
ansible.builtin.file: | ||
path: "/etc/nginx/{{ item }}" | ||
state: directory | ||
mode: '0700' | ||
owner: root | ||
group: root | ||
with_items: | ||
- streams-available | ||
- streams-enabled | ||
|
||
- name: Create nginx stream config file | ||
ansible.builtin.template: | ||
src: nginx_stream.module.j2 | ||
dest: "/etc/nginx/modules-available/stream_configuration.conf" | ||
mode: '0600' | ||
owner: root | ||
group: root | ||
notify: (Re)start nginx service | ||
|
||
- name: Create nginx stream config symlbolic link | ||
when: (nginx_stream.disabled is not defined) or (nginx_stream.disabled == None) or (not nginx_stream.disabled | bool) | ||
ansible.builtin.file: | ||
src: "/etc/nginx/modules-available/stream_configuration.conf" | ||
dest: "/etc/nginx/modules-enabled/stream_configuration.conf" | ||
state: link | ||
notify: (Re)start nginx service | ||
|
||
- name: Delete nginx stream config symlbolic link | ||
when: | ||
- nginx_stream.disabled is defined | ||
- nginx_stream.disabled != None | ||
- nginx_stream.disabled | bool | ||
ansible.builtin.file: | ||
path: "/etc/nginx/modules-enabled/stream_configuration.conf" | ||
state: absent | ||
notify: (Re)start nginx service | ||
|
||
- name: Configure streams | ||
when: | ||
- nginx_stream.streams is defined | ||
- nginx_stream.streams != None | ||
ansible.builtin.include_tasks: | ||
file: streams.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
|
||
- name: Fail on spaces in streams config names | ||
ansible.builtin.assert: | ||
that: | ||
- "' ' not in item.key" | ||
with_dict: "{{ nginx_stream.streams }}" | ||
no_log: true | ||
|
||
- name: Create nginx streams-avalable file | ||
when: | ||
- item.value.content is defined | ||
- item.value.content != None | ||
- item.value.content | length > 0 | ||
with_dict: "{{ nginx_stream.streams }}" | ||
ansible.builtin.template: | ||
src: nginx_stream.streams.j2 | ||
dest: "/etc/nginx/streams-available/{{ item.key }}" | ||
mode: "0600" | ||
owner: root | ||
group: root | ||
no_log: true | ||
notify: (Re)start nginx service | ||
|
||
- name: Create nginx streams-enabled symlbolic link | ||
when: | ||
- item.value.enabled is defined | ||
- item.value.enabled != None | ||
- item.value.enabled | bool | ||
with_dict: "{{ nginx_stream.streams }}" | ||
ansible.builtin.file: | ||
src: "/etc/nginx/streams-available/{{ item.key }}" | ||
dest: "/etc/nginx/streams-enabled/{{ item.key }}" | ||
state: link | ||
no_log: true | ||
notify: (Re)start nginx service | ||
|
||
- name: Delete nginx streams-enabled symbolic link | ||
when: (item.value.enabled is not defined) or (item.value.enabled == None) or (not item.value.enabled | bool) | ||
with_dict: "{{ nginx_stream.streams }}" | ||
ansible.builtin.file: | ||
path: "/etc/nginx/streams-enabled/{{ item.key }}" | ||
state: absent | ||
no_log: true | ||
notify: (Re)start nginx service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{{ ansible_managed | comment }} | ||
|
||
stream { | ||
{{ nginx_stream.config | default() | indent(width=4, first=True) }} | ||
|
||
include /etc/nginx/streams-enabled/*; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{ ansible_managed | comment }} | ||
|
||
{{ item.value.content }} |