Compare commits

...

3 Commits

Author SHA1 Message Date
Justine Pelletreau
bec78b8405 Added stop 2021-09-25 13:04:53 +02:00
Justine Pelletreau
ed5699cd78 Stopped Apache before installing varnish 2021-09-24 12:12:30 +02:00
Justine Pelletreau
be4595bc7e Added stopvarnish 2021-09-24 09:56:08 +02:00
4 changed files with 79 additions and 2 deletions

BIN
1613725221862.jpg.tmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 881 KiB

72
stopvarnish.yml Executable file
View File

@ -0,0 +1,72 @@
---
- hosts: all
become: True
tasks:
- name: Create conf directory
ansible.builtin.file:
path: /etc/systemd/system/varnish.service.d
state: directory
mode: '0655'
- name: Dropping config in conf directory
ansible.builtin.template:
src: templates/customexec.conf.j2
dest: /etc/systemd/system/varnish.service.d/customexec.conf
mode: '0655'
owner: root
group: root
- name: Dropping Varnish config (default.vcl)
ansible.builtin.template:
src: templates/default.vcl.j2
dest: /etc/varnish/default.vcl
mode: '0644'
force: yes
- name: Reload daemons, enable varnish
ansible.builtin.systemd:
daemon_reload: yes
name: varnish.service
enabled: no
state: stopped
- name: Modfying Apache default port
ansible.builtin.lineinfile:
path: /etc/apache2/ports.conf
regexp: '^Listen 8080$'
line: 'Listen 80'
- name: Find all enabled vhosts
ansible.builtin.find:
paths: /etc/apache2/sites-available
patterns: "*.conf"
follow: yes
file_type: file
register: vhosts
- name: dbg
ansible.builtin.debug:
var: vhosts.files
- name: Modfying VHosts
ansible.builtin.replace:
path: "{{ item.path }}"
regexp: '^\<[Vv]irtual[Hh]ost \*:8080\>$'
replace: "<VirtualHost *:80>"
with_items:
- "{{ vhosts.files }}"
- name: Activating Apache Headers Mod
community.general.apache2_module:
state: present
name: headers
identifier: headers_module
- name: Restart Varnish and Apache
ansible.builtin.systemd:
name: "{{ item }}"
state: restarted
with_items:
- "apache2.service"

View File

@ -34,7 +34,7 @@ sub vcl_backend_response {
set beresp.ttl = 2h;
set beresp.grace = 24h;
if (bereq.url ~ "\.(bmp|ejs|jpeg|pdf|ps|ttf|class|eot|jpg|pict|svg|webp|html|htm|css|eps|js|pls|svgz|woff|csv|gif|mid|png|swf|woff2|doc|ico|midi|ppt|tif|xls|docx|jar|otf|pptx|tiff|xlsx|mp3)$") {
if (bereq.url ~ "\.(bmp|ejs|jpeg|pdf|ps|ttf|class|eot|jpg|pict|svg|webp|html|htm|css|eps|js|pls|svgz|woff|csv|gif|mid|png|swf|woff2|doc|ico|midi|ppt|tif|xls|docx|jar|otf|pptx|tiff|xlsx|php|mp3)$") {
set beresp.ttl = 1y;
set beresp.grace = 24h;
}

View File

@ -2,7 +2,12 @@
- hosts: all
become: True
tasks:
tasks:
- name: Stop Apache
ansible.builtin.systemd:
name: apache2
state: stopped
- name: Install Varnish
ansible.builtin.package:
name: varnish