2016-05-04 07:53:33 +00:00
|
|
|
---
|
|
|
|
- hosts: localhost
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
|
|
|
|
####################################################
|
|
|
|
# Replace default nginx config with nginx template
|
|
|
|
- name: Rename default nginx.conf to nginx.conf.old
|
|
|
|
command: mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
|
|
|
|
- name: Copy the nginx_config template
|
|
|
|
template:
|
|
|
|
src: ../templates/default_nginx.j2
|
|
|
|
dest: /etc/nginx/nginx.conf
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
|
|
|
|
- name: Reload the nginx service
|
|
|
|
service:
|
|
|
|
name: nginx
|
2016-07-28 12:52:20 +00:00
|
|
|
state: restarted
|
2016-05-04 07:53:33 +00:00
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
|
2016-11-07 11:53:17 +00:00
|
|
|
######################################################
|
|
|
|
# Set InnoDB Buffer Pool size to half of total RAM
|
|
|
|
- name: Set InnoDB buffer pool
|
|
|
|
lineinfile: >
|
|
|
|
dest=/etc/my.cnf.d/frappe.cnf
|
|
|
|
regexp="^\[mysqld\]$"
|
|
|
|
line="[mysqld]\ninnodb_buffer_pool_size={{ (ansible_memtotal_mb/2)|round|int }}M"
|
|
|
|
state=present
|
|
|
|
when: ansible_distribution == 'CentOS'
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
|
|
|
|
- name: Set InnoDB buffer pool
|
|
|
|
lineinfile: >
|
|
|
|
dest=/etc/mysql/conf.d/frappe.cnf
|
|
|
|
regexp="^\[mysqld\]$"
|
|
|
|
line="[mysqld]\ninnodb_buffer_pool_size={{ (ansible_memtotal_mb/2)|round|int }}M"
|
|
|
|
state=present
|
|
|
|
when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian'
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
|
2016-05-04 07:53:33 +00:00
|
|
|
####################################################
|
|
|
|
# Enable nginx, mysql, redis and supevisord services
|
|
|
|
- name: Enable nginx, mysql, and redis
|
|
|
|
service:
|
|
|
|
name: '{{ item }}'
|
|
|
|
enabled: yes
|
|
|
|
with_items:
|
|
|
|
- nginx
|
|
|
|
- mysql
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
|
|
|
|
- name: Enable redis.service on centos
|
|
|
|
service:
|
|
|
|
name: redis
|
|
|
|
enabled: yes
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
when: ansible_distribution == 'CentOS'
|
|
|
|
|
|
|
|
- name: Enable redis-server.service on ubuntu
|
|
|
|
service:
|
|
|
|
name: redis-server
|
|
|
|
enabled: yes
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
2016-07-27 07:40:52 +00:00
|
|
|
when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian'
|
2016-05-04 07:53:33 +00:00
|
|
|
|
|
|
|
- name: Check whether default supervisor.conf exists
|
|
|
|
service:
|
|
|
|
name: supervisord
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
2016-07-14 11:34:23 +00:00
|
|
|
when: ansible_distribution == 'CentOS'
|
|
|
|
|
|
|
|
- name: Check whether default supervisor.conf exists
|
|
|
|
service:
|
|
|
|
name: supervisor
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
2016-07-27 07:40:52 +00:00
|
|
|
when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian'
|
2016-08-22 10:32:16 +00:00
|
|
|
|