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 @@
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
......@@ -12,4 +12,5 @@
- blacklist.ip
- blacklist.referer
- blacklist.agent
notify: "Check HAProxy Config"
notify:
- Check HAProxy Config
......@@ -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"
......@@ -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
......@@ -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
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