-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from sitewards/ad-hoc-harden-tls
AD-HOC refactor (*): Add support for apache
- Loading branch information
Showing
10 changed files
with
122 additions
and
35 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"linters": { | ||
"yamllint": { | ||
"type": "script-and-regex", | ||
"include": "(\\.(yaml|yml)$)", | ||
"script-and-regex.script": "sh -c '/usr/bin/yamllint -f parsable \"$0\" || true'", | ||
"script-and-regex.regex": "/^(?P<file>[A-z0-9-_\\.\\/]+):(?P<line>[0-9]+):(?P<char>[0-9]+):\\s\\[(?P<severity>[a-z]+)\\]\\s(?P<message>.*)$/m" | ||
} | ||
} | ||
} |
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,12 @@ | ||
--- | ||
|
||
extends: default | ||
|
||
rules: | ||
line-length: | ||
max: 120 | ||
comments-indentation: disable | ||
braces: | ||
max-spaces-inside: 1 | ||
|
||
|
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
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,24 +1,34 @@ | ||
--- | ||
## The webserver that will expose the metrics. Currently supported: | ||
## - NGINX | ||
## - Apache | ||
## (Required) | ||
# prometheus_proxy_webserver: | ||
|
||
## The addresses of the exporters, such that they can be reversed proxied by the webserver | ||
nginx_prometheus_proxy_exporters: [] | ||
prometheus_proxy_exporters: [] | ||
## The name of the exporter. | ||
# - name: "node-exporter" | ||
## The port the exporter operators on | ||
# port: 9100 | ||
|
||
## A series of usernames and passwords that will be used by the webserver as basic auth | ||
nginx_prometheus_proxy_users: [] | ||
prometheus_proxy_users: [] | ||
# - user: "monitoring" | ||
# password: "testpassword" | ||
|
||
nginx_prometheus_proxy_htaccess_path: "/etc/nginx/nginx_prometheus_proxy.htaccess" | ||
## The path to the password file for the proxy | ||
prometheus_proxy_htaccess_path: "/etc/prometheus_proxy/prometheus-proxy.htaccess" | ||
|
||
## A server name which will be used in the nginx configuration, | ||
## please be advised that by default we use "_" and that is a dirty trick to achieve catch-all behavior, | ||
## see http://nginx.org/en/docs/http/server_names.html | ||
nginx_prometheus_proxy_server_name: "_" | ||
## The user/group that should own the file | ||
prometheus_proxy_htaccess_owner: "www-data" | ||
prometheus_proxy_htaccess_group: "www-data" | ||
|
||
## If TLS should be enabled for the connection, enable it by supplying an appropriate TLS certificate and key | ||
## (Optional) | ||
# nginx_prometheus_tls_certificate_path: "" | ||
# nginx_prometheus_tls_certificate_key_path: "" | ||
|
||
## The prompt that basic authentication will supply | ||
## (Required) | ||
prometheus_proxy_authentication_prompt: "Please supply a valid username / password" |
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
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,21 +1,20 @@ | ||
--- | ||
## Debguging | ||
- name: "Show me teh ip addresses" | ||
debug: | ||
var: ansible_all_ipv4_addresses | ||
- name: "Create the dir for htaccess" | ||
file: | ||
path: "{{ prometheus_proxy_htaccess_path | dirname }}" | ||
state: "directory" | ||
mode: "u=rx,g=rx,o=" | ||
owner: "{{ prometheus_proxy_htaccess_owner }}" | ||
group: "{{ prometheus_proxy_htaccess_owner }}" | ||
|
||
- name: "Create the .htaccess file" | ||
htpasswd: | ||
path: "{{ nginx_prometheus_proxy_htaccess_path }}" | ||
path: "{{ prometheus_proxy_htaccess_path }}" | ||
name: "{{ item.user }}" | ||
password: "{{ item.password }}" | ||
with_items: "{{ nginx_prometheus_proxy_users }}" | ||
mode: "u=r,g=r,o=" | ||
owner: "{{ prometheus_proxy_htaccess_owner }}" | ||
group: "{{ prometheus_proxy_htaccess_owner }}" | ||
with_items: "{{ prometheus_proxy_users }}" | ||
|
||
# Exposes the exporters via the webserver, in a password protected way. | ||
- name: "Create the vhosts" | ||
template: | ||
src: "etc/nginx/sites-enabled/template.conf" | ||
dest: "/etc/nginx/sites-enabled/{{ item.name }}.conf" | ||
with_items: "{{ nginx_prometheus_proxy_exporters }}" | ||
## This comes from the upstream geerlingguy.nginx task | ||
notify: "reload nginx" | ||
- include: "proxies/{{ prometheus_proxy_webserver|lower }}.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,9 @@ | ||
--- | ||
# Exposes the exporters via the webserver, in a password protected way. | ||
- name: "Create the vhosts" | ||
template: | ||
src: "etc/apache2/sites-enabled/template.conf" | ||
dest: "/etc/apache2/sites-enabled/{{ item.name }}.conf" | ||
with_items: "{{ prometheus_proxy_exporters }}" | ||
## This comes from the upstream geerlingguy.apache task | ||
notify: "restart apache" |
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,9 @@ | ||
--- | ||
# Exposes the exporters via the webserver, in a password protected way. | ||
- name: "Create the vhosts" | ||
template: | ||
src: "etc/nginx/sites-enabled/template.conf" | ||
dest: "/etc/nginx/sites-enabled/{{ item.name }}.conf" | ||
with_items: "{{ prometheus_proxy_exporters }}" | ||
## This comes from the upstream geerlingguy.nginx task | ||
notify: "reload nginx" |
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,19 @@ | ||
{{ ansible_managed | comment }} | ||
|
||
{% for ip in ansible_all_ipv4_addresses %} | ||
Listen {{ ip }}:{{ item.port }} | ||
|
||
<VirtualHost {{ ip }}:{{ item.port }}> | ||
ProxyPreserveHost On | ||
|
||
<Location "/"> | ||
AuthType Basic | ||
AuthName "{{ prometheus_proxy_authentication_prompt }}" | ||
AuthUserFile {{ prometheus_proxy_htaccess_path }} | ||
Require valid-user | ||
|
||
ProxyPass http://localhost:{{ item.port }}/ | ||
</Location> | ||
|
||
</VirtualHost> | ||
{% endfor %} |
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