Skip to content
Snippets Groups Projects
Commit 2f0f1796 authored by Adrian K.'s avatar Adrian K.
Browse files

Fix ansible-lint

parent 3a35f79b
No related branches found
No related tags found
1 merge request!19Add ansible-lint and fix all warnings and errors
Pipeline #89585 failed
...@@ -11,7 +11,7 @@ haproxy_wanted_acme_domains: [] ...@@ -11,7 +11,7 @@ haproxy_wanted_acme_domains: []
haproxy_acme_backend_name: "acmetool" haproxy_acme_backend_name: "acmetool"
_haproxy_ssl_options: 'no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets' _haproxy_ssl_options: 'no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets'
_haproxy_ssl_ciphers: 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384' # noqa line-length _haproxy_ssl_ciphers: 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384' # noqa yaml[line-length]
_haproxy_ssl_ciphersuites: 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256' _haproxy_ssl_ciphersuites: 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256'
haproxy_default_compression_algo: gzip haproxy_default_compression_algo: gzip
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
# handlers file for haproxy # handlers file for haproxy
- name: restart haproxy - name: restart haproxy
service: ansible.builtin.service:
name: haproxy name: haproxy
state: restarted state: restarted
- name: reload haproxy - name: reload haproxy
service: ansible.builtin.service:
name: haproxy name: haproxy
state: reloaded state: reloaded
...@@ -3,7 +3,7 @@ galaxy_info: ...@@ -3,7 +3,7 @@ galaxy_info:
author: Fachschaft Informatik, TU Dortmund author: Fachschaft Informatik, TU Dortmund
description: Install and configure a HAProxy reverse proxy description: Install and configure a HAProxy reverse proxy
license: Apache-2.0 license: Apache-2.0
min_ansible_version: 2.9 min_ansible_version: "2.9"
platforms: platforms:
- name: Ubuntu - name: Ubuntu
versions: versions:
......
--- ---
- name: "{{ item.name }}: Generate certpaths file" - name: "{{ item.name }}: Generate certpaths file"
notify: reload haproxy notify: reload haproxy
template: ansible.builtin.template:
src: certpaths.j2 src: certpaths.j2
dest: "/etc/haproxy/{{ item.name }}.certpaths" dest: "/etc/haproxy/{{ item.name }}.certpaths"
owner: root owner: root
......
--- ---
- name: Collect all extern certpaths - name: Collect all extern certpaths
set_fact: ansible.builtin.set_fact:
haproxy_wanted_certpaths: "{{ haproxy_wanted_certs }} + {{ (item.ssl | default([])).cert | default([]) }}" haproxy_wanted_certpaths: "{{ haproxy_wanted_certs }} + {{ (item.ssl | default([])).cert | default([]) }}"
loop: "{{ haproxy_frontends }}" loop: "{{ haproxy_frontends }}"
when: haproxy_frontends is defined when: haproxy_frontends is defined
- name: Collect all LE certs - name: Collect all LE certs
set_fact: ansible.builtin.set_fact:
haproxy_wanted_acme_domains: "{{ haproxy_wanted_acme_domains }} + {{ (item.ssl | default([])).acme_domains | default([]) }}" haproxy_wanted_acme_domains: "{{ haproxy_wanted_acme_domains }} + {{ (item.ssl | default([])).acme_domains | default([]) }}"
loop: "{{ haproxy_frontends }}" loop: "{{ haproxy_frontends }}"
when: haproxy_frontends is defined when: haproxy_frontends is defined
- name: Check if haproxy backend is already configured - name: Check if haproxy backend is already configured
lineinfile: ansible.builtin.lineinfile:
path: /etc/haproxy/haproxy.cfg path: /etc/haproxy/haproxy.cfg
line: "backend {{ haproxy_acme_backend_name }}" line: "backend {{ haproxy_acme_backend_name }}"
state: present state: present
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
## ASSEMBLE CONFIG - FRONTEND ## ASSEMBLE CONFIG - FRONTEND
- name: 'Create directory for the frontend' - name: 'Create directory for the frontend'
file: ansible.builtin.file:
path: "{{ haproxy_config_dir }}/frontends.d" path: "{{ haproxy_config_dir }}/frontends.d"
state: directory state: directory
owner: root owner: root
...@@ -42,21 +42,21 @@ ...@@ -42,21 +42,21 @@
mode: 0755 mode: 0755
- name: "List files for the frontends" - name: "List files for the frontends"
find: ansible.builtin.find:
paths: "{{ haproxy_config_dir }}/frontends.d" paths: "{{ haproxy_config_dir }}/frontends.d"
patterns: "*.cfg" patterns: "*.cfg"
register: directory_contents register: directory_contents
changed_when: false changed_when: false
- name: "Remove unmanaged files for the frontends" - name: "Remove unmanaged files for the frontends"
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: absent state: absent
when: (item.path | basename) not in (haproxy_frontends | json_query('[*].name') | map('regex_replace', '(^.*$)', '\\1.cfg') | list) when: (item.path | basename) not in (haproxy_frontends | json_query('[*].name') | map('regex_replace', '(^.*$)', '\\1.cfg') | list)
loop: "{{ directory_contents.files }}" loop: "{{ directory_contents.files }}"
- name: 'Build up the frontends' - name: 'Build up the frontends'
template: ansible.builtin.template:
src: "frontend.cfg" src: "frontend.cfg"
dest: "{{ haproxy_config_dir }}/frontends.d/{{ item.name }}.cfg" dest: "{{ haproxy_config_dir }}/frontends.d/{{ item.name }}.cfg"
owner: root owner: root
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
## ASSEMBLE CONFIG - BACKEND ## ASSEMBLE CONFIG - BACKEND
- name: 'Create directory for the backends' - name: 'Create directory for the backends'
file: ansible.builtin.file:
path: "{{ haproxy_config_dir }}/backends.d" path: "{{ haproxy_config_dir }}/backends.d"
state: directory state: directory
owner: root owner: root
...@@ -76,21 +76,21 @@ ...@@ -76,21 +76,21 @@
mode: 0755 mode: 0755
- name: "List files for the backends" - name: "List files for the backends"
find: ansible.builtin.find:
paths: "{{ haproxy_config_dir }}/backends.d" paths: "{{ haproxy_config_dir }}/backends.d"
patterns: "*.cfg" patterns: "*.cfg"
register: directory_contents register: directory_contents
changed_when: false changed_when: false
- name: "Remove unmanaged files for the backends" - name: "Remove unmanaged files for the backends"
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: absent state: absent
when: (item.path | basename) not in (haproxy_backends | json_query('[*].name') | map('regex_replace', '(^.*$)', '\\1.cfg') | list) when: (item.path | basename) not in (haproxy_backends | json_query('[*].name') | map('regex_replace', '(^.*$)', '\\1.cfg') | list)
loop: "{{ directory_contents.files }}" loop: "{{ directory_contents.files }}"
- name: 'Build up the backends' - name: 'Build up the backends'
template: ansible.builtin.template:
src: "backend.cfg" src: "backend.cfg"
dest: "{{ haproxy_config_dir }}/backends.d/{{ item.name }}.cfg" dest: "{{ haproxy_config_dir }}/backends.d/{{ item.name }}.cfg"
owner: root owner: root
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
## ASSEMBLE CONFIG - LISTEN ## ASSEMBLE CONFIG - LISTEN
- name: 'Create directory for the listen sections' - name: 'Create directory for the listen sections'
file: ansible.builtin.file:
path: "{{ haproxy_config_dir }}/listen.d" path: "{{ haproxy_config_dir }}/listen.d"
state: directory state: directory
owner: root owner: root
...@@ -110,21 +110,21 @@ ...@@ -110,21 +110,21 @@
mode: 0755 mode: 0755
- name: "List files the listen sections" - name: "List files the listen sections"
find: ansible.builtin.find:
paths: "{{ haproxy_config_dir }}/listen.d" paths: "{{ haproxy_config_dir }}/listen.d"
patterns: "*.cfg" patterns: "*.cfg"
register: directory_contents register: directory_contents
changed_when: false changed_when: false
- name: "Remove unmanaged files the listen sections" - name: "Remove unmanaged files the listen sections"
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: absent state: absent
when: (item.path | basename) not in (haproxy_listen | json_query('[*].name') | map('regex_replace', '(^.*$)', '\\1.cfg') | list) when: (item.path | basename) not in (haproxy_listen | json_query('[*].name') | map('regex_replace', '(^.*$)', '\\1.cfg') | list)
loop: "{{ directory_contents.files }}" loop: "{{ directory_contents.files }}"
- name: 'Build up the listen sections' - name: 'Build up the listen sections'
template: ansible.builtin.template:
src: "listen.cfg" src: "listen.cfg"
dest: "{{ haproxy_config_dir }}/listen.d/{{ item.name }}.cfg" dest: "{{ haproxy_config_dir }}/listen.d/{{ item.name }}.cfg"
owner: root owner: root
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
## ASSEMBLE CONFIG - USERLIST ## ASSEMBLE CONFIG - USERLIST
- name: 'Create directory for the userlists' - name: 'Create directory for the userlists'
file: ansible.builtin.file:
path: "{{ haproxy_config_dir }}/userlists.d" path: "{{ haproxy_config_dir }}/userlists.d"
state: directory state: directory
owner: root owner: root
...@@ -144,21 +144,21 @@ ...@@ -144,21 +144,21 @@
mode: 0755 mode: 0755
- name: "List files for the userlists" - name: "List files for the userlists"
find: ansible.builtin.find:
paths: "{{ haproxy_config_dir }}/userlists.d" paths: "{{ haproxy_config_dir }}/userlists.d"
patterns: "*.cfg" patterns: "*.cfg"
register: directory_contents register: directory_contents
changed_when: false changed_when: false
- name: "Remove unmanaged files for the userlists" - name: "Remove unmanaged files for the userlists"
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: absent state: absent
when: (item.path | basename) not in (haproxy_userlists | json_query('[*].name') | map('regex_replace', '(^.*$)', '\\1.cfg') | list) when: (item.path | basename) not in (haproxy_userlists | json_query('[*].name') | map('regex_replace', '(^.*$)', '\\1.cfg') | list)
loop: "{{ directory_contents.files }}" loop: "{{ directory_contents.files }}"
- name: 'Build up the userlist sections' - name: 'Build up the userlist sections'
template: ansible.builtin.template:
src: userlist.cfg src: userlist.cfg
dest: "{{ haproxy_config_dir }}/userlists.d/{{ item.name }}.cfg" dest: "{{ haproxy_config_dir }}/userlists.d/{{ item.name }}.cfg"
owner: root owner: root
...@@ -170,7 +170,7 @@ ...@@ -170,7 +170,7 @@
## ASSEMBLE CONFIG - GLOBAL & DEFAULT ## ASSEMBLE CONFIG - GLOBAL & DEFAULT
- name: 'Create the compiled folder' - name: 'Create the compiled folder'
file: ansible.builtin.file:
path: "{{ haproxy_config_dir }}/compiled" path: "{{ haproxy_config_dir }}/compiled"
state: directory state: directory
owner: root owner: root
...@@ -178,11 +178,11 @@ ...@@ -178,11 +178,11 @@
mode: 0755 mode: 0755
- name: 'Merge global config' - name: 'Merge global config'
set_fact: ansible.builtin.set_fact:
haproxy_global_final: "{{ _haproxy_global | combine(haproxy_global, recursive=true) }}" haproxy_global_final: "{{ _haproxy_global | combine(haproxy_global, recursive=true) }}"
- name: 'Build up the global config' - name: 'Build up the global config'
template: ansible.builtin.template:
src: "global.cfg" src: "global.cfg"
dest: "{{ haproxy_config_dir }}/compiled/01-global.cfg" dest: "{{ haproxy_config_dir }}/compiled/01-global.cfg"
owner: root owner: root
...@@ -190,11 +190,11 @@ ...@@ -190,11 +190,11 @@
mode: 0644 mode: 0644
- name: 'Merge default config' - name: 'Merge default config'
set_fact: ansible.builtin.set_fact:
haproxy_defaults_final: "{{ _haproxy_defaults | combine(haproxy_defaults, recursive=true) }}" haproxy_defaults_final: "{{ _haproxy_defaults | combine(haproxy_defaults, recursive=true) }}"
- name: 'Build up the default config' - name: 'Build up the default config'
template: ansible.builtin.template:
src: "defaults.cfg" src: "defaults.cfg"
dest: "{{ haproxy_config_dir }}/compiled/02-defaults.cfg" dest: "{{ haproxy_config_dir }}/compiled/02-defaults.cfg"
owner: root owner: root
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
## ASSEMBLE FINAL CONFIG ## ASSEMBLE FINAL CONFIG
- name: 'Assemble the backends configuration file' - name: 'Assemble the backends configuration file'
assemble: ansible.builtin.assemble:
src: "{{ haproxy_config_dir }}/backends.d" src: "{{ haproxy_config_dir }}/backends.d"
dest: "{{ haproxy_config_dir }}/compiled/03-backends.cfg" dest: "{{ haproxy_config_dir }}/compiled/03-backends.cfg"
owner: root owner: root
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,7 @@
mode: 0644 mode: 0644
- name: 'Assemble the frontends configuration file' - name: 'Assemble the frontends configuration file'
assemble: ansible.builtin.assemble:
src: "{{ haproxy_config_dir }}/frontends.d" src: "{{ haproxy_config_dir }}/frontends.d"
dest: "{{ haproxy_config_dir }}/compiled/04-frontends.cfg" dest: "{{ haproxy_config_dir }}/compiled/04-frontends.cfg"
owner: root owner: root
...@@ -221,7 +221,7 @@ ...@@ -221,7 +221,7 @@
mode: 0644 mode: 0644
- name: 'Assemble the listen sections configuration file' - name: 'Assemble the listen sections configuration file'
assemble: ansible.builtin.assemble:
src: "{{ haproxy_config_dir }}/listen.d" src: "{{ haproxy_config_dir }}/listen.d"
dest: "{{ haproxy_config_dir }}/compiled/05-listen.cfg" dest: "{{ haproxy_config_dir }}/compiled/05-listen.cfg"
owner: root owner: root
...@@ -229,7 +229,7 @@ ...@@ -229,7 +229,7 @@
mode: 0644 mode: 0644
- name: 'Assemble the userlists sections configuration file' - name: 'Assemble the userlists sections configuration file'
assemble: ansible.builtin.assemble:
src: "{{ haproxy_config_dir }}/userlists.d" src: "{{ haproxy_config_dir }}/userlists.d"
dest: "{{ haproxy_config_dir }}/compiled/06-userlists.cfg" dest: "{{ haproxy_config_dir }}/compiled/06-userlists.cfg"
owner: root owner: root
...@@ -237,7 +237,7 @@ ...@@ -237,7 +237,7 @@
mode: 0644 mode: 0644
- name: 'Assemble the final configuration file' - name: 'Assemble the final configuration file'
assemble: ansible.builtin.assemble:
src: "{{ haproxy_config_dir }}/compiled" src: "{{ haproxy_config_dir }}/compiled"
dest: "{{ haproxy_config_file }}" dest: "{{ haproxy_config_file }}"
owner: root owner: root
......
--- ---
- name: Add HAProxy 2.6 PPA - name: Add HAProxy 2.6 PPA
apt_repository: ansible.builtin.apt_repository:
repo: 'ppa:vbernat/haproxy-2.6' repo: 'ppa:vbernat/haproxy-2.6'
state: present state: present
- name: Remove HAProxy 2.5 PPA - name: Remove HAProxy 2.5 PPA
apt_repository: ansible.builtin.apt_repository:
repo: 'ppa:vbernat/haproxy-2.5' repo: 'ppa:vbernat/haproxy-2.5'
state: absent state: absent
- name: Remove HAProxy 2.4 PPA - name: Remove HAProxy 2.4 PPA
apt_repository: ansible.builtin.apt_repository:
repo: 'ppa:vbernat/haproxy-2.4' repo: 'ppa:vbernat/haproxy-2.4'
state: absent state: absent
- name: Remove HAProxy 2.3 PPA - name: Remove HAProxy 2.3 PPA
apt_repository: ansible.builtin.apt_repository:
repo: 'ppa:vbernat/haproxy-2.3' repo: 'ppa:vbernat/haproxy-2.3'
state: absent state: absent
- name: Remove HAProxy 2.2 PPA - name: Remove HAProxy 2.2 PPA
apt_repository: ansible.builtin.apt_repository:
repo: 'ppa:vbernat/haproxy-2.2' repo: 'ppa:vbernat/haproxy-2.2'
state: absent state: absent
- name: Remove HAProxy 2.1 PPA - name: Remove HAProxy 2.1 PPA
apt_repository: ansible.builtin.apt_repository:
repo: 'ppa:vbernat/haproxy-2.1' repo: 'ppa:vbernat/haproxy-2.1'
state: absent state: absent
- name: Remove HAProxy 2.0 PPA - name: Remove HAProxy 2.0 PPA
apt_repository: ansible.builtin.apt_repository:
repo: 'ppa:vbernat/haproxy-2.0' repo: 'ppa:vbernat/haproxy-2.0'
state: absent state: absent
- name: Remove HAProxy 1.8 PPA - name: Remove HAProxy 1.8 PPA
apt_repository: ansible.builtin.apt_repository:
repo: 'ppa:vbernat/haproxy-1.8' repo: 'ppa:vbernat/haproxy-1.8'
state: absent state: absent
- name: Install HAProxy - name: Install HAProxy
apt: ansible.builtin.apt:
name: "haproxy=2.6.*" name: "haproxy=2.6.*"
state: present state: present
update_cache: true update_cache: true
- name: 'Enable haproxy unit' - name: 'Enable haproxy unit'
systemd: ansible.builtin.systemd:
name: haproxy name: haproxy
enabled: true enabled: true
- name: 'Ensure chroot directory exists' - name: 'Ensure chroot directory exists'
file: ansible.builtin.file:
name: "{{ haproxy_global.chroot }}" name: "{{ haproxy_global.chroot }}"
state: directory state: directory
owner: root owner: root
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
when: haproxy_global.chroot is defined and haproxy_global.chroot when: haproxy_global.chroot is defined and haproxy_global.chroot
- name: Create service override directory - name: Create service override directory
file: ansible.builtin.file:
path: /etc/systemd/system/haproxy.service.d path: /etc/systemd/system/haproxy.service.d
state: directory state: directory
owner: root owner: root
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
mode: 0755 mode: 0755
- name: Copy service override - name: Copy service override
copy: ansible.builtin.copy:
dest: /etc/systemd/system/haproxy.service.d/override.conf dest: /etc/systemd/system/haproxy.service.d/override.conf
content: | content: |
[Unit] [Unit]
......
--- ---
- name: Copy temporary haproxy.cfg - name: Copy temporary haproxy.cfg
template: ansible.builtin.template:
src: tls_temp.cfg src: tls_temp.cfg
dest: /etc/haproxy/haproxy.cfg dest: /etc/haproxy/haproxy.cfg
owner: root owner: root
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
mode: 0644 mode: 0644
- name: Restart haproxy - name: Restart haproxy
systemd: ansible.builtin.systemd:
name: haproxy name: haproxy
state: restarted state: restarted
--- ---
- name: "<{{ item }}> Gather Cert stats" - name: "<{{ item }}> Gather Cert stats"
stat: ansible.builtin.stat:
path: "/var/lib/acme/live/{{ item }}/haproxy" path: "/var/lib/acme/live/{{ item }}/haproxy"
register: cert register: cert
- name: "<{{ item }}> Run acmetool (Make sure your system is accessible from the internet!)" - name: "<{{ item }}> Run acmetool (Make sure your system is accessible from the internet!)"
shell: "acmetool want --batch {{ item }}" ansible.builtin.command: "acmetool want --batch {{ item }}"
register: result register: result
changed_when: "result.stdout" changed_when: "result.stdout"
when: not cert.stat.exists when: not cert.stat.exists
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment