Skip to content
Snippets Groups Projects
Commit 9b4173d1 authored by jurgenhaas's avatar jurgenhaas
Browse files

ansible-playbooks/general#85 Linting [skip-ci]

parent e84a44cc
No related branches found
No related tags found
No related merge requests found
...@@ -6,10 +6,13 @@ ...@@ -6,10 +6,13 @@
register: haproxy_config_check register: haproxy_config_check
changed_when: "Configuration file is valid" in haproxy_config_check.stdout_lines 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 failed_when: "Configuration file is valid" not in haproxy_config_check.stdout_lines
notify: "Restart HAProxy" notify:
- Restart HAProxy
- name: Restart HAProxy - name: Restart HAProxy
service: name={{item.name}} state={{item.state}} service:
name: '{{ item.name }}'
state: '{{ item.state }}'
with_items: with_items:
- name: haproxy - name: haproxy
state: restarted state: restarted
...@@ -12,4 +12,5 @@ ...@@ -12,4 +12,5 @@
- blacklist.ip - blacklist.ip
- blacklist.referer - blacklist.referer
- blacklist.agent - blacklist.agent
notify: "Check HAProxy Config" notify:
- Check HAProxy Config
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
- name: Create PEM file for HaProxy - name: Create PEM file for HaProxy
assemble: assemble:
src='/etc/letsencrypt/live/{{ item.domain }}' src: /etc/letsencrypt/live/{{ item.domain }}
dest='/etc/haproxy/certs/{{ item.file }}' dest: /etc/haproxy/certs/{{ item.file }}
regexp='(fullchain)|(privkey)\.pem' regexp: '(fullchain)|(privkey)\.pem'
with_items: '{{ proxy_certificates|default([]) }}' with_items: '{{ proxy_certificates|default([]) }}'
when: item.letsencrypt|default(false) and item.active|default(true) when: item.letsencrypt|default(false) and item.active|default(true)
ignore_errors: true ignore_errors: yes
notify: notify:
- "Restart HAProxy" - "Restart HAProxy"
...@@ -3,114 +3,123 @@ ...@@ -3,114 +3,123 @@
- name: Backup current settings - name: Backup current settings
archive: archive:
path=/etc/haproxy path: /etc/haproxy
dest=/var/backups/haproxy-{{ lookup('pipe','date +%Y%m%d-%H%M%S') }}.tgz dest: /var/backups/haproxy-{{ lookup('pipe','date +%Y%m%d-%H%M%S') }}.tgz
- name: Install SSL certificates - name: Install SSL certificates
copy: copy:
src='{{inventory_dir}}/files/ssl/{{item.file}}' src: '{{inventory_dir}}/files/ssl/{{item.file}}'
dest='/etc/haproxy/certs' dest: /etc/haproxy/certs
with_items: '{{ proxy_certificates }}' with_items: '{{ proxy_certificates }}'
when: not item.letsencrypt|default(false) when: not item.letsencrypt|default(false)
notify: "Check HAProxy Config" notify:
- Check HAProxy Config
- name: Create host lists - name: Create host lists
template: template:
src='host_list' src: host_list
dest='/etc/haproxy/{{item}}.list' dest: /etc/haproxy/{{item}}.list
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
with_items: '{{ groups.webserver|default([]) }}' with_items: '{{ groups.webserver|default([]) }}'
notify: "Check HAProxy Config" notify:
- Check HAProxy Config
- name: Create host ssl lists - name: Create host ssl lists
template: template:
src='host_ssl_list' src: host_ssl_list
dest='/etc/haproxy/{{item}}.ssl.list' dest: /etc/haproxy/{{item}}.ssl.list
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
with_items: '{{ groups.webserver|default([]) }}' with_items: '{{ groups.webserver|default([]) }}'
notify: "Check HAProxy Config" notify:
- Check HAProxy Config
- name: Create host path lists - name: Create host path lists
file: file:
dest='/etc/haproxy/{{item}}.path.list' dest: /etc/haproxy/{{item}}.path.list
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
state='touch' state: touch
with_items: '{{ groups.webserver|default([]) }}' with_items: '{{ groups.webserver|default([]) }}'
changed_when: false changed_when: no
- name: Create use bigpipe host lists - name: Create use bigpipe host lists
template: template:
src='use_bigpipe_list' src: use_bigpipe_list
dest='/etc/haproxy/use_bigpipe.list' dest: /etc/haproxy/use_bigpipe.list
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
notify: "Check HAProxy Config" notify:
- Check HAProxy Config
- name: Create ignore varnish host lists - name: Create ignore varnish host lists
template: template:
src='ignore_varnish_list' src: ignore_varnish_list
dest='/etc/haproxy/ignore_varnish.list' dest: /etc/haproxy/ignore_varnish.list
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
notify: "Check HAProxy Config" notify:
- Check HAProxy Config
- name: Create empty crm lists files - name: Create empty crm lists files
file: file:
dest='/etc/haproxy/{{item}}.crm.list' dest: /etc/haproxy/{{item}}.crm.list
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
state='touch' state: touch
with_items: '{{ groups.webserver|default([]) }}' with_items: '{{ groups.webserver|default([]) }}'
changed_when: false changed_when: no
- name: Update private ips - name: Update private ips
template: template:
src='privatelist.ip.jinja2' src: privatelist.ip.jinja2
dest='/etc/haproxy/privatelist.ip' dest: /etc/haproxy/privatelist.ip
owner='root' owner: root
group='root' group: root
mode='644' mode: 644
when: haproxy_private is defined when: haproxy_private is defined
notify: "Check HAProxy Config" notify:
- Check HAProxy Config
- name: Update private domains - name: Update private domains
template: template:
src='privatelist.domain.jinja2' src: privatelist.domain.jinja2
dest='/etc/haproxy/privatelist.domain' dest: /etc/haproxy/privatelist.domain
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
when: haproxy_private is defined and haproxy_private.domain is defined when: haproxy_private is defined and haproxy_private.domain is defined
notify: "Check HAProxy Config" notify:
- Check HAProxy Config
- name: Update redirect map files - name: Update redirect map files
template: template:
src='redirect.map.jinja2' src: redirect.map.jinja2
dest='/etc/haproxy/redirect.{{ item }}.map' dest: /etc/haproxy/redirect.{{ item }}.map
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
with_items: with_items:
- domain - domain
- domain-and-path - domain-and-path
- domain-append-path - domain-append-path
- path - path
notify: "Check HAProxy Config" notify:
- Check HAProxy Config
- name: Create config file - name: Create config file
template: template:
src='haproxy_cfg.jinja2' src: haproxy_cfg.jinja2
dest='/etc/haproxy/haproxy.cfg' dest: /etc/haproxy/haproxy.cfg
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
notify: "Check HAProxy Config" notify:
- Check HAProxy Config
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
- name: Add Apt Repositories - name: Add Apt Repositories
apt_repository: apt_repository:
repo='{{ item }}' repo: '{{ item }}'
state=present state: present
mode='644' mode: 0644
with_items: with_items:
- "ppa:vbernat/haproxy-1.8" - "ppa:vbernat/haproxy-1.8"
- name: Install some packages - name: Install some packages
apt: apt:
pkg='{{ packages }}' pkg: '{{ packages }}'
state=latest state: latest
vars: vars:
packages: packages:
- haproxy - haproxy
...@@ -21,35 +21,35 @@ ...@@ -21,35 +21,35 @@
- name: create directories - name: create directories
file: file:
dest='{{ item }}' dest: '{{ item }}'
state=directory state: directory
mode='755' mode: 0755
with_items: with_items:
- /etc/haproxy/certs - /etc/haproxy/certs
- /etc/haproxy/update - /etc/haproxy/update
- name: Install hatop shortcut - name: Install hatop shortcut
copy: copy:
src='usr_local_bin_hatop' src: usr_local_bin_hatop
dest='/usr/local/bin/hatop' dest: /usr/local/bin/hatop
owner='root' owner: root
group='root' group: root
mode='755' mode: 0755
- name: Install log rotator - name: Install log rotator
copy: copy:
src='etc_logrotate_d_haproxy' src: etc_logrotate_d_haproxy
dest='/etc/logrotate.d/haproxy' dest: /etc/logrotate.d/haproxy
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
tags: tags:
- logrotate - logrotate
- name: Install script to read socket - name: Install script to read socket
template: template:
src='hasocket' src: hasocket
dest='/usr/local/bin/hasocket' dest: /usr/local/bin/hasocket
owner='root' owner: root
group='root' group: root
mode='755' mode: 0755
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment