-
Notifications
You must be signed in to change notification settings - Fork 1
/
site.yml
146 lines (128 loc) · 3.81 KB
/
site.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
---
- hosts: mbp
remote_user: root
tasks:
- name: Install required packages
apt:
name: "{{ item }}"
state: present
with_items:
- apache2
- mysql-server
- apt-transport-https
- python-mysqldb
- git
- curl
- sudo
- name: Add PHP repository key
apt_key:
url: https://packages.sury.org/php/apt.gpg
state: present
- name: Add PHP repository
apt_repository:
repo: "deb https://packages.sury.org/php/ stretch main"
state: present
update_cache: yes
- name: Install PHP7.1 and required extenstions
apt:
name: "{{ item }}"
state: present
with_items:
- php7.1
- php7.1-cli
- php7.1-common
- php7.1-json
- php7.1-opcache
- php7.1-mysql
- php7.1-mbstring
- php7.1-mcrypt
- php7.1-zip
- php7.1-fpm
- php7.1-bcmath
- php7.1-soap
- php7.1-curl
- php7.1-dom
- php7.1-gd
- php7.1-intl
- php7.1-simplexml
- php7.1-xsl
- libapache2-mod-php7.1
- name: Add system group "magento"
group:
name: magento
state: present
- name: Create system user magento
user:
name: magento
system: yes
createhome: yes
home: /home/magento
shell: /bin/bash
groups: magento,www-data
- name: Validate sudoers
lineinfile:
path: /etc/sudoers
state: present
regexp: '^%magento ALL='
line: '%magento ALL=(ALL) NOPASSWD: ALL'
validate: '/usr/sbin/visudo -cf %s'
- name: Enable modules
apache2_module:
name: "{{ item }}"
state: present
identifier: "{{ item }}_module"
with_items:
- rewrite
- ssl
#- php7.1
register: modules
- name: Create database
mysql_db:
name: magento
state: present
- mysql_user:
name: magento
password: "{{ magento_dbuser_pwd }}"
priv: '*.*:ALL,GRANT'
state: present
- name: install composer
shell: curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
args:
creates: /usr/local/bin/composer
- name: Clone Magento
git:
repo: https://github.com/magento/magento2.git
dest: /var/www/magento
clone: yes
version: "{{ magento_version }}"
force: yes
- name: Install deps via composer
composer:
command: install
working_dir: /var/www/magento
- name: Configure Magento
shell: php -f bin/magento setup:install --base-url=https://{{ domain_name }} --backend-frontname=admin --db-host=localhost --db-name=magento --db-user=magento --db-password={{ magento_dbuser_pwd }} --admin-firstname=Magento --admin-lastname=User [email protected] --admin-user={{ magento_admin_username }} --admin-password={{ magento_admin_username_pwd }} --language=en_US --currency=USD --use-rewrites=1
args:
chdir: /var/www/magento
- name: Rename file
shell: mv /var/www/magento/pub/errors/local.xml.sample /var/www/magento/pub/errors/local.xml
- name: Deploy Static Content
shell: php -f bin/magento setup:static-content:deploy -f
args:
chdir: /var/www/magento
- name: Verify ownership
file:
path: /var/www/magento/
owner: magento
group: www-data
recurse: yes
- name: Upload config
template:
src: apache.conf
dest: /etc/apache2/sites-enabled/{{ domain_name }}.conf
register: config
- name: Restart Apache
systemd:
name: apache2.service
state: restarted
when: config.changed or modules.changed