2016-05-04 07:53:33 +00:00
|
|
|
---
|
|
|
|
- hosts: localhost
|
|
|
|
vars:
|
2018-01-20 18:27:35 +00:00
|
|
|
bench_path: "/home/{{ frappe_user }}/{{ bench_name }}"
|
2016-05-04 07:53:33 +00:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
|
|
|
|
# In case we are re-running the script, we would like to skip the site creation
|
|
|
|
- name: Check whether a site exists
|
|
|
|
stat: path="{{ bench_path }}/sites/{{ site }}"
|
|
|
|
register: site_folder
|
|
|
|
|
2018-01-20 18:27:35 +00:00
|
|
|
- name: Add additional conf for MariaDB 10.2 in mariadb.conf.d
|
|
|
|
blockinfile:
|
|
|
|
path: /etc/mysql/conf.d/settings.cnf
|
|
|
|
block: |
|
|
|
|
# Import all .cnf files from configuration directory
|
|
|
|
!includedir /etc/mysql/mariadb.conf.d/
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian'
|
|
|
|
|
|
|
|
- name: Add additional conf for MariaDB 10.2 in mariadb.conf.d
|
|
|
|
blockinfile:
|
|
|
|
path: /etc/mysql/mariadb.conf.d/erpnext.cnf
|
|
|
|
block: |
|
|
|
|
[mysqld]
|
|
|
|
pid-file = /var/run/mysqld/mysqld.pid
|
|
|
|
socket = /var/run/mysqld/mysqld.sock
|
|
|
|
create: yes
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian'
|
|
|
|
|
|
|
|
- name: restart mysql
|
|
|
|
service: name=mysql state=restarted
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
|
2016-05-04 07:53:33 +00:00
|
|
|
- name: Create new site
|
|
|
|
command: bench new-site {{ site }} --admin-password {{ admin_password }} --mariadb-root-password {{ mysql_root_password }}
|
|
|
|
args:
|
|
|
|
chdir: "{{ bench_path }}"
|
|
|
|
when: not site_folder.stat.exists
|
|
|
|
|
|
|
|
- name: Check ERPNext App exists
|
|
|
|
stat: path="{{ bench_path }}/apps/erpnext"
|
|
|
|
register: app
|
|
|
|
|
|
|
|
# In case we are re-running the script, we would like to skip getting ERPNext App
|
|
|
|
- name: Get-app erpnext app
|
|
|
|
command: bench get-app erpnext https://github.com/frappe/erpnext.git --branch {{ branch }}
|
|
|
|
args:
|
|
|
|
chdir: '{{ bench_path }}'
|
|
|
|
when: not app.stat.exists
|
|
|
|
|
|
|
|
- name: Install erpnext app
|
|
|
|
command: bench --site {{ site }} install-app erpnext
|
|
|
|
args:
|
|
|
|
chdir: '{{ bench_path }}'
|
|
|
|
|
|
|
|
- name: Change permissions for frappe home folder
|
2016-06-28 09:36:12 +00:00
|
|
|
become: yes
|
|
|
|
become_user: root
|
2016-05-04 07:53:33 +00:00
|
|
|
file:
|
2018-01-20 18:27:35 +00:00
|
|
|
dest: '/home/{{ frappe_user }}'
|
|
|
|
owner: '{{ frappe_user }}'
|
|
|
|
group: '{{ frappe_user }}'
|
2016-05-04 07:53:33 +00:00
|
|
|
mode: 0755
|
|
|
|
recurse: yes
|
2016-05-25 10:47:48 +00:00
|
|
|
state: directory
|
2016-05-04 07:53:33 +00:00
|
|
|
|
|
|
|
- name: Setup production
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
2018-01-20 18:27:35 +00:00
|
|
|
command: bench setup production {{ frappe_user }}
|
2016-05-04 07:53:33 +00:00
|
|
|
args:
|
|
|
|
chdir: '{{ bench_path }}'
|
|
|
|
|
|
|
|
- name: Setup Sudoers
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
2018-01-20 18:27:35 +00:00
|
|
|
command: bench setup sudoers {{ frappe_user }}
|
2016-05-04 07:53:33 +00:00
|
|
|
args:
|
|
|
|
chdir: '{{ bench_path }}'
|
|
|
|
|
|
|
|
- name: Restart the bench
|
|
|
|
command: bench restart
|
|
|
|
args:
|
|
|
|
chdir: '{{ bench_path }}'
|