Compare commits
4 Commits
6aabccbe75
...
e3527bf5fe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3527bf5fe | ||
|
|
65d5d64222 | ||
|
|
20c24f2f1b | ||
|
|
05714898eb |
@@ -3,7 +3,7 @@
|
|||||||
namespace: uumas
|
namespace: uumas
|
||||||
name: general
|
name: general
|
||||||
description: General roles
|
description: General roles
|
||||||
version: 0.5.12
|
version: 0.5.13
|
||||||
readme: README.md
|
readme: README.md
|
||||||
authors:
|
authors:
|
||||||
- uumas
|
- uumas
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
Installs caddy https server
|
Installs caddy
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
argument_specs:
|
argument_specs:
|
||||||
main:
|
main:
|
||||||
short_description: Installs caddy
|
description: Installs caddy
|
||||||
options:
|
options:
|
||||||
caddy_admin_email:
|
caddy_admin_email:
|
||||||
description: Email address used for ssl certs
|
description: Email address used for ssl certs
|
||||||
|
|||||||
3
roles/compatcheck/README.md
Normal file
3
roles/compatcheck/README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Checks that the host is runing a supported os.
|
||||||
|
Supported distros and versions are defined by the compatcheck_supported_distros variable.
|
||||||
|
This role is used by other roles to check compatibility.
|
||||||
2
roles/example/README.md
Normal file
2
roles/example/README.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
This role is just an example.
|
||||||
|
It pings the host, if example_ping is set to true.
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
argument_specs:
|
argument_specs:
|
||||||
main:
|
main:
|
||||||
short_description: Prometheus node exporter
|
description: Installs and configures prometheus node exporter to listen on local ipv4 address
|
||||||
options:
|
options:
|
||||||
local_network:
|
local_network:
|
||||||
description: The local ipv4 network block, listen address is taken from this block
|
description: The local ipv4 network block, listen address is taken from this block
|
||||||
|
|||||||
1
roles/raw_python/README.md
Normal file
1
roles/raw_python/README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Installs python using only the raw module
|
||||||
5
roles/raw_python/meta/argument_specs.yaml
Normal file
5
roles/raw_python/meta/argument_specs.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
argument_specs:
|
||||||
|
main:
|
||||||
|
description: Installs python using only the raw module
|
||||||
|
options: {}
|
||||||
31
roles/raw_python/tasks/main.yaml
Normal file
31
roles/raw_python/tasks/main.yaml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
- name: Check ansible dependencies
|
||||||
|
ansible.builtin.raw: which python3
|
||||||
|
register: _python_test
|
||||||
|
failed_when: false
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Install ansible dependencies
|
||||||
|
when: _python_test.rc != 0
|
||||||
|
block:
|
||||||
|
- name: Get os release information
|
||||||
|
ansible.builtin.raw: cat /etc/os-release
|
||||||
|
changed_when: false
|
||||||
|
register: _os_release
|
||||||
|
|
||||||
|
- name: Parse os release content
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
_os_release_id: >-
|
||||||
|
{{ (_os_release.stdout_lines
|
||||||
|
| select('search', '^ID='))[0]
|
||||||
|
| regex_replace('^ID=', '') }}
|
||||||
|
_os_release_variant_id: >-
|
||||||
|
{{ (_os_release.stdout_lines
|
||||||
|
| select('search', '^VARIANT_ID='))[0]
|
||||||
|
| default('none')
|
||||||
|
| regex_replace('^VARIANT_ID=', '') }}
|
||||||
|
|
||||||
|
- name: Install ansible dependencies (Fedora CoreOS)
|
||||||
|
ansible.builtin.raw: rpm-ostree install -y -A python3 python3-libselinux
|
||||||
|
changed_when: true
|
||||||
|
when: _os_release_id == 'fedora' and _os_release_variant_id == 'coreos'
|
||||||
3
roles/vhost/README.md
Normal file
3
roles/vhost/README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Sets up a vhost on a web server.
|
||||||
|
Supports reverse proxies, redirects and simple resonses.
|
||||||
|
Currently only supports caddy.
|
||||||
@@ -19,5 +19,6 @@ vhost_proxy_delete_headers: []
|
|||||||
|
|
||||||
vhost_redirect_type: temporary
|
vhost_redirect_type: temporary
|
||||||
vhost_redirect_preserve_path: false
|
vhost_redirect_preserve_path: false
|
||||||
|
vhost_redirect_preserve_query: "{{ vhost_redirect_preserve_path }}"
|
||||||
|
|
||||||
vhost_respond_content_type: plain
|
vhost_respond_content_type: plain
|
||||||
|
|||||||
@@ -20,16 +20,18 @@ argument_specs:
|
|||||||
- present
|
- present
|
||||||
- absent
|
- absent
|
||||||
vhost_type:
|
vhost_type:
|
||||||
|
description: Required if vhost_state is present
|
||||||
type: str
|
type: str
|
||||||
required: "{{ vhost_state == 'present' }}"
|
required: false
|
||||||
choices:
|
choices:
|
||||||
- reverse_proxy
|
- reverse_proxy
|
||||||
- redirect
|
- redirect
|
||||||
- respond
|
- respond
|
||||||
- absent
|
- absent
|
||||||
vhost_domains:
|
vhost_domains:
|
||||||
|
description: Required if vhost_state is present
|
||||||
type: list
|
type: list
|
||||||
required: "{{ vhost_state == 'present' }}"
|
required: false
|
||||||
elements: str
|
elements: str
|
||||||
vhost_web_server:
|
vhost_web_server:
|
||||||
description: Defines which server software to use for vhost. This role does nothing if set to none.
|
description: Defines which server software to use for vhost. This role does nothing if set to none.
|
||||||
@@ -94,13 +96,13 @@ argument_specs:
|
|||||||
- Port where to proxy requests to.
|
- Port where to proxy requests to.
|
||||||
- Only applicable if vhost_type is reverse_proxy and vhost_proxy_target_netproto is tcp.
|
- Only applicable if vhost_type is reverse_proxy and vhost_proxy_target_netproto is tcp.
|
||||||
type: int
|
type: int
|
||||||
required: "{{ vhost_state == 'present' and vhost_type == 'reverse_proxy' and vhost_proxy_target_netproto == 'tcp' }}"
|
required: false
|
||||||
vhost_proxy_target_socket:
|
vhost_proxy_target_socket:
|
||||||
description:
|
description:
|
||||||
- Unix socket path to proxy requests to.
|
- Unix socket path to proxy requests to.
|
||||||
- Only applicable if vhost_type is reverse_proxy and vhost_proxy_target_netproto is unix.
|
- Only applicable if vhost_type is reverse_proxy and vhost_proxy_target_netproto is unix.
|
||||||
type: str
|
type: str
|
||||||
required: "{{ vhost_state == 'present' and vhost_type == 'reverse_proxy' and vhost_proxy_target_netproto == 'unix' }}"
|
required: false
|
||||||
vhost_proxy_delete_headers:
|
vhost_proxy_delete_headers:
|
||||||
description: List of headers to delete from proxied requests
|
description: List of headers to delete from proxied requests
|
||||||
type: list
|
type: list
|
||||||
@@ -111,14 +113,19 @@ argument_specs:
|
|||||||
vhost_redirect_target:
|
vhost_redirect_target:
|
||||||
description: "Only applicable if vhost_type is redirect. Example: https://www.domain.tld/location"
|
description: "Only applicable if vhost_type is redirect. Example: https://www.domain.tld/location"
|
||||||
type: str
|
type: str
|
||||||
required: "{{ vhost_state == 'present' and vhost_type == 'redirect' }}"
|
required: false
|
||||||
vhost_redirect_preserve_path:
|
vhost_redirect_preserve_path:
|
||||||
description: Whether to keep the original request path
|
description: Whether to keep the original request path
|
||||||
type: bool
|
type: bool
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
redirect type:
|
vhost_redirect_preserve_query:
|
||||||
description: Only applicable if vhost_type is reverse_proxy
|
description: Whether to keep the original request query string
|
||||||
|
type: bool
|
||||||
|
required: false
|
||||||
|
default: "{{ vhost_redirect_preserve_path }}"
|
||||||
|
redirect_type:
|
||||||
|
description: Only applicable if vhost_type is redirect
|
||||||
type: str
|
type: str
|
||||||
required: false
|
required: false
|
||||||
default: temporary
|
default: temporary
|
||||||
@@ -129,7 +136,7 @@ argument_specs:
|
|||||||
vhost_respond_content:
|
vhost_respond_content:
|
||||||
description: Content to respond with. Json content can be set as yaml as long as vhost_respond_content_type is set to json
|
description: Content to respond with. Json content can be set as yaml as long as vhost_respond_content_type is set to json
|
||||||
type: str
|
type: str
|
||||||
required: "{{ vhost_state == 'present' and vhost_type == 'respond' }}"
|
required: false
|
||||||
vhost_respond_content_type:
|
vhost_respond_content_type:
|
||||||
description: Type of the respond content
|
description: Type of the respond content
|
||||||
type: str
|
type: str
|
||||||
@@ -234,8 +241,13 @@ argument_specs:
|
|||||||
type: bool
|
type: bool
|
||||||
required: false
|
required: false
|
||||||
default: "{{ vhost_redirect_preserve_path }}"
|
default: "{{ vhost_redirect_preserve_path }}"
|
||||||
|
redirect_preserve_query:
|
||||||
|
description: Whether to keep the original request query string
|
||||||
|
type: bool
|
||||||
|
required: false
|
||||||
|
default: "{{ vhost_redirect_preserve_query }}"
|
||||||
redirect_type:
|
redirect_type:
|
||||||
description: Only applicable if vhost_type is reverse_proxy
|
description: Only applicable if vhost_type is redirect
|
||||||
type: str
|
type: str
|
||||||
required: false
|
required: false
|
||||||
default: "{{ vhost_redirect_type }}"
|
default: "{{ vhost_redirect_type }}"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
ansible.builtin.blockinfile:
|
ansible.builtin.blockinfile:
|
||||||
path: /etc/caddy/Caddyfile
|
path: /etc/caddy/Caddyfile
|
||||||
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ vhost_id }}"
|
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ vhost_id }}"
|
||||||
|
# yamllint disable rule:line-length
|
||||||
block: |
|
block: |
|
||||||
{{ vhost_domains | join(' ') }} {
|
{{ vhost_domains | join(' ') }} {
|
||||||
{% for location in vhost_locations_all %}
|
{% for location in vhost_locations_all %}
|
||||||
@@ -41,7 +42,7 @@
|
|||||||
request_header -{{ header }}
|
request_header -{{ header }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% elif location.type == 'redirect' %}
|
{% elif location.type == 'redirect' %}
|
||||||
redir {{ location.redirect_target }}{{ '{uri}' if location.redirect_preserve_path }} {{ location.redirect_type }}
|
redir * {{ location.redirect_target }}{{ '{path}' if location.redirect_preserve_path }}{{ '?{query}' if location.redirect_preserve_query }} {{ location.redirect_type }}
|
||||||
{% elif location.type == 'respond' %}
|
{% elif location.type == 'respond' %}
|
||||||
{% if location.respond_content_type == 'json' %}
|
{% if location.respond_content_type == 'json' %}
|
||||||
respond `{{ location.respond_content | to_json }}`
|
respond `{{ location.respond_content | to_json }}`
|
||||||
@@ -52,6 +53,7 @@
|
|||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
}
|
}
|
||||||
|
# yamllint enable rule:line-length
|
||||||
validate: 'caddy validate --config %s --adapter caddyfile'
|
validate: 'caddy validate --config %s --adapter caddyfile'
|
||||||
backup: true
|
backup: true
|
||||||
state: "{{ vhost_state }}"
|
state: "{{ vhost_state }}"
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
'redirect_target': item.redirect_target | default(vhost_redirect_target if vhost_type == 'redirect' else ''),
|
'redirect_target': item.redirect_target | default(vhost_redirect_target if vhost_type == 'redirect' else ''),
|
||||||
'redirect_preserve_path': item.redirect_preserve_path | default(vhost_redirect_preserve_path),
|
'redirect_preserve_path': item.redirect_preserve_path | default(vhost_redirect_preserve_path),
|
||||||
|
'redirect_preserve_query': item.redirect_preserve_query | default(vhost_redirect_preserve_query),
|
||||||
'redirect_type': item.redirect_type | default(vhost_redirect_type),
|
'redirect_type': item.redirect_type | default(vhost_redirect_type),
|
||||||
|
|
||||||
'respond_content': item.respond_content | default(vhost_respond_content if vhost_type == 'respond' else ''),
|
'respond_content': item.respond_content | default(vhost_respond_content if vhost_type == 'respond' else ''),
|
||||||
|
|||||||
Reference in New Issue
Block a user