-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsiteadd.yml
executable file
·51 lines (39 loc) · 1.69 KB
/
siteadd.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
# Install LAMP server with laravel
---
- hosts: all
user: ansible
sudo: yes
vars:
user_name: subuser
user_password: userpassword345345
db_user: dbusername
db_user_password: dbuserpassword
site_fqdn: something.example.com
tasks:
- name: Test connection
ping:
- name: Creating user "{{ user_name }}" with password
user: name={{ user_name }} password={{ user_password |password_hash('sha512') }}
- name: Create MySQL database "{{user_name}}"
mysql_db: name={{user_name}} state=present
- name: Create MySQL user "{{user_name}}" with password and grant permissions to "{{user_name}}" database
mysql_user: name={{user_name}} password={{user_password}} priv={{user_name}}.*:ALL state=present
- name: Create MySQL user "{{db_user}}" with password and grant limited permissions to "{{user_name}}" database
mysql_user: name={{db_user}} password={{db_user_password}} priv={{user_name}}.*:INSERT,UPDATE,SELECT:ALL state=present
- name: create virtual host for "{{site_fqdn}}"
template: src=host.conf dest=/etc/apache2/sites-available/{{user_name}}.conf
- name: Install laravel (please be patient)
shell: sudo -u {{user_name}} composer create-project --prefer-dist laravel/laravel {{site_fqdn}}
args:
chdir: /home/{{user_name}}
- name: Create symlink for public directory
file:
src: /home/{{user_name}}/{{site_fqdn}}/public
dest: /home/{{user_name}}/public
state: link
- name: Change permissions
shell: chown -R {{user_name}}:{{user_name}} /home/{{user_name}}
- name: Enable virtaulhost
shell: a2ensite {{user_name}}
- name: Service apache reload
service: name=apache2 state=reloaded