From 9b4173d1c3c0fdd1a2d59b39ee4d0c63b2c07c84 Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Mon, 10 Jun 2019 20:20:24 +0200 Subject: [PATCH] ansible-playbooks/general#85 Linting [skip-ci] --- handlers/main.yml | 7 ++- tasks/blacklists.yml | 3 +- tasks/buildcerts.yml | 8 +-- tasks/configure.yml | 139 +++++++++++++++++++++++-------------------- tasks/install.yml | 46 +++++++------- 5 files changed, 108 insertions(+), 95 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 41e9727..aef2982 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -6,10 +6,13 @@ register: haproxy_config_check changed_when: "Configuration file is valid" in haproxy_config_check.stdout_lines failed_when: "Configuration file is valid" not in haproxy_config_check.stdout_lines - notify: "Restart HAProxy" + notify: + - Restart HAProxy - name: Restart HAProxy - service: name={{item.name}} state={{item.state}} + service: + name: '{{ item.name }}' + state: '{{ item.state }}' with_items: - name: haproxy state: restarted diff --git a/tasks/blacklists.yml b/tasks/blacklists.yml index 29e1f01..b9c0337 100644 --- a/tasks/blacklists.yml +++ b/tasks/blacklists.yml @@ -12,4 +12,5 @@ - blacklist.ip - blacklist.referer - blacklist.agent - notify: "Check HAProxy Config" + notify: + - Check HAProxy Config diff --git a/tasks/buildcerts.yml b/tasks/buildcerts.yml index 67c9fe2..ebe887a 100644 --- a/tasks/buildcerts.yml +++ b/tasks/buildcerts.yml @@ -3,11 +3,11 @@ - name: Create PEM file for HaProxy assemble: - src='/etc/letsencrypt/live/{{ item.domain }}' - dest='/etc/haproxy/certs/{{ item.file }}' - regexp='(fullchain)|(privkey)\.pem' + src: /etc/letsencrypt/live/{{ item.domain }} + dest: /etc/haproxy/certs/{{ item.file }} + regexp: '(fullchain)|(privkey)\.pem' with_items: '{{ proxy_certificates|default([]) }}' when: item.letsencrypt|default(false) and item.active|default(true) - ignore_errors: true + ignore_errors: yes notify: - "Restart HAProxy" diff --git a/tasks/configure.yml b/tasks/configure.yml index 8975dda..1c05b1b 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -3,114 +3,123 @@ - name: Backup current settings archive: - path=/etc/haproxy - dest=/var/backups/haproxy-{{ lookup('pipe','date +%Y%m%d-%H%M%S') }}.tgz + path: /etc/haproxy + dest: /var/backups/haproxy-{{ lookup('pipe','date +%Y%m%d-%H%M%S') }}.tgz - name: Install SSL certificates copy: - src='{{inventory_dir}}/files/ssl/{{item.file}}' - dest='/etc/haproxy/certs' + src: '{{inventory_dir}}/files/ssl/{{item.file}}' + dest: /etc/haproxy/certs with_items: '{{ proxy_certificates }}' when: not item.letsencrypt|default(false) - notify: "Check HAProxy Config" + notify: + - Check HAProxy Config - name: Create host lists template: - src='host_list' - dest='/etc/haproxy/{{item}}.list' - owner='root' - group='root' - mode='644' + src: host_list + dest: /etc/haproxy/{{item}}.list + owner: root + group: root + mode: 0644 with_items: '{{ groups.webserver|default([]) }}' - notify: "Check HAProxy Config" + notify: + - Check HAProxy Config - name: Create host ssl lists template: - src='host_ssl_list' - dest='/etc/haproxy/{{item}}.ssl.list' - owner='root' - group='root' - mode='644' + src: host_ssl_list + dest: /etc/haproxy/{{item}}.ssl.list + owner: root + group: root + mode: 0644 with_items: '{{ groups.webserver|default([]) }}' - notify: "Check HAProxy Config" + notify: + - Check HAProxy Config - name: Create host path lists file: - dest='/etc/haproxy/{{item}}.path.list' - owner='root' - group='root' - mode='644' - state='touch' + dest: /etc/haproxy/{{item}}.path.list + owner: root + group: root + mode: 0644 + state: touch with_items: '{{ groups.webserver|default([]) }}' - changed_when: false + changed_when: no - name: Create use bigpipe host lists template: - src='use_bigpipe_list' - dest='/etc/haproxy/use_bigpipe.list' - owner='root' - group='root' - mode='644' - notify: "Check HAProxy Config" + src: use_bigpipe_list + dest: /etc/haproxy/use_bigpipe.list + owner: root + group: root + mode: 0644 + notify: + - Check HAProxy Config - name: Create ignore varnish host lists template: - src='ignore_varnish_list' - dest='/etc/haproxy/ignore_varnish.list' - owner='root' - group='root' - mode='644' - notify: "Check HAProxy Config" + src: ignore_varnish_list + dest: /etc/haproxy/ignore_varnish.list + owner: root + group: root + mode: 0644 + notify: + - Check HAProxy Config - name: Create empty crm lists files file: - dest='/etc/haproxy/{{item}}.crm.list' - owner='root' - group='root' - mode='644' - state='touch' + dest: /etc/haproxy/{{item}}.crm.list + owner: root + group: root + mode: 0644 + state: touch with_items: '{{ groups.webserver|default([]) }}' - changed_when: false + changed_when: no - name: Update private ips template: - src='privatelist.ip.jinja2' - dest='/etc/haproxy/privatelist.ip' - owner='root' - group='root' - mode='644' + src: privatelist.ip.jinja2 + dest: /etc/haproxy/privatelist.ip + owner: root + group: root + mode: 644 when: haproxy_private is defined - notify: "Check HAProxy Config" + notify: + - Check HAProxy Config - name: Update private domains template: - src='privatelist.domain.jinja2' - dest='/etc/haproxy/privatelist.domain' - owner='root' - group='root' - mode='644' + src: privatelist.domain.jinja2 + dest: /etc/haproxy/privatelist.domain + owner: root + group: root + mode: 0644 when: haproxy_private is defined and haproxy_private.domain is defined - notify: "Check HAProxy Config" + notify: + - Check HAProxy Config - name: Update redirect map files template: - src='redirect.map.jinja2' - dest='/etc/haproxy/redirect.{{ item }}.map' - owner='root' - group='root' - mode='644' + src: redirect.map.jinja2 + dest: /etc/haproxy/redirect.{{ item }}.map + owner: root + group: root + mode: 0644 with_items: - domain - domain-and-path - domain-append-path - path - notify: "Check HAProxy Config" + notify: + - Check HAProxy Config - name: Create config file template: - src='haproxy_cfg.jinja2' - dest='/etc/haproxy/haproxy.cfg' - owner='root' - group='root' - mode='644' - notify: "Check HAProxy Config" + src: haproxy_cfg.jinja2 + dest: /etc/haproxy/haproxy.cfg + owner: root + group: root + mode: 0644 + notify: + - Check HAProxy Config diff --git a/tasks/install.yml b/tasks/install.yml index 96a7cb1..ce1bcc6 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -3,16 +3,16 @@ - name: Add Apt Repositories apt_repository: - repo='{{ item }}' - state=present - mode='644' + repo: '{{ item }}' + state: present + mode: 0644 with_items: - "ppa:vbernat/haproxy-1.8" - name: Install some packages apt: - pkg='{{ packages }}' - state=latest + pkg: '{{ packages }}' + state: latest vars: packages: - haproxy @@ -21,35 +21,35 @@ - name: create directories file: - dest='{{ item }}' - state=directory - mode='755' + dest: '{{ item }}' + state: directory + mode: 0755 with_items: - /etc/haproxy/certs - /etc/haproxy/update - name: Install hatop shortcut copy: - src='usr_local_bin_hatop' - dest='/usr/local/bin/hatop' - owner='root' - group='root' - mode='755' + src: usr_local_bin_hatop + dest: /usr/local/bin/hatop + owner: root + group: root + mode: 0755 - name: Install log rotator copy: - src='etc_logrotate_d_haproxy' - dest='/etc/logrotate.d/haproxy' - owner='root' - group='root' - mode='644' + src: etc_logrotate_d_haproxy + dest: /etc/logrotate.d/haproxy + owner: root + group: root + mode: 0644 tags: - logrotate - name: Install script to read socket template: - src='hasocket' - dest='/usr/local/bin/hasocket' - owner='root' - group='root' - mode='755' + src: hasocket + dest: /usr/local/bin/hasocket + owner: root + group: root + mode: 0755 -- GitLab