-
Notifications
You must be signed in to change notification settings - Fork 8
/
apache.yml
50 lines (39 loc) · 1.38 KB
/
apache.yml
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
- hosts: apache
become: yes
vars:
http_port: 80
domain: example.cloudgeni.us
tasks:
- name: install packages
apt: name={{ item }} update_cache=yes state=latest
with_items:
- apache2
- git
- name: enable apache2
service: name=apache2 state=started
- name: enabled mod_rewrite
apache2_module: name=rewrite state=present
notify:
- restart apache2
- name: apache2 listen on port {{ http_port }}
lineinfile: dest=/etc/apache2/ports.conf regexp="^Listen " line="Listen {{ http_port }}" state=present
notify:
- restart apache2
- name: apache2 virtualhost on port {{ http_port }}
lineinfile: dest=/etc/apache2/sites-available/000-default.conf regexp="^<VirtualHost \*:" line="<VirtualHost *:{{ http_port }}>"
notify:
- restart apache2
- name: create virtual host file
template: src=virtualhost.conf dest=/etc/apache2/sites-available/{{ domain }}.conf
- name: a2ensite {{ domain }}
command: a2ensite {{ domain }}
args:
creates: /etc/apache2/sites-enabled/{{ domain }}.conf
notify:
- restart apache2
- name: clone basic html template
git: repo=https://github.com/beacloudgenius/ansible-apache-site.git dest=/var/www/{{ domain }} update=yes
handlers:
- name: restart apache2
service: name=apache2 state=restarted