-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapache.yml
More file actions
35 lines (26 loc) · 1.41 KB
/
apache.yml
File metadata and controls
35 lines (26 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
---
- name: Config apache
hosts: all
tasks:
# - name: Apache2 listen on port 8080
# lineinfile: dest=/etc/apache2/ports.conf regexp="^Listen 80" line="Listen 8080" state=present
# when: frontend_name.stdout.find('apache') != -1
# - name: Apache2 listen on port 8443
# lineinfile: dest=/etc/apache2/ports.conf regexp="(Listen).*(443)" line="Listen 8443" state=present
# when: frontend_name.stdout.find('apache') != -1
- name: Apache2 listen on port 8080
shell: echo "Listen 8080" > /etc/apache2/ports.conf
when: frontend_name.stdout.find('apache') != -1
- name: Apache2 virtualhost on port 8080
lineinfile: dest=/etc/apache2/sites-available/000-default.conf regexp="^<VirtualHost \*:80>" line="<VirtualHost *:8080>" state=present
when: frontend_name.stdout.find('apache') != -1
- name: Get worker size
shell: ps -auxww | grep apache | grep -v root | awk '{print $6}' | sort -n | tail -n1
register: worker_size
- name: Get max workers
shell: echo {{ (((ansible_memtotal_mb - 264) * 0.9) / (worker_size.stdout|int / 1024))|int }}
register: max_workers
- name: Set max workers
lineinfile: dest=/etc/apache2/mods-available/mpm_prefork.conf regexp="MaxRequestWorkers.*([0-9])\w+" line="MaxRequestWorkers {{ max_workers.stdout }}" state=present
- name: Restart apache2
service: name=apache2 state=restarted