forked from mageops/ansible-infrastructure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vagrant.switch-project.yml
55 lines (49 loc) · 1.45 KB
/
vagrant.switch-project.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
- hosts: "app"
become: yes
tasks:
- name: Create root directory
file:
state: directory
name: "{{ mageops_app_web_dir }}"
owner: "{{ magento_user }}"
group: "{{ magento_group }}"
- name: Symlink project
file:
force: yes
state: link
src: "{{ mageops_app_web_dir }}/{{ mageops_project }}"
dest: "{{ mageops_app_web_dir }}/current"
owner: "{{ magento_user }}"
group: "{{ magento_group }}"
- name: Save projects info to file
copy:
dest: "{{ mageops_app_web_dir }}/current_project.json"
content: "{{ mageops_current_project_info | to_nice_json }}"
vars:
mageops_current_project_info:
name: "{{ mageops_project }}"
- name: Change project name in nginx config
lineinfile:
path: "{{ nginx_confd_dir }}/magento.conf"
regexp: '^\s*set\s+\$PROJ_NAME\s+[\w\-_]+;\s*$'
line: ' set $PROJ_NAME {{ mageops_project }};'
create: no
state: present
insertafter: '^\s*server\s*{\s*$'
validate: "echo 'http { include %s; }' > /tmp/n && /sbin/nginx -t -c /tmp/n"
- name: Restart services
service:
name: "{{ item }}"
state: restarted
loop:
- php-fpm
- nginx
- varnish
- redis
roles:
- role: cs.mageops-cli-profile
mageops_node_role: raccoon
- hosts: database
become: yes
roles:
- cs.mysql-configure