-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlamp.yml
80 lines (70 loc) · 1.88 KB
/
lamp.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
- name: This playbook will setup environment for PHP development
hosts: lamp_desk
sudo: yes
vars_files:
- vars/local.yml
- vars/lamp.yml
pre_tasks:
- name: Update apt cache if needed.
apt:
update_cache: yes
cache_valid_time: 86400
- name: Ensure user exist
user:
name: "{{ user_name }}"
state: present
generate_ssh_key: yes
ssh_key_bits: 2048
ssh_key_file: .ssh/id_rsa
- name: Ensure www folder exists
file:
path: "{{ user_folder }}"
state: directory
group: "{{ user_name }}"
owner: "{{ user_name }}"
mode: 0755
- name: "Update hosts file"
lineinfile:
dest: /etc/hosts
regexp: '.*{{ item }}$'
line: "127.0.0.1 {{item.servername}}"
state: present
with_items: "{{ local_domains }}"
- name: Ensure www folder exists
file:
path: "{{ item.documentroot }}"
group: "{{ user_name }}"
owner: "{{ user_name }}"
state: directory
mode: 0755
with_items: "{{ local_domains }}"
roles:
- apache
- php
- composer
post_tasks:
- name: Enable php5 mcrypt module
shell: phpenmod mcrypt
args:
creates: /etc/php5/cli/conf.d/20-mcrypt.ini
notify: restart apache
- name: Remove native Apache user
lineinfile:
dest: /etc/apache2/envvars
regexp: 'export {{ item }}\=www-data$'
state: absent
with_items:
- APACHE_RUN_USER
- APACHE_RUN_GROUP
notify: restart apache
- name: Setup username for Apache process
lineinfile:
dest: /etc/apache2/envvars
regexp: 'export {{ item }}\={{ user_name }}$'
line: "export {{ item }}={{ user_name }}"
state: present
with_items:
- APACHE_RUN_USER
- APACHE_RUN_GROUP
notify: restart apache