mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-04-23 21:53:21 +02:00
Update to 2022-02-09 17:00
This commit is contained in:
parent
00b3d728c8
commit
6f6d3b7382
@ -20,7 +20,7 @@
|
|||||||
- ansible_conf.d/10-ssl.conf
|
- ansible_conf.d/10-ssl.conf
|
||||||
- ansible_conf.d/30-vhosts.conf
|
- ansible_conf.d/30-vhosts.conf
|
||||||
notify: reload nginx
|
notify: reload nginx
|
||||||
tags: [web,conf]
|
tags: web,conf,quickweb
|
||||||
|
|
||||||
- name: Remove naxsi configuration
|
- name: Remove naxsi configuration
|
||||||
file: path=/etc/nginx/{{ item }} state=absent
|
file: path=/etc/nginx/{{ item }} state=absent
|
||||||
@ -37,7 +37,7 @@
|
|||||||
- ansible_conf.d/10-filter.conf
|
- ansible_conf.d/10-filter.conf
|
||||||
- ansible_conf.d/headers.inc
|
- ansible_conf.d/headers.inc
|
||||||
notify: reload nginx
|
notify: reload nginx
|
||||||
tags: [web,conf]
|
tags: web,conf
|
||||||
|
|
||||||
# TODO make it configurable
|
# TODO make it configurable
|
||||||
- name: Create dummy white and blacklist files for nginx
|
- name: Create dummy white and blacklist files for nginx
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
---
|
---
|
||||||
- name: List http ports
|
- name: List http ports
|
||||||
set_fact: nginx_ports={{ nginx_ports + (nginx_vhosts | selectattr('port','defined') | map(attribute='port') | list) | flatten | unique }}
|
set_fact: nginx_ports={{ nginx_ports + (nginx_vhosts | selectattr('port','defined') | map(attribute='port') | list) | flatten | unique }}
|
||||||
tags: [firewall,web]
|
tags: firewall,web,quickweb
|
||||||
|
|
||||||
- name: List https ports
|
- name: List https ports
|
||||||
set_fact: nginx_ssl_ports={{ nginx_ssl_ports + (nginx_vhosts | selectattr('ssl','defined') | selectattr('ssl.port','defined') | map(attribute='ssl.port') | list) | flatten | unique }}
|
set_fact: nginx_ssl_ports={{ nginx_ssl_ports + (nginx_vhosts | selectattr('ssl','defined') | selectattr('ssl.port','defined') | map(attribute='ssl.port') | list) | flatten | unique }}
|
||||||
tags: [firewall,web]
|
tags: firewall,web,quickweb
|
||||||
|
|
||||||
- set_fact: nginx_cert_path={{ '/var/lib/dehydrated/certificates/certs/' + nginx_letsencrypt_cert + '/fullchain.pem' }}
|
- set_fact: nginx_cert_path={{ '/var/lib/dehydrated/certificates/certs/' + nginx_letsencrypt_cert + '/fullchain.pem' }}
|
||||||
when: nginx_letsencrypt_cert is defined
|
when: nginx_letsencrypt_cert is defined
|
||||||
tags: [web,conf]
|
tags: web,conf,quickweb
|
||||||
- set_fact: nginx_key_path={{ '/var/lib/dehydrated/certificates/certs/' + nginx_letsencrypt_cert + '/privkey.pem' }}
|
- set_fact: nginx_key_path={{ '/var/lib/dehydrated/certificates/certs/' + nginx_letsencrypt_cert + '/privkey.pem' }}
|
||||||
when: nginx_letsencrypt_cert is defined
|
when: nginx_letsencrypt_cert is defined
|
||||||
tags: [web,conf]
|
tags: web,conf,quickweb
|
||||||
|
|
||||||
- name: Merge vhosts settings with defaults
|
- name: Merge vhosts settings with defaults
|
||||||
set_fact: nginx_vhosts_conf={{ nginx_vhosts_conf | default([]) + [ nginx_default_vhost | combine(item, recursive=True) ] }}
|
set_fact: nginx_vhosts_conf={{ nginx_vhosts_conf | default([]) + [ nginx_default_vhost | combine(item, recursive=True) ] }}
|
||||||
with_items: "{{ nginx_vhosts }}"
|
with_items: "{{ nginx_vhosts }}"
|
||||||
tags: [web,conf]
|
tags: web,conf,quickweb
|
||||||
- set_fact: nginx_vhosts={{ nginx_vhosts_conf | default([]) }}
|
- set_fact: nginx_vhosts={{ nginx_vhosts_conf | default([]) }}
|
||||||
tags: [web,conf]
|
tags: web,conf,quickweb
|
||||||
|
|
||||||
- name: Check if Lemonldap::NG is installed
|
- name: Check if Lemonldap::NG is installed
|
||||||
stat: path=/etc/lemonldap-ng/lemonldap-ng.ini
|
stat: path=/etc/lemonldap-ng/lemonldap-ng.ini
|
||||||
register: nginx_llng
|
register: nginx_llng
|
||||||
tags: web
|
tags: web,quickweb
|
||||||
|
|
||||||
- name: Check if llng_header.inc conf is installed
|
- name: Check if llng_header.inc conf is installed
|
||||||
stat: path=/etc/nginx/ansible_conf.d/llng_headers.inc
|
stat: path=/etc/nginx/ansible_conf.d/llng_headers.inc
|
||||||
register: nginx_llng_headers
|
register: nginx_llng_headers
|
||||||
tags: web
|
tags: web,quickweb
|
||||||
|
@ -10,6 +10,7 @@ map $sent_http_content_type $is_client_cacheable {
|
|||||||
application/font-sfnt 1;
|
application/font-sfnt 1;
|
||||||
font/ttf 1;
|
font/ttf 1;
|
||||||
font/opentype 1;
|
font/opentype 1;
|
||||||
|
font/woff 1;
|
||||||
font/woff2 1;
|
font/woff2 1;
|
||||||
application/font-woff 1;
|
application/font-woff 1;
|
||||||
application/vnd.ms-fontobject 1;
|
application/vnd.ms-fontobject 1;
|
||||||
@ -21,6 +22,6 @@ map $request_uri $is_proxy_cacheable {
|
|||||||
~*\.(png|jpe?g|bmp|gif|webp)$ 1;
|
~*\.(png|jpe?g|bmp|gif|webp)$ 1;
|
||||||
~*\.(js|css|txt)$ 1;
|
~*\.(js|css|txt)$ 1;
|
||||||
~*\.(pdf)$ 1;
|
~*\.(pdf)$ 1;
|
||||||
~*\.(ttf|ott|woff2)$ 1;
|
~*\.(ttf|ott|woff?2)$ 1;
|
||||||
~*\.(mp3|mp4|avi|mpe?g|mov|flv)$ 1;
|
~*\.(mp3|mp4|avi|mpe?g|mov|flv)$ 1;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,21 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
# System proxy to use. If undefined or set to an empty string
|
||||||
|
# proxy will be disabled
|
||||||
# system_proxy: http://proxyout.example.org:3128
|
# system_proxy: http://proxyout.example.org:3128
|
||||||
|
|
||||||
|
# List of hosts for which no proxy should be used
|
||||||
system_proxy_base_no_proxy:
|
system_proxy_base_no_proxy:
|
||||||
- 127.0.0.1
|
- 127.0.0.1
|
||||||
- localhost
|
- localhost
|
||||||
- "{{ inventory_hostname | regex_replace('^([^.]+)\\..*','\\1') }}"
|
- "{{ inventory_hostname | regex_replace('^([^.]+)\\..*','\\1') }}"
|
||||||
- "{{ inventory_hostname }}"
|
- "{{ inventory_hostname }}"
|
||||||
|
# Can be used to add no_proxy hosts without overriding the default ones
|
||||||
system_proxy_extra_no_proxy: []
|
system_proxy_extra_no_proxy: []
|
||||||
system_proxy_no_proxy: "{{ system_proxy_base_no_proxy + system_proxy_extra_no_proxy }}"
|
system_proxy_no_proxy: "{{ system_proxy_base_no_proxy + system_proxy_extra_no_proxy }}"
|
||||||
|
|
||||||
|
# List of protocols for which env variables will be set (if a proxy is configured)
|
||||||
|
system_proxy_proto:
|
||||||
|
- http
|
||||||
|
- https
|
||||||
|
- ftp
|
||||||
|
17
roles/system_proxy/tasks/Debian.yml
Normal file
17
roles/system_proxy/tasks/Debian.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Config proxy for apt
|
||||||
|
copy:
|
||||||
|
content: |
|
||||||
|
Acquire::http::Proxy "{{ system_proxy }}";
|
||||||
|
Acquire::https::Proxy "{{ system_proxy }}";
|
||||||
|
dest: /etc/apt/apt.conf.d/10proxy
|
||||||
|
when:
|
||||||
|
- system_proxy is defined
|
||||||
|
- system_proxy != ''
|
||||||
|
tags: proxy
|
||||||
|
|
||||||
|
- name: Remove proxy from apt config
|
||||||
|
file: path=/etc/apt/apt.conf.d/10proxy state=absent
|
||||||
|
when: system_proxy is not defined or system_proxy == ''
|
||||||
|
tags: proxy
|
20
roles/system_proxy/tasks/RedHat.yml
Normal file
20
roles/system_proxy/tasks/RedHat.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Configure proxy for yum
|
||||||
|
ini_file:
|
||||||
|
path: /etc/yum.conf
|
||||||
|
section: main
|
||||||
|
option: proxy
|
||||||
|
value: "{{ (system_proxy is defined and system_proxy != '') | ternary(system_proxy,'') }}"
|
||||||
|
state: "{{ (system_proxy is defined and system_proxy != '') | ternary('present','absent') }}"
|
||||||
|
tags: proxy
|
||||||
|
|
||||||
|
- name: Configure proxy for dnf
|
||||||
|
ini_file:
|
||||||
|
path: /etc/dnf/yum.conf
|
||||||
|
section: main
|
||||||
|
option: proxy
|
||||||
|
value: "{{ (system_proxy is defined and system_proxy != '') | ternary(system_proxy,'') }}"
|
||||||
|
state: "{{ (system_proxy is defined and system_proxy != '') | ternary('present','absent') }}"
|
||||||
|
when: ansible_distribution_major_version is version('8', '>=')
|
||||||
|
tags: proxy
|
@ -10,13 +10,7 @@
|
|||||||
regexp: "^{{ item }}=.*"
|
regexp: "^{{ item }}=.*"
|
||||||
line: "{{ item }}={{ (system_proxy is defined and system_proxy != '') | ternary(system_proxy,'') }}"
|
line: "{{ item }}={{ (system_proxy is defined and system_proxy != '') | ternary(system_proxy,'') }}"
|
||||||
state: "{{ (system_proxy is defined and system_proxy != '') | ternary('present','absent') }}"
|
state: "{{ (system_proxy is defined and system_proxy != '') | ternary('present','absent') }}"
|
||||||
with_items:
|
with_items: "{{ system_proxy_proto | map('regex_replace', '^(.*)$', '\\1_proxy') | list }} + {{ system_proxy_proto | map('regex_replace', '^(.*)$', '\\1_proxy') | map('upper') | list }}"
|
||||||
- http_proxy
|
|
||||||
- HTTP_PROXY
|
|
||||||
- https_proxy
|
|
||||||
- HTTPS_PROXY
|
|
||||||
- ftp_proxy
|
|
||||||
- FTP_PROXY
|
|
||||||
tags: proxy
|
tags: proxy
|
||||||
|
|
||||||
- name: Set proxy exceptions
|
- name: Set proxy exceptions
|
||||||
@ -30,55 +24,15 @@
|
|||||||
- NO_PROXY
|
- NO_PROXY
|
||||||
tags: proxy
|
tags: proxy
|
||||||
|
|
||||||
|
- when: ansible_service_mgr == 'systemd'
|
||||||
|
block:
|
||||||
- name: Creates systemd.conf.d dir
|
- name: Creates systemd.conf.d dir
|
||||||
file: path=/etc/systemd/system.conf.d state=directory
|
file: path=/etc/systemd/system.conf.d state=directory
|
||||||
when: ansible_service_mgr == 'systemd'
|
|
||||||
tags: proxy
|
|
||||||
|
|
||||||
- name: Deploy a systemd snippet for default proxy
|
- name: Deploy a systemd snippet for default proxy
|
||||||
template: src=systemd.conf.j2 dest=/etc/systemd/system.conf.d/proxy.conf
|
template: src=systemd.conf.j2 dest=/etc/systemd/system.conf.d/proxy.conf
|
||||||
notify: reload systemd
|
notify: reload systemd
|
||||||
when: ansible_service_mgr == 'systemd'
|
|
||||||
tags: proxy
|
tags: proxy
|
||||||
|
|
||||||
- name: Configure proxy for yum
|
- include: "{{ ansible_os_family }}.yml"
|
||||||
ini_file:
|
|
||||||
path: /etc/yum.conf
|
|
||||||
section: main
|
|
||||||
option: proxy
|
|
||||||
value: "{{ (system_proxy is defined and system_proxy != '') | ternary(system_proxy,'') }}"
|
|
||||||
state: "{{ (system_proxy is defined and system_proxy != '') | ternary('present','absent') }}"
|
|
||||||
when: ansible_os_family == 'RedHat'
|
|
||||||
tags: proxy
|
|
||||||
|
|
||||||
- name: Configure proxy for dnf
|
|
||||||
ini_file:
|
|
||||||
path: /etc/dnf/yum.conf
|
|
||||||
section: main
|
|
||||||
option: proxy
|
|
||||||
value: "{{ (system_proxy is defined and system_proxy != '') | ternary(system_proxy,'') }}"
|
|
||||||
state: "{{ (system_proxy is defined and system_proxy != '') | ternary('present','absent') }}"
|
|
||||||
when:
|
|
||||||
- ansible_os_family == 'RedHat'
|
|
||||||
- ansible_distribution_major_version is version('8', '>=')
|
|
||||||
tags: proxy
|
|
||||||
|
|
||||||
- name: Config proxy for apt
|
|
||||||
copy:
|
|
||||||
content: |
|
|
||||||
Acquire::http::Proxy "{{ system_proxy }}";
|
|
||||||
Acquire::https::Proxy "{{ system_proxy }}";
|
|
||||||
dest: /etc/apt/apt.conf.d/10proxy
|
|
||||||
when:
|
|
||||||
- ansible_os_family == 'Debian'
|
|
||||||
- system_proxy is defined
|
|
||||||
- system_proxy != ''
|
|
||||||
tags: proxy
|
|
||||||
|
|
||||||
- name: Remove proxy from apt config
|
|
||||||
file: path=/etc/apt/apt.conf.d/10proxy state=absent
|
|
||||||
when:
|
|
||||||
- ansible_os_family == 'Debian'
|
|
||||||
- system_proxy is not defined or system_proxy == ''
|
|
||||||
tags: proxy
|
|
||||||
|
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
{% if system_proxy is defined and system_proxy != '' %}
|
{% if system_proxy is defined and system_proxy != '' %}
|
||||||
export http_proxy={{ system_proxy }}
|
{% for proto in system_proxy_proto %}
|
||||||
export https_proxy={{ system_proxy }}
|
export {{ proto }}_proxy={{ system_proxy }}
|
||||||
export ftp_proxy={{ system_proxy }}
|
export {{ proto | upper }}_PROXY={{ system_proxy }}
|
||||||
export HTTP_PROXY={{ system_proxy }}
|
{% endfor %}
|
||||||
export HTTPS_PROXY={{ system_proxy }}
|
|
||||||
export FTP_PROXY={{ system_proxy }}
|
|
||||||
export no_proxy='{{ system_proxy_no_proxy | join(',') }}'
|
export no_proxy='{{ system_proxy_no_proxy | join(',') }}'
|
||||||
export NO_PROXY='{{ system_proxy_no_proxy | join(',') }}'
|
export NO_PROXY='{{ system_proxy_no_proxy | join(',') }}'
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[Manager]
|
[Manager]
|
||||||
{% if system_proxy is defined and system_proxy != '' %}
|
{% if system_proxy is defined and system_proxy != '' %}
|
||||||
DefaultEnvironment=http_proxy={{ system_proxy }} https_proxy={{ system_proxy }} ftp_proxy={{ system_proxy }} HTTP_PROXY={{ system_proxy }} HTTPS_PROXY={{ system_proxy }} FTP_PROXY={{ system_proxy }} no_proxy={{ system_proxy_no_proxy | join(',') }} NO_PROXY={{ system_proxy_no_proxy | join(',') }}
|
DefaultEnvironment={% for proto in system_proxy_proto %}{{ proto }}_proxy={{ system_proxy }} {{ proto | upper }}_PROXY={{ system_proxy }} {% endfor %}no_proxy={{ system_proxy_no_proxy | join(',') }} NO_PROXY={{ system_proxy_no_proxy | join(',') }}
|
||||||
{% else %}
|
{% else %}
|
||||||
# No proxy configured
|
# No proxy configured
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user