forked from leucos/ansible-tuto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapache.yml
50 lines (39 loc) · 1.56 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: web
tasks:
- name: Updates apt cache
apt: update_cache=true
- name: Installs necessary packages
apt: pkg={{ item }} state=latest
with_items:
- apache2
- libapache2-mod-php5
- git
- name: Push future default virtual host configuration
copy: src=files/awesome-app dest=/etc/apache2/sites-available/ mode=0640
- name: Activates our virtualhost
command: a2ensite awesome-app
- name: Check that our config is valid
command: apache2ctl configtest
register: result
ignore_errors: True
- name: Rolling back - Restoring old default virtualhost
command: a2ensite default
when: result|failed
- name: Rolling back - Removing out virtualhost
command: a2dissite awesome-app
when: result|failed
- name: Rolling back - Ending playbook
fail: msg="Configuration file is not valid. Please check that before re-running the playbook."
when: result|failed
- name: Deploy our awesome application
git: repo=https://github.com/leucos/ansible-tuto-demosite.git dest=/var/www/awesome-app
tags: deploy
- name: Deactivates the default virtualhost
command: a2dissite default
- name: Deactivates the default ssl virtualhost
command: a2dissite default-ssl
notify:
- restart apache
handlers:
- name: restart apache
service: name=apache2 state=restarted