mirror of
https://github.com/frappe/bench.git
synced 2024-11-11 15:51:03 +00:00
commit
63047730c5
143
.gitignore
vendored
143
.gitignore
vendored
@ -1,8 +1,139 @@
|
||||
*.pyc
|
||||
*.py~
|
||||
*.swp
|
||||
# MAC OS
|
||||
.DS_Store
|
||||
build/
|
||||
dist/
|
||||
*.egg-info/
|
||||
|
||||
# Vim Gitignore
|
||||
## Swap
|
||||
[._]*.s[a-v][a-z]
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-v][a-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
## Session
|
||||
Session.vim
|
||||
|
||||
## Temporary
|
||||
.netrwhist
|
||||
*~
|
||||
|
||||
## Auto-generated tag files
|
||||
tags
|
||||
|
||||
# Python Gitignore
|
||||
## Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
## C extensions
|
||||
*.so
|
||||
|
||||
## Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
## PyInstaller
|
||||
## Usually these files are written by a python script from a template
|
||||
## before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
## Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
## Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
## Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
## Django stuff:
|
||||
*.log
|
||||
.static_storage/
|
||||
.media/
|
||||
local_settings.py
|
||||
|
||||
## Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
## Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
## Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
## PyBuilder
|
||||
target/
|
||||
|
||||
## Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
## pyenv
|
||||
.python-version
|
||||
|
||||
## celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
## SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
## Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
## Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
## Rope project settings
|
||||
.ropeproject
|
||||
|
||||
## mkdocs documentation
|
||||
/site
|
||||
|
||||
## mypy
|
||||
.mypy_cache/
|
||||
|
||||
# Packer Gitignore
|
||||
## Cache objects
|
||||
packer_cache/
|
||||
*.checksum
|
||||
|
||||
## For built virtualmachines
|
||||
*.ova
|
||||
*.iso
|
||||
|
||||
## For built boxes
|
||||
*.box
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import os, sys, json, click
|
||||
from bench.utils import run_playbook, setup_sudoers
|
||||
from bench.utils import run_playbook, setup_sudoers, is_root
|
||||
|
||||
extra_vars = {"production": True}
|
||||
|
||||
@ -46,6 +46,14 @@ def install_nginx(user=None):
|
||||
if user:
|
||||
setup_sudoers(user)
|
||||
|
||||
@click.command('virtualbox')
|
||||
def install_virtualbox():
|
||||
run_playbook('vm_build.yml', tag='virtualbox')
|
||||
|
||||
@click.command('packer')
|
||||
def install_packer():
|
||||
run_playbook('vm_build.yml', tag='packer')
|
||||
|
||||
@click.command('fail2ban')
|
||||
@click.option('--maxretry', default=6, help="Number of matches (i.e. value of the counter) which triggers ban action on the IP.")
|
||||
@click.option('--bantime', default=600, help="The counter is set to zero if no match is found within 'findtime' seconds.")
|
||||
@ -61,4 +69,6 @@ install.add_command(install_nodejs)
|
||||
install.add_command(install_psutil)
|
||||
install.add_command(install_supervisor)
|
||||
install.add_command(install_nginx)
|
||||
install.add_command(install_failtoban)
|
||||
install.add_command(install_failtoban)
|
||||
install.add_command(install_virtualbox)
|
||||
install.add_command(install_packer)
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
# Install's prerequisites, like fonts, image libraries, vim, screen, python-dev and gcc
|
||||
# Install's prerequisites, like fonts, image libraries, vim, screen, python-dev
|
||||
|
||||
- include_tasks: debian_family.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
6
playbooks/roles/packer/tasks/debian_family.yml
Normal file
6
playbooks/roles/packer/tasks/debian_family.yml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: Install unzip
|
||||
apt: pkg={{ item }} update_cache=yes state=present
|
||||
with_items:
|
||||
- unzip
|
||||
...
|
37
playbooks/roles/packer/tasks/main.yml
Normal file
37
playbooks/roles/packer/tasks/main.yml
Normal file
@ -0,0 +1,37 @@
|
||||
---
|
||||
- name: Check if packer already exists
|
||||
stat:
|
||||
path: /opt/packer
|
||||
register: packer
|
||||
|
||||
- name: Check if packer version is 1.2.1
|
||||
command: /opt/packer --version
|
||||
register: packer_version
|
||||
when: packer.stat.exists
|
||||
|
||||
- include_tasks: debian_family.yml
|
||||
when: ansible_os_family == 'Debian' and packer.stat.exists == False
|
||||
|
||||
- include_tasks: redhat_family.yml
|
||||
when: ansible_os_family == "RedHat" and packer.stat.exists == False
|
||||
|
||||
- name: Delete packer if < 1.2.1
|
||||
file:
|
||||
state: absent
|
||||
path: /opt/packer
|
||||
when: (packer.stat.exists) and (packer_version | version_compare('1.2.1', '<'))
|
||||
|
||||
- name: Download packer zip file
|
||||
command: chdir=/opt/ wget https://releases.hashicorp.com/packer/1.2.1/packer_1.2.1_linux_amd64.zip
|
||||
when: (packer.stat.exists == False) or (packer_version | version_compare('1.2.1', '<'))
|
||||
|
||||
- name: Unzip the packer binary in /opt
|
||||
command: chdir=/opt/ unzip packer_1.2.1_linux_amd64.zip
|
||||
when: (packer.stat.exists == False) or (packer_version | version_compare('1.2.1', '<'))
|
||||
|
||||
- name: Remove the downloaded packer zip file
|
||||
file:
|
||||
state: absent
|
||||
path: /opt/packer_1.2.1_linux_amd64.zip
|
||||
when: (packer.stat.exists == False) or (packer_version | version_compare('1.2.1', '<'))
|
||||
...
|
7
playbooks/roles/packer/tasks/redhat_family.yml
Normal file
7
playbooks/roles/packer/tasks/redhat_family.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Install unzip
|
||||
yum: name={{ item }} state=present
|
||||
with_items:
|
||||
- unzip
|
||||
...
|
3
playbooks/roles/virtualbox/defaults/main.yml
Normal file
3
playbooks/roles/virtualbox/defaults/main.yml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
virtualbox_version: 5.2
|
||||
...
|
7
playbooks/roles/virtualbox/files/virtualbox_centos.repo
Normal file
7
playbooks/roles/virtualbox/files/virtualbox_centos.repo
Normal file
@ -0,0 +1,7 @@
|
||||
[virtualbox]
|
||||
name=Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox
|
||||
baseurl=http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch
|
||||
enabled=1
|
||||
gpgcheck=1
|
||||
repo_gpgcheck=1
|
||||
gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
|
29
playbooks/roles/virtualbox/tasks/debian_family.yml
Normal file
29
playbooks/roles/virtualbox/tasks/debian_family.yml
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
- name: Install dependencies
|
||||
apt: pkg={{ item }} state=present
|
||||
with_items:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
|
||||
- name: Add VirtualBox to sources.list
|
||||
apt_repository:
|
||||
repo: deb https://download.virtualbox.org/virtualbox/debian {{ ansible_distribution_release }} contrib
|
||||
state: present
|
||||
|
||||
- name: Add apt signing key for VirtualBox for Debian >= 8 and Ubuntu >= 16
|
||||
apt_key:
|
||||
url: https://www.virtualbox.org/download/oracle_vbox_2016.asc
|
||||
state: present
|
||||
when: (ansible_distribution == "Debian" and ansible_distribution_major_version >= "8") or (ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "16")
|
||||
|
||||
- name: Add apt signing key for VirtualBox for Debian < 8 and Ubuntu < 16
|
||||
apt_key:
|
||||
url: https://www.virtualbox.org/download/oracle_vbox.asc
|
||||
state: present
|
||||
when: (ansible_distribution == "Debian" and ansible_distribution_major_version < "8") or (ansible_distribution == "Ubuntu" and ansible_distribution_major_version < "16")
|
||||
|
||||
- name: Install VirtualBox
|
||||
apt: pkg={{ item }} update_cache=yes state=present
|
||||
with_items:
|
||||
- virtualbox-{{ virtualbox_version }}
|
||||
...
|
7
playbooks/roles/virtualbox/tasks/main.yml
Normal file
7
playbooks/roles/virtualbox/tasks/main.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
- include_tasks: debian_family.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- include_tasks: redhat_family.yml
|
||||
when: ansible_os_family == "RedHat"
|
||||
...
|
17
playbooks/roles/virtualbox/tasks/redhat_family.yml
Normal file
17
playbooks/roles/virtualbox/tasks/redhat_family.yml
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
- name: Install the 'Development tools' package group
|
||||
yum:
|
||||
name: "@Development tools"
|
||||
state: present
|
||||
|
||||
- name: Install dependencies
|
||||
yum: name={{ item }} state=present
|
||||
with_items:
|
||||
- kernel-devel
|
||||
- deltarpm
|
||||
|
||||
- copy: src=virtualbox_centos.repo dest=/etc/yum.repos.d/virtualbox.repo owner=root group=root mode=0644 force=no
|
||||
|
||||
- name: Install VirtualBox
|
||||
command: yum install -y VirtualBox-{{ virtualbox_version }}
|
||||
...
|
9
playbooks/vm_build.yml
Normal file
9
playbooks/vm_build.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: Install Packer
|
||||
hosts: localhost
|
||||
become: yes
|
||||
become_user: root
|
||||
roles:
|
||||
- { role: virtualbox, tags: "virtualbox" }
|
||||
- { role: packer, tags: "packer" }
|
||||
...
|
46
vm/Readme.md
46
vm/Readme.md
@ -1,25 +1,43 @@
|
||||
### ERPNext VM Builder
|
||||
|
||||
#### Steps to build a vm image
|
||||
|
||||
* Install VirtualBox
|
||||
* Place a `base.ova` ubuntu base image in the current directory.
|
||||
* `./packer build vm.json` builds a new vm.
|
||||
#### Steps to build a VM Image
|
||||
|
||||
* `python build.py` builds a new VM
|
||||
|
||||
|
||||
#### Requirements
|
||||
|
||||
* Bench should be installed.
|
||||
* Ansible should be installed
|
||||
|
||||
|
||||
#### How it works
|
||||
|
||||
Packer imports the base image in a virtual machine and boots it. It runs the following
|
||||
Apart from the above the rest is handled by bench:
|
||||
|
||||
* Install prerequisites if not already installed
|
||||
- virtualbox
|
||||
- packer
|
||||
* Cleanup
|
||||
- Clean the required directories
|
||||
* Generate the erpnext_develop.json and the erpnext_production.json
|
||||
- Figure out the latest ubuntu iso available, get it's link and the checksum and generate the json files
|
||||
* Build the VM using packer
|
||||
- Packer downloads the mentioned Ubuntu iso, boots a virtual machine and preceeds the preseed.cfg file into it in order to setup a clean Ubuntu OS
|
||||
- Then packer uses ssh to enter the virtual machine to execute the required commands
|
||||
- `scripts/debian_family/install_ansible.sh` sets up ansible on the vm.
|
||||
- Depending on the VM being built, the `install_erpnext_develop.sh` or the `install_erpnext_production.sh` is executed
|
||||
- `scripts/set_message.sh` sets welcome message (with update instructions) in the vm.
|
||||
- `scripts/cleanup.sh` writes zero to all the free space in the disk, it shrinks the disk image
|
||||
* Set the correct permissions for the built Vagrant and Virtual Appliance Images
|
||||
* Cleanup
|
||||
- Delete the generated files from the required directories
|
||||
* restart nginx
|
||||
|
||||
The requirements for this to run are Packer and Virtualbox. imports the base image in a virtual machine and boots it. It runs the following
|
||||
|
||||
* `scripts/install_ansible.sh` sets up ansible on the vm.
|
||||
* The `ansible/vm.yml` playbook sets up the dependencies, installs a bench and sets up a site. It also puts it into production.
|
||||
* `scripts/set_message.sh` sets welcome message (with update instructions) in the vm.
|
||||
* `scripts/zerofree.sh` writes zero to all the free space in the disk, it shrinks the disk image.
|
||||
|
||||
#### For a build server
|
||||
|
||||
Running the `build.py` script builds a vm and puts it in `~/public`. It also writes a `latest.json` file in `~/public` with filename of the latest build and its md5sum.
|
||||
|
||||
#### Packer binary
|
||||
|
||||
The binary included in this tree is compiled (for linux amd64) with a fix for https://github.com/mitchellh/packer/issues/2447. We can remove it once a new version of packer is released.
|
||||
|
||||
|
73
vm/Vagrantfile
vendored
Normal file
73
vm/Vagrantfile
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version (we support older styles for
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure(2) do |config|
|
||||
# The most common configuration options are documented and commented below.
|
||||
# For a complete reference, please see the online documentation at
|
||||
# https://docs.vagrantup.com.
|
||||
|
||||
# Every Vagrant development environment requires a box. You can search for
|
||||
# boxes at https://atlas.hashicorp.com/search.
|
||||
config.vm.box = "erpnext"
|
||||
config.ssh.username = "frappe"
|
||||
config.ssh.password = "frappe"
|
||||
|
||||
# Disable automatic box update checking. If you disable this, then
|
||||
# boxes will only be checked for updates when the user runs
|
||||
# `vagrant box outdated`. This is not recommended.
|
||||
# config.vm.box_check_update = false
|
||||
|
||||
# Create a forwarded port mapping which allows access to a specific port
|
||||
# within the machine from a port on the host machine. In the example below,
|
||||
# accessing "localhost:8080" will access port 80 on the guest machine.
|
||||
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
||||
|
||||
# Create a private network, which allows host-only access to the machine
|
||||
# using a specific IP.
|
||||
# config.vm.network "private_network", ip: "192.168.33.10"
|
||||
|
||||
# Create a public network, which generally matched to bridged network.
|
||||
# Bridged networks make the machine appear as another physical device on
|
||||
# your network.
|
||||
# config.vm.network "public_network"
|
||||
|
||||
# Share an additional folder to the guest VM. The first argument is
|
||||
# the path on the host to the actual folder. The second argument is
|
||||
# the path on the guest to mount the folder. And the optional third
|
||||
# argument is a set of non-required options.
|
||||
# config.vm.synced_folder "../data", "/vagrant_data"
|
||||
|
||||
# Provider-specific configuration so you can fine-tune various
|
||||
# backing providers for Vagrant. These expose provider-specific options.
|
||||
# Example for VirtualBox:
|
||||
#
|
||||
# config.vm.provider "virtualbox" do |vb|
|
||||
# # Display the VirtualBox GUI when booting the machine
|
||||
# vb.gui = true
|
||||
#
|
||||
# # Customize the amount of memory on the VM:
|
||||
# vb.memory = "1024"
|
||||
# end
|
||||
#
|
||||
# View the documentation for the provider you are using for more
|
||||
# information on available options.
|
||||
|
||||
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
|
||||
# such as FTP and Heroku are also available. See the documentation at
|
||||
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
|
||||
# config.push.define "atlas" do |push|
|
||||
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
|
||||
# end
|
||||
|
||||
# Enable provisioning with a shell script. Additional provisioners such as
|
||||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
||||
# documentation for more information about their specific syntax and use.
|
||||
# config.vm.provision "shell", inline: <<-SHELL
|
||||
# sudo apt-get update
|
||||
# sudo apt-get install -y apache2
|
||||
# SHELL
|
||||
end
|
@ -1,104 +0,0 @@
|
||||
---
|
||||
- name: Apply basic roles
|
||||
hosts: all
|
||||
become: yes
|
||||
become_user: root
|
||||
vars:
|
||||
- mysql_secure_installation: True
|
||||
- mysql_conf_tpl: templates/mariadb_config.cnf
|
||||
- nginx_conf_file: templates/nginx.conf
|
||||
roles:
|
||||
- mariadb
|
||||
- nginx
|
||||
- wkhtmltopdf
|
||||
tasks:
|
||||
- name: Install the 'Development tools' package group (Redhat)
|
||||
yum: name="@Development tools" state=present
|
||||
when: ansible_os_family == 'RedHat'
|
||||
- name: Install packages
|
||||
yum: name={{ item }} state=present
|
||||
with_items:
|
||||
- git
|
||||
- nginx
|
||||
- zlib-devel
|
||||
- bzip2-devel
|
||||
- openssl-devel
|
||||
- postfix
|
||||
- python-devel
|
||||
- mariadb
|
||||
- redis
|
||||
- libXrender
|
||||
- libXext
|
||||
- cronie
|
||||
- sudo
|
||||
- which
|
||||
- xorg-x11-fonts-75dpi
|
||||
- xorg-x11-fonts-Type1
|
||||
- screen
|
||||
- vim
|
||||
- git
|
||||
- nginx
|
||||
- zlib-devel
|
||||
- bzip2-devel
|
||||
- openssl-devel
|
||||
- postfix
|
||||
- python-devel
|
||||
- redis
|
||||
- cronie
|
||||
- sudo
|
||||
- which
|
||||
- supervisor
|
||||
- nodejs
|
||||
- npm
|
||||
- libtiff-devel
|
||||
- libjpeg-devel
|
||||
- libzip-devel
|
||||
- freetype-devel
|
||||
- lcms2-devel
|
||||
- libwebp-devel
|
||||
- tcl-devel
|
||||
- tk-devel
|
||||
when: ansible_os_family == 'RedHat'
|
||||
- name: Install packages
|
||||
apt: pkg={{ item }} state=present
|
||||
with_items:
|
||||
- python-dev
|
||||
- python-setuptools
|
||||
- build-essential
|
||||
- python-mysqldb
|
||||
- git
|
||||
- ntp
|
||||
- vim
|
||||
- screen
|
||||
- htop
|
||||
- mariadb-server
|
||||
- mariadb-common
|
||||
- libmariadbclient-dev
|
||||
- libxslt1.1
|
||||
- libxslt1-dev
|
||||
- redis-server
|
||||
- libssl-dev
|
||||
- libcrypto++-dev
|
||||
- postfix
|
||||
- nginx
|
||||
- supervisor
|
||||
- python-pip
|
||||
- fontconfig
|
||||
- libxrender1
|
||||
- libxext6
|
||||
- xfonts-75dpi
|
||||
- xfonts-base
|
||||
- nodejs
|
||||
- npm
|
||||
- libtiff5-dev
|
||||
- libjpeg8-dev
|
||||
- zlib1g-dev
|
||||
- libfreetype6-dev
|
||||
- liblcms2-dev
|
||||
- libwebp-dev
|
||||
- tcl8.6-dev
|
||||
- tk8.6-dev
|
||||
- python-tk
|
||||
when: ansible_os_family == 'Debian'
|
||||
- user: name="{{ frappe_user }}"
|
||||
|
@ -1,84 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
|
||||
def init_bench(path, frappe_branch):
|
||||
if not frappe_branch:
|
||||
frappe_branch = 'master'
|
||||
subprocess.check_call("bench init {} --frappe-branch {}".format(path, frappe_branch), shell=True)
|
||||
|
||||
def check_if_app_exists(app, bench_path):
|
||||
return os.path.exists(os.path.join(bench_path, 'apps', app))
|
||||
|
||||
def check_if_site_exists(site, bench_path):
|
||||
return os.path.exists(os.path.join(bench_path, 'sites', site))
|
||||
|
||||
def get_app(app, url, branch, bench_path):
|
||||
subprocess.check_call("bench get-app {} {} --branch {}".format(app, url, branch), cwd=bench_path, shell=True)
|
||||
|
||||
def install_site(site, mariadb_root_password, bench_path):
|
||||
admin_password = site.get('admin_password')
|
||||
site_name = site['name']
|
||||
subprocess.check_call("bench new-site {} --mariadb-root-password {} --admin-password {}".format(site_name, mariadb_root_password, admin_password), cwd=bench_path, shell=True)
|
||||
|
||||
for app in site['apps']:
|
||||
subprocess.check_call("bench --site {} install-app {}".format(site['name'], app), cwd=bench_path, shell=True)
|
||||
|
||||
site_config_path = os.path.join(bench_path, 'sites', site_name, 'site_config.json')
|
||||
with open(site_config_path) as f:
|
||||
site_config = json.load(f)
|
||||
site_config.update(site.get('site_config', {}))
|
||||
with open(site_config_path, 'wb') as f:
|
||||
json.dump(site_config, f)
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
path=dict(required=True),
|
||||
apps=dict(required=True),
|
||||
sites=dict(required=True),
|
||||
mariadb_root_password=dict(),
|
||||
frappe_branch=dict(),
|
||||
),
|
||||
supports_check_mode=True
|
||||
)
|
||||
changed = False
|
||||
|
||||
bench_path = module.params['path']
|
||||
if not os.path.exists(bench_path):
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True)
|
||||
|
||||
init_bench(bench_path, module.params['frappe_branch'])
|
||||
changed = True
|
||||
|
||||
|
||||
for app in module.params['apps']:
|
||||
if not check_if_app_exists(app['name'], bench_path):
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True)
|
||||
|
||||
get_app(app['url'], app.get('branch', 'master'), bench_path)
|
||||
changed = True
|
||||
|
||||
for site in module.params['sites']:
|
||||
if not check_if_site_exists(site['name'], bench_path):
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True)
|
||||
|
||||
mariadb_root_password = module.params.get('mariadb_root_password')
|
||||
if not mariadb_root_password:
|
||||
module.fail_json(msg="MariaDB root password not passed")
|
||||
|
||||
if not site.get('admin_password'):
|
||||
module.fail_json(msg="Admin password not passed for {}".format(site['name']))
|
||||
|
||||
install_site(site, mariadb_root_password, bench_path)
|
||||
changed = True
|
||||
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
main()
|
@ -1,64 +0,0 @@
|
||||
# Ansible Role: MariaDB
|
||||
|
||||
Installs MariaDB
|
||||
|
||||
## Supported platforms
|
||||
|
||||
```
|
||||
CentOS 6 & 7
|
||||
Ubuntu 14.04
|
||||
```
|
||||
|
||||
## Post install
|
||||
|
||||
Run `mysql_secure_installation`
|
||||
|
||||
## Requirements
|
||||
|
||||
None
|
||||
|
||||
## Role Variables
|
||||
|
||||
MariaDB version:
|
||||
|
||||
```
|
||||
mariadb_version: 10.0
|
||||
```
|
||||
|
||||
Configuration template:
|
||||
|
||||
```
|
||||
mysql_conf_tpl: change_me
|
||||
```
|
||||
|
||||
Configuration filename:
|
||||
|
||||
```
|
||||
mysql_conf_file: settings.cnf
|
||||
```
|
||||
|
||||
### Experimental unattended mysql_secure_installation
|
||||
|
||||
```
|
||||
ansible-playbook release.yml --extra-vars "mysql_secure_installation=true mysql_root_password=your_very_secret_password"
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
None
|
||||
|
||||
## Example Playbook
|
||||
|
||||
```
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: pcextreme.mariadb }
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT / BSD
|
||||
|
||||
## Author Information
|
||||
|
||||
Created by [Attila van der Velde](https://github.com/vdvm)
|
@ -1,7 +0,0 @@
|
||||
---
|
||||
mariadb_version: 10.0
|
||||
|
||||
mysql_conf_tpl: change_me
|
||||
mysql_conf_file: settings.cnf
|
||||
|
||||
mysql_secure_installation: false
|
@ -1,3 +0,0 @@
|
||||
---
|
||||
- name: restart mysql
|
||||
service: name=mysql state=restarted
|
@ -1,19 +0,0 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: "Attila van der Velde"
|
||||
description: "Installs MariaDB"
|
||||
company: "PCextreme B.V."
|
||||
license: "license (MIT, BSD)"
|
||||
min_ansible_version: 1.8
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 6
|
||||
- 7
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- trusty
|
||||
categories:
|
||||
- database:sql
|
||||
|
||||
dependencies: []
|
@ -1,12 +0,0 @@
|
||||
---
|
||||
- name: Add repo file
|
||||
template: src=mariadb_centos.repo.j2 dest=/etc/yum.repos.d/mariadb.repo owner=root group=root mode=0644
|
||||
|
||||
- name: Install MariaDB
|
||||
yum: name={{ item }} enablerepo=mariadb state=present
|
||||
with_items:
|
||||
- MariaDB-server
|
||||
- MariaDB-client
|
||||
- MySQL-python
|
||||
- MariaDB-devel
|
||||
|
@ -1,18 +0,0 @@
|
||||
---
|
||||
- include_tasks: centos.yml
|
||||
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version|int >= 6
|
||||
|
||||
- include_tasks: ubuntu.yml
|
||||
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '14.04'
|
||||
|
||||
- name: Add configuration
|
||||
template: src={{ mysql_conf_tpl }} dest={{ mysql_conf_dir[ansible_distribution] }}/{{ mysql_conf_file }} owner=root group=root mode=0644
|
||||
when: mysql_conf_tpl != 'change_me'
|
||||
notify: restart mysql
|
||||
|
||||
- name: Start and enable service
|
||||
service: name=mysql state=started enabled=yes
|
||||
|
||||
- include_tasks: mysql_secure_installation.yml
|
||||
debug: var=mysql_secure_installation
|
||||
when: mysql_secure_installation and mysql_root_password is defined
|
@ -1,57 +0,0 @@
|
||||
---
|
||||
# Set root password
|
||||
# UPDATE mysql.user SET Password=PASSWORD('mysecret') WHERE User='root';
|
||||
# FLUSH PRIVILEGES;
|
||||
|
||||
|
||||
- name: Set root Password
|
||||
mysql_user: name=root host={{ item }} password={{ mysql_root_password }} state=present
|
||||
with_items:
|
||||
- localhost
|
||||
|
||||
- name: Add .my.cnf
|
||||
template: src=my.cnf.j2 dest=/root/.my.cnf owner=root group=root mode=0600
|
||||
|
||||
- name: Set root Password
|
||||
mysql_user: name=root host={{ item }} password={{ mysql_root_password }} state=present
|
||||
with_items:
|
||||
- 127.0.0.1
|
||||
- ::1
|
||||
|
||||
- name: Reload privilege tables
|
||||
command: 'mysql -ne "{{ item }}"'
|
||||
with_items:
|
||||
- FLUSH PRIVILEGES
|
||||
changed_when: False
|
||||
|
||||
- name: Reload privilege tables
|
||||
command: 'mysql -ne "{{ item }}"'
|
||||
with_items:
|
||||
- FLUSH PRIVILEGES
|
||||
changed_when: False
|
||||
|
||||
- name: Remove anonymous users
|
||||
command: 'mysql -ne "{{ item }}"'
|
||||
with_items:
|
||||
- DELETE FROM mysql.user WHERE User=''
|
||||
changed_when: False
|
||||
|
||||
- name: Disallow root login remotely
|
||||
command: 'mysql -ne "{{ item }}"'
|
||||
with_items:
|
||||
- DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')
|
||||
changed_when: False
|
||||
|
||||
- name: Remove test database and access to it
|
||||
command: 'mysql -ne "{{ item }}"'
|
||||
with_items:
|
||||
- DROP DATABASE if exists test
|
||||
- DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'
|
||||
changed_when: False
|
||||
ignore_errors: True
|
||||
|
||||
- name: Reload privilege tables
|
||||
command: 'mysql -ne "{{ item }}"'
|
||||
with_items:
|
||||
- FLUSH PRIVILEGES
|
||||
changed_when: False
|
@ -1,23 +0,0 @@
|
||||
---
|
||||
- name: Add repo file
|
||||
template: src=mariadb_ubuntu.list.j2 dest=/etc/apt/sources.list.d/mariadb.list owner=root group=root mode=0644
|
||||
register: mariadb_list
|
||||
|
||||
- name: Add repo key
|
||||
apt_key: id=1BB943DB url=http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xCBCB082A1BB943DB state=present
|
||||
register: mariadb_key
|
||||
|
||||
- name: Update apt cache
|
||||
apt: update_cache=yes
|
||||
when: mariadb_list.changed == True or mariadb_key.changed == True
|
||||
|
||||
- name: Unattended package installation
|
||||
shell: export DEBIAN_FRONTEND=noninteractive
|
||||
changed_when: false
|
||||
|
||||
- name: Install MariaDB
|
||||
apt: pkg={{ item }} state=present
|
||||
with_items:
|
||||
- mariadb-server
|
||||
- mariadb-client
|
||||
- python-mysqldb
|
@ -1,7 +0,0 @@
|
||||
# MariaDB CentOS {{ ansible_distribution_major_version|int }} repository list
|
||||
# http://mariadb.org/mariadb/repositories/
|
||||
[mariadb]
|
||||
name = MariaDB
|
||||
baseurl = http://yum.mariadb.org/{{ mariadb_version }}/centos{{ ansible_distribution_major_version|int }}-amd64
|
||||
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
|
||||
gpgcheck=1
|
@ -1,4 +0,0 @@
|
||||
# MariaDB Ubuntu {{ ansible_distribution_release | title }} repository list
|
||||
# http://mariadb.org/mariadb/repositories/
|
||||
deb http://ams2.mirrors.digitalocean.com/mariadb/repo/{{ mariadb_version }}/ubuntu {{ ansible_distribution_release | lower }} main
|
||||
deb-src http://ams2.mirrors.digitalocean.com/mariadb/repo/{{ mariadb_version }}/ubuntu {{ ansible_distribution_release | lower }} main
|
@ -1,3 +0,0 @@
|
||||
[client]
|
||||
user=root
|
||||
password={{ mysql_root_password }}
|
@ -1,4 +0,0 @@
|
||||
---
|
||||
mysql_conf_dir:
|
||||
"CentOS": /etc/my.cnf.d
|
||||
"Ubuntu": /etc/mysql/conf.d
|
@ -1,35 +0,0 @@
|
||||
---
|
||||
language: python
|
||||
python: "2.7"
|
||||
|
||||
env:
|
||||
- SITE=test.yml
|
||||
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -y curl
|
||||
|
||||
install:
|
||||
# Install Ansible.
|
||||
- pip install ansible
|
||||
|
||||
# Add ansible.cfg to pick up roles path.
|
||||
- "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"
|
||||
|
||||
script:
|
||||
# Check the role/playbook's syntax.
|
||||
- "ansible-playbook -i tests/inventory tests/$SITE --syntax-check"
|
||||
|
||||
# Run the role/playbook with ansible-playbook.
|
||||
- "ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo"
|
||||
|
||||
# Run the role/playbook again, checking to make sure it's idempotent.
|
||||
- >
|
||||
ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo
|
||||
| grep -q 'changed=0.*failed=0'
|
||||
&& (echo 'Idempotence test: pass' && exit 0)
|
||||
|| (echo 'Idempotence test: fail' && exit 1)
|
||||
|
||||
# TODO - get the test working. Probably need to add a virtual host.
|
||||
# Request a page via Nginx, to make sure Nginx is running and responds.
|
||||
# - "curl http://localhost/"
|
@ -1,82 +0,0 @@
|
||||
# Ansible Role: Nginx
|
||||
|
||||
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-nginx.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-nginx)
|
||||
|
||||
Installs Nginx on RedHat/CentOS or Debian/Ubuntu linux servers.
|
||||
|
||||
This role installs and configures the latest version of Nginx from the Nginx yum repository (on RedHat-based systems) or via apt (on Debian-based systems). You will likely need to do extra setup work after this role has installed Nginx, like adding your own [virtualhost].conf file inside `/etc/nginx/conf.d/`, describing the location and options to use for your particular website.
|
||||
|
||||
## Requirements
|
||||
|
||||
None.
|
||||
|
||||
## Role Variables
|
||||
|
||||
Available variables are listed below, along with default values (see `defaults/main.yml`):
|
||||
|
||||
nginx_vhosts: []
|
||||
|
||||
A list of vhost definitions (server blocks) for Nginx virtual hosts. If left empty, you will need to supply your own virtual host configuration. See the commented example in `defaults/main.yml` for available server options. If you have a large number of customizations required for your server definition(s), you're likely better off managing the vhost configuration file yourself, leaving this variable set to `[]`.
|
||||
|
||||
nginx_remove_default_vhost: false
|
||||
|
||||
Whether to remove the 'default' virtualhost configuration supplied by Nginx. Useful if you want the base `/` URL to be directed at one of your own virtual hosts configured in a separate .conf file.
|
||||
|
||||
nginx_upstreams: []
|
||||
|
||||
If you are configuring Nginx as a load balancer, you can define one or more upstream sets using this variable. In addition to defining at least one upstream, you would need to configure one of your server blocks to proxy requests through the defined upstream (e.g. `proxy_pass http://myapp1;`). See the commented example in `defaults/main.yml` for more information.
|
||||
|
||||
nginx_user: "nginx"
|
||||
|
||||
The user under which Nginx will run. Defaults to `nginx` for RedHat, and `www-data` for Debian.
|
||||
|
||||
nginx_worker_processes: "1"
|
||||
nginx_worker_connections: "1024"
|
||||
|
||||
`nginx_worker_processes` should be set to the number of cores present on your machine. Connections (find this number with `grep processor /proc/cpuinfo | wc -l`). `nginx_worker_connections` is the number of connections per process. Set this higher to handle more simultaneous connections (and remember that a connection will be used for as long as the keepalive timeout duration for every client!).
|
||||
|
||||
nginx_error_log: "/var/log/nginx/error.log warn"
|
||||
nginx_access_log: "/var/log/nginx/access.log main buffer=16k"
|
||||
|
||||
Configuration of the default error and access logs. Set to `off` to disable a log entirely.
|
||||
|
||||
nginx_sendfile: "on"
|
||||
nginx_tcp_nopush: "on"
|
||||
nginx_tcp_nodelay: "on"
|
||||
|
||||
TCP connection options. See [this blog post](https://t37.net/nginx-optimization-understanding-sendfile-tcp_nodelay-and-tcp_nopush.html) for more information on these directives.
|
||||
|
||||
nginx_keepalive_timeout: "65"
|
||||
nginx_keepalive_requests: "100"
|
||||
|
||||
Nginx keepalive settings. Timeout should be set higher (10s+) if you have more polling-style traffic (AJAX-powered sites especially), or lower (<10s) if you have a site where most users visit a few pages and don't send any further requests.
|
||||
|
||||
nginx_client_max_body_size: "64m"
|
||||
|
||||
This value determines the largest file upload possible, as uploads are passed through Nginx before hitting a backend like `php-fpm`. If you get an error like `client intended to send too large body`, it means this value is set too low.
|
||||
|
||||
nginx_proxy_cache_path: ""
|
||||
|
||||
Set as the `proxy_cache_path` directive in the `nginx.conf` file. By default, this will not be configured (if left as an empty string), but if you wish to use Nginx as a reverse proxy, you can set this to a valid value (e.g. `"/var/cache/nginx keys_zone=cache:32m"`) to use Nginx's cache (further proxy configuration can be done in individual server configurations).
|
||||
|
||||
nginx_default_release: ""
|
||||
|
||||
(For Debian/Ubuntu only) Allows you to set a different repository for the installation of Nginx. As an example, if you are running Debian's wheezy release, and want to get a newer version of Nginx, you can install the `wheezy-backports` repository and set that value here, and Ansible will use that as the `-t` option while installing Nginx.
|
||||
|
||||
## Dependencies
|
||||
|
||||
None.
|
||||
|
||||
## Example Playbook
|
||||
|
||||
- hosts: server
|
||||
roles:
|
||||
- { role: geerlingguy.nginx }
|
||||
|
||||
## License
|
||||
|
||||
MIT / BSD
|
||||
|
||||
## Author Information
|
||||
|
||||
This role was created in 2014 by [Jeff Geerling](http://jeffgeerling.com/), author of [Ansible for DevOps](http://ansiblefordevops.com/).
|
@ -1,47 +0,0 @@
|
||||
---
|
||||
# Used only for Debian/Ubuntu installation, as the -t option for apt.
|
||||
nginx_default_release: ""
|
||||
|
||||
nginx_worker_processes: "1"
|
||||
nginx_worker_connections: "1024"
|
||||
|
||||
nginx_error_log: "/var/log/nginx/error.log warn"
|
||||
nginx_access_log: "/var/log/nginx/access.log main buffer=16k"
|
||||
|
||||
nginx_sendfile: "on"
|
||||
nginx_tcp_nopush: "on"
|
||||
nginx_tcp_nodelay: "on"
|
||||
|
||||
nginx_keepalive_timeout: "65"
|
||||
nginx_keepalive_requests: "100"
|
||||
|
||||
nginx_client_max_body_size: "64m"
|
||||
|
||||
nginx_proxy_cache_path: ""
|
||||
|
||||
nginx_remove_default_vhost: false
|
||||
nginx_vhosts: []
|
||||
# Example vhost below, showing all available options:
|
||||
# - {
|
||||
# listen: "80 default_server", # default: "80 default_server"
|
||||
# server_name: "example.com", # default: N/A
|
||||
# root: "/var/www/example.com", # default: N/A
|
||||
# index: "index.html index.htm", # default: "index.html index.htm"
|
||||
#
|
||||
# # Properties that are only added if defined:
|
||||
# error_page: "",
|
||||
# access_log: "",
|
||||
# extra_config: "" # Can be used to add extra config blocks (multiline).
|
||||
# }
|
||||
|
||||
nginx_upstreams: []
|
||||
# - {
|
||||
# name: myapp1,
|
||||
# strategy: "ip_hash", # "least_conn", etc.
|
||||
# servers: {
|
||||
# "srv1.example.com",
|
||||
# "srv2.example.com weight=3",
|
||||
# "srv3.example.com"
|
||||
# }
|
||||
# }
|
||||
nginx_conf_file: nginx.conf.j2
|
@ -1,3 +0,0 @@
|
||||
---
|
||||
- name: restart nginx
|
||||
service: name=nginx state=restarted
|
@ -1,23 +0,0 @@
|
||||
---
|
||||
dependencies: []
|
||||
|
||||
galaxy_info:
|
||||
author: geerlingguy
|
||||
description: Nginx installation for Linux/UNIX.
|
||||
company: "Midwestern Mac, LLC"
|
||||
license: "license (BSD, MIT)"
|
||||
min_ansible_version: 1.4
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 6
|
||||
- 7
|
||||
- name: Debian
|
||||
versions:
|
||||
- all
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- all
|
||||
categories:
|
||||
- development
|
||||
- web
|
@ -1,31 +0,0 @@
|
||||
---
|
||||
# Variable setup.
|
||||
- name: Include OS-specific variables.
|
||||
include_vars: "{{ ansible_os_family }}.yml"
|
||||
|
||||
- name: Define nginx_user.
|
||||
set_fact:
|
||||
nginx_user: "{{ __nginx_user }}"
|
||||
when: nginx_user is not defined
|
||||
|
||||
# Setup/install tasks.
|
||||
- include_tasks: setup-RedHat.yml
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- include_tasks: setup-Debian.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
# Nginx setup.
|
||||
- name: Copy nginx configuration in place.
|
||||
template:
|
||||
src: "{{ nginx_conf_file }}"
|
||||
dest: /etc/nginx/nginx.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: restart nginx
|
||||
|
||||
- name: Ensure nginx is started and enabled to start at boot.
|
||||
service: name=nginx state=started enabled=yes
|
||||
|
||||
- include_tasks: vhosts.yml
|
@ -1,6 +0,0 @@
|
||||
---
|
||||
- name: Ensure nginx is installed.
|
||||
apt:
|
||||
pkg: nginx
|
||||
state: installed
|
||||
default_release: "{{ nginx_default_release }}"
|
@ -1,11 +0,0 @@
|
||||
---
|
||||
- name: Enable nginx repo.
|
||||
template:
|
||||
src: nginx.repo.j2
|
||||
dest: /etc/yum.repos.d/nginx.repo
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- name: Ensure nginx is installed.
|
||||
yum: pkg=nginx state=installed enablerepo=nginx
|
@ -1,22 +0,0 @@
|
||||
---
|
||||
- name: Remove default nginx vhost config file (if configured).
|
||||
file:
|
||||
path: "{{ nginx_default_vhost_path }}"
|
||||
state: absent
|
||||
when: nginx_remove_default_vhost
|
||||
notify: restart nginx
|
||||
|
||||
- name: Add managed vhost config file (if any vhosts are configured).
|
||||
template:
|
||||
src: vhosts.j2
|
||||
dest: "{{ nginx_vhost_path }}/vhosts.conf"
|
||||
mode: 0644
|
||||
when: nginx_vhosts
|
||||
notify: restart nginx
|
||||
|
||||
- name: Remove managed vhost config file (if no vhosts are configured).
|
||||
file:
|
||||
path: "{{ nginx_vhost_path }}/vhosts.conf"
|
||||
state: absent
|
||||
when: not nginx_vhosts
|
||||
notify: restart nginx
|
@ -1,51 +0,0 @@
|
||||
user {{ nginx_user }};
|
||||
|
||||
error_log {{ nginx_error_log }};
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
worker_processes {{ nginx_worker_processes }};
|
||||
|
||||
events {
|
||||
worker_connections {{ nginx_worker_connections }};
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
server_names_hash_bucket_size 64;
|
||||
|
||||
client_max_body_size {{ nginx_client_max_body_size }};
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log {{ nginx_access_log }};
|
||||
|
||||
sendfile {{ nginx_sendfile }};
|
||||
tcp_nopush {{ nginx_tcp_nopush }};
|
||||
tcp_nodelay {{ nginx_tcp_nodelay }};
|
||||
|
||||
keepalive_timeout {{ nginx_keepalive_timeout }};
|
||||
keepalive_requests {{ nginx_keepalive_requests }};
|
||||
|
||||
#gzip on;
|
||||
|
||||
{% if nginx_proxy_cache_path %}
|
||||
proxy_cache_path {{ nginx_proxy_cache_path }};
|
||||
{% endif %}
|
||||
|
||||
{% for upstream in nginx_upstreams %}
|
||||
upstream {{ upstream.name }} {
|
||||
{% if upstream.strategy is defined %}
|
||||
{{ upstream.strategy }};
|
||||
{% endif %}
|
||||
{% for server in upstream.servers %}
|
||||
server {{ server }};
|
||||
{% endfor %}
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
include {{ nginx_vhost_path }}/*;
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
[nginx]
|
||||
name=nginx repo
|
||||
baseurl=http://nginx.org/packages/centos/{{ ansible_distribution_major_version }}/$basearch/
|
||||
gpgcheck=0
|
||||
enabled=1
|
@ -1,24 +0,0 @@
|
||||
{% for vhost in nginx_vhosts %}
|
||||
server {
|
||||
listen {{ vhost.listen | default('80 default_server') }};
|
||||
server_name {{ vhost.server_name }};
|
||||
|
||||
root {{ vhost.root }};
|
||||
index {{ vhost.index | default('index.html index.htm') }};
|
||||
|
||||
{% if vhost.error_page is defined %}
|
||||
error_page {{ vhost.error_page }};
|
||||
{% endif %}
|
||||
{% if vhost.access_log is defined %}
|
||||
access_log {{ vhost.access_log }};
|
||||
{% endif %}
|
||||
|
||||
{% if vhost.return is defined %}
|
||||
return {{ vhost.return }};
|
||||
{% endif %}
|
||||
|
||||
{% if vhost.extra_parameters is defined %}
|
||||
{{ vhost.extra_parameters }};
|
||||
{% endif %}
|
||||
}
|
||||
{% endfor %}
|
@ -1 +0,0 @@
|
||||
localhost
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- ansible-role-nginx
|
@ -1,4 +0,0 @@
|
||||
---
|
||||
nginx_vhost_path: /etc/nginx/sites-enabled
|
||||
nginx_default_vhost_path: /etc/nginx/sites-enabled/default
|
||||
__nginx_user: "www-data"
|
@ -1,4 +0,0 @@
|
||||
---
|
||||
nginx_vhost_path: /etc/nginx/conf.d
|
||||
nginx_default_vhost_path: /etc/nginx/conf.d/default.conf
|
||||
__nginx_user: "nginx"
|
@ -1 +0,0 @@
|
||||
swap_size_mb: 1024
|
@ -1,18 +0,0 @@
|
||||
- name: Create swap space
|
||||
command: dd if=/dev/zero of=/extraswap bs=1M count={{swap_size_mb}}
|
||||
when: ansible_swaptotal_mb < 1
|
||||
|
||||
- name: Make swap
|
||||
command: mkswap /extraswap
|
||||
when: ansible_swaptotal_mb < 1
|
||||
|
||||
- name: Add to fstab
|
||||
action: lineinfile dest=/etc/fstab regexp="extraswap" line="/extraswap none swap sw 0 0" state=present
|
||||
when: ansible_swaptotal_mb < 1
|
||||
|
||||
- name: Turn swap on
|
||||
command: swapon -a
|
||||
when: ansible_swaptotal_mb < 1
|
||||
|
||||
- name: Set swapiness
|
||||
shell: echo 1 | tee /proc/sys/vm/swappiness
|
@ -1 +0,0 @@
|
||||
wkhtmltopdf_version: 0.12.3
|
@ -1,27 +0,0 @@
|
||||
---
|
||||
- name: install base fonts
|
||||
yum: name={{ item }} state=present
|
||||
with_items:
|
||||
- libXrender
|
||||
- libXext
|
||||
- xorg-x11-fonts-75dpi
|
||||
- xorg-x11-fonts-Type1
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- name: install base fonts
|
||||
apt: name={{ item }} state=present
|
||||
with_items:
|
||||
- libxrender1
|
||||
- libxext6
|
||||
- xfonts-75dpi
|
||||
- xfonts-base
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: download wkthmltox linux
|
||||
get_url: url=https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-{{ "amd64" if ansible_architecture == "x86_64" else "i386"}}.tar.xz dest=/tmp/wkhtmltox.tar.xz
|
||||
|
||||
- name: unarchive wkhtmltopdf
|
||||
unarchive: src=/tmp/wkhtmltox.tar.xz dest=/tmp/wkhtmltox
|
||||
|
||||
- name: move to /usr/local/bin
|
||||
command: creates="/usr/local/bin/wkhtmltopdf" mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
|
@ -1,59 +0,0 @@
|
||||
[mysqld]
|
||||
|
||||
# GENERAL #
|
||||
user = mysql
|
||||
default-storage-engine = InnoDB
|
||||
socket = /var/lib/mysql/mysql.sock
|
||||
pid-file = /var/lib/mysql/mysql.pid
|
||||
|
||||
# MyISAM #
|
||||
key-buffer-size = 32M
|
||||
myisam-recover = FORCE,BACKUP
|
||||
|
||||
# SAFETY #
|
||||
max-allowed-packet = 16M
|
||||
max-connect-errors = 1000000
|
||||
innodb = FORCE
|
||||
|
||||
# DATA STORAGE #
|
||||
datadir = /var/lib/mysql/
|
||||
|
||||
# BINARY LOGGING #
|
||||
log-bin = /var/lib/mysql/mysql-bin
|
||||
expire-logs-days = 14
|
||||
sync-binlog = 1
|
||||
|
||||
# CACHES AND LIMITS #
|
||||
tmp-table-size = 32M
|
||||
max-heap-table-size = 32M
|
||||
query-cache-type = 0
|
||||
query-cache-size = 0
|
||||
max-connections = 500
|
||||
thread-cache-size = 50
|
||||
open-files-limit = 65535
|
||||
table-definition-cache = 4096
|
||||
table-open-cache = 10240
|
||||
|
||||
# INNODB #
|
||||
innodb-flush-method = O_DIRECT
|
||||
innodb-log-files-in-group = 2
|
||||
innodb-log-file-size = 512M
|
||||
innodb-flush-log-at-trx-commit = 1
|
||||
innodb-file-per-table = 1
|
||||
innodb-buffer-pool-size = {{ (ansible_memtotal_mb*0.685)|round|int }}M
|
||||
innodb-file-format = barracuda
|
||||
innodb-large-prefix = 1
|
||||
collation-server = utf8mb4_unicode_ci
|
||||
character-set-server = utf8mb4
|
||||
character-set-client-handshake = FALSE
|
||||
max_allowed_packet = 64M
|
||||
|
||||
# LOGGING #
|
||||
log-error = /var/lib/mysql/mysql-error.log
|
||||
log-queries-not-using-indexes = 0
|
||||
slow-query-log = 1
|
||||
slow-query-log-file = /var/lib/mysql/mysql-slow.log
|
||||
|
||||
[mysql]
|
||||
default-character-set = utf8mb4
|
||||
|
@ -1,44 +0,0 @@
|
||||
# For more information on configuration, see:
|
||||
# * Official English Documentation: http://nginx.org/en/docs/
|
||||
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
||||
|
||||
user www-data;
|
||||
worker_processes 1;
|
||||
|
||||
error_log /var/log/nginx/error.log;
|
||||
#error_log /var/log/nginx/error.log notice;
|
||||
#error_log /var/log/nginx/error.log info;
|
||||
|
||||
pid /run/nginx.pid;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
|
||||
#keepalive_timeout 0;
|
||||
keepalive_timeout 65;
|
||||
|
||||
#gzip on;
|
||||
|
||||
index index.html index.htm;
|
||||
|
||||
# Load modular configuration files from the /etc/nginx/conf.d directory.
|
||||
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
||||
# for more information.
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
---
|
||||
mysql_root_password: frappe
|
@ -1,64 +0,0 @@
|
||||
---
|
||||
- include_tasks: base.yml
|
||||
- name: Clone bench
|
||||
hosts: all
|
||||
user: "{{ frappe_user }}"
|
||||
tasks:
|
||||
- git:
|
||||
repo=https://github.com/frappe/bench
|
||||
dest=/home/frappe/bench-repo
|
||||
depth=no
|
||||
tags:
|
||||
- bench_install
|
||||
|
||||
- name: Install bench
|
||||
hosts: all
|
||||
become: yes
|
||||
become_user: root
|
||||
tasks:
|
||||
|
||||
- easy_install: name=pip executable=easy_install-2.7
|
||||
- pip: name=/home/frappe/bench-repo extra_args='-e'
|
||||
tags:
|
||||
- bench_install
|
||||
|
||||
|
||||
- name: Setup bench
|
||||
hosts: all
|
||||
become: yes
|
||||
become_user: "{{ frappe_user }}"
|
||||
become_method: sudo
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- bench:
|
||||
path: /home/frappe/frappe-bench
|
||||
frappe_branch: develop
|
||||
apps:
|
||||
- name: erpnext
|
||||
url: https://github.com/frappe/erpnext
|
||||
- name: erpnext_demo
|
||||
url: https://github.com/frappe/erpnext_demo
|
||||
mariadb_root_password: "{{ mysql_root_password }}"
|
||||
sites:
|
||||
- name: erpnext.vm
|
||||
admin_password: "{{ admin_password or 'admin' }}"
|
||||
apps:
|
||||
- erpnext
|
||||
tags:
|
||||
- bench_setup
|
||||
|
||||
- name: Setup Production
|
||||
hosts: all
|
||||
become: yes
|
||||
become_user: root
|
||||
become_method: sudo
|
||||
tasks:
|
||||
- shell: "bench setup sudoers {{ frappe_user }}"
|
||||
args:
|
||||
chdir: "/home/{{ frappe_user }}/frappe-bench"
|
||||
creates: "/home/{{ frappe_user }}/frappe-bench/config/supervisor.conf"
|
||||
- shell: "bench setup production {{ frappe_user }}"
|
||||
args:
|
||||
chdir: "/home/{{ frappe_user }}/frappe-bench"
|
||||
creates: "/home/{{ frappe_user }}/frappe-bench/config/supervisor.conf"
|
||||
- file: path="/home/{{ frappe_user }}/frappe-bench/logs/" recurse=yes owner="{{ frappe_user }}"
|
@ -1,4 +0,0 @@
|
||||
---
|
||||
mysql_root_password: frappe
|
||||
frappe_user: frappe
|
||||
admin_password: admin
|
138
vm/build.py
138
vm/build.py
@ -1,50 +1,128 @@
|
||||
"""
|
||||
Builds a vm and puts it in ~/public with a latest.json that has its filename and md5sum
|
||||
"""
|
||||
import os
|
||||
import subprocess
|
||||
import json
|
||||
import stat
|
||||
|
||||
OUTPUT_DIR = 'output-virtualbox-ovf'
|
||||
PUBLIC_DIR = os.path.join(os.path.expanduser('~'), 'public')
|
||||
# imports - standard imports
|
||||
import os
|
||||
import json
|
||||
import stat
|
||||
import errno
|
||||
from shutil import rmtree
|
||||
from distutils import spawn
|
||||
from subprocess import check_output
|
||||
|
||||
NEW_FILES = []
|
||||
BUILDS = ['Production', 'Developer']
|
||||
PUBLIC_DIR = os.path.join(os.path.expanduser('~'), 'Public')
|
||||
SYMLINKS = ['ERPNext-Production.ova', 'ERPNext-Dev.ova', 'ERPNext-Vagrant.box',
|
||||
'ERPNext-Production.ova.md5', 'ERPNext-Dev.ova.md5', 'ERPNext-Vagrant.box.md5']
|
||||
|
||||
def main():
|
||||
install_virtualbox()
|
||||
install_packer()
|
||||
cleanup()
|
||||
build_vm()
|
||||
update_latest()
|
||||
move_to_public()
|
||||
generate_md5_hashes()
|
||||
generate_symlinks()
|
||||
delete_old_vms()
|
||||
move_current_vms()
|
||||
cleanup()
|
||||
|
||||
def build_vm():
|
||||
subprocess.check_call("./packer build vm.json", shell=True)
|
||||
def install_virtualbox():
|
||||
if not spawn.find_executable("virtualbox"):
|
||||
check_output(['bench', 'install', 'virtualbox'])
|
||||
|
||||
def move_to_public():
|
||||
src = get_filepath()
|
||||
dest = os.path.join(PUBLIC_DIR, os.path.join(PUBLIC_DIR, get_filename()))
|
||||
def install_packer():
|
||||
if not os.path.exists(os.path.join('/', 'opt', 'packer')):
|
||||
check_output(['bench', 'install', 'packer'])
|
||||
|
||||
def silent_remove(name, is_dir=False):
|
||||
'''
|
||||
Method to safely remove a file or directory,
|
||||
without throwing error if file doesn't exist
|
||||
|
||||
By default takes in file as input, for directory:
|
||||
is_dir = True
|
||||
'''
|
||||
try:
|
||||
if is_dir:
|
||||
rmtree(name)
|
||||
else:
|
||||
os.remove(name)
|
||||
except OSError as e:
|
||||
if e.errno != errno.ENOENT: # errno.ENOENT = no such file or directory
|
||||
raise # re-raise exception if a different error occurred
|
||||
|
||||
def cleanup():
|
||||
silent_remove("Production Builds", is_dir=True)
|
||||
silent_remove("Developer Builds", is_dir=True)
|
||||
silent_remove("packer_virtualbox-iso_virtualbox-iso_md5.checksum")
|
||||
|
||||
def build_vm():
|
||||
check_output(["/opt/packer", "build", "vm-production.json"])
|
||||
check_output(["/opt/packer", "build", "vm-develop.json"])
|
||||
|
||||
def md5(build, file):
|
||||
return check_output("md5sum '{} Builds/{}'".format(build, file), shell=True).split()[0]
|
||||
|
||||
def move_to_public(build, file):
|
||||
NEW_FILES.append(file)
|
||||
src = os.path.join('{} Builds/{}'.format(build, file))
|
||||
dest = os.path.join(PUBLIC_DIR, file)
|
||||
os.rename(src, dest)
|
||||
# Make Public folder readable by others
|
||||
st = os.stat(dest)
|
||||
os.chmod(dest, st.st_mode | stat.S_IROTH)
|
||||
|
||||
def update_latest():
|
||||
with open(os.path.join(PUBLIC_DIR, "latest.json"), 'w') as f:
|
||||
json.dump(get_latest(), f)
|
||||
def generate_md5_hashes():
|
||||
for build in BUILDS:
|
||||
for file in os.listdir('{} Builds'.format(build)):
|
||||
if file.endswith(".ova") or file.endswith(".box"):
|
||||
with open('{} Builds/{}.md5'.format(build, file), 'w') as f:
|
||||
f.write(md5(build, file))
|
||||
move_to_public(build, file)
|
||||
move_to_public(build, '{}.md5'.format(file))
|
||||
|
||||
def get_latest():
|
||||
md5 = subprocess.check_output("md5sum {}".format(get_filepath()), shell=True).split()[0]
|
||||
return {
|
||||
"filename": get_filename(),
|
||||
"md5": md5
|
||||
}
|
||||
def generate_symlinks():
|
||||
for file in NEW_FILES:
|
||||
if 'md5' in file:
|
||||
if 'Vagrant' in file:
|
||||
silent_remove(os.path.join(PUBLIC_DIR, 'ERPNext-Vagrant.box.md5'))
|
||||
os.symlink(os.path.join(PUBLIC_DIR, file),
|
||||
os.path.join(PUBLIC_DIR, 'ERPNext-Vagrant.box.md5'))
|
||||
elif 'Production' in file:
|
||||
silent_remove(os.path.join(PUBLIC_DIR, 'ERPNext-Production.ova.md5'))
|
||||
os.symlink(os.path.join(PUBLIC_DIR, file),
|
||||
os.path.join(PUBLIC_DIR, 'ERPNext-Production.ova.md5'))
|
||||
else: # Develop
|
||||
silent_remove(os.path.join(PUBLIC_DIR, 'ERPNext-Dev.ova.md5'))
|
||||
os.symlink(os.path.join(PUBLIC_DIR, file),
|
||||
os.path.join(PUBLIC_DIR, 'ERPNext-Dev.ova.md5'))
|
||||
else: # ova/box files
|
||||
if 'Vagrant' in file:
|
||||
silent_remove(os.path.join(PUBLIC_DIR, 'ERPNext-Vagrant.box'))
|
||||
os.symlink(os.path.join(PUBLIC_DIR, file),
|
||||
os.path.join(PUBLIC_DIR, 'ERPNext-Vagrant.box'))
|
||||
elif 'Production' in file:
|
||||
silent_remove(os.path.join(PUBLIC_DIR, 'ERPNext-Production.ova'))
|
||||
os.symlink(os.path.join(PUBLIC_DIR, file),
|
||||
os.path.join(PUBLIC_DIR, 'ERPNext-Production.ova'))
|
||||
else: # Develop
|
||||
silent_remove(os.path.join(PUBLIC_DIR, 'ERPNext-Dev.ova'))
|
||||
os.symlink(os.path.join(PUBLIC_DIR, file),
|
||||
os.path.join(PUBLIC_DIR, 'ERPNext-Dev.ova'))
|
||||
|
||||
def get_filename():
|
||||
return os.listdir(OUTPUT_DIR)[0]
|
||||
def delete_old_vms():
|
||||
silent_remove(os.path.join(PUBLIC_DIR, 'BACKUPS'), is_dir=True)
|
||||
|
||||
def get_filepath():
|
||||
filename = os.listdir(OUTPUT_DIR)[0]
|
||||
return os.path.join(OUTPUT_DIR, filename)
|
||||
|
||||
def cleanup():
|
||||
os.rmdir(OUTPUT_DIR)
|
||||
def move_current_vms():
|
||||
os.mkdir(os.path.join(PUBLIC_DIR, 'BACKUPS'))
|
||||
for file in os.listdir(PUBLIC_DIR):
|
||||
if file in NEW_FILES or file in SYMLINKS or file == 'BACKUPS':
|
||||
continue
|
||||
src = os.path.join(PUBLIC_DIR, '{}'.format(file))
|
||||
dest = os.path.join(PUBLIC_DIR, 'BACKUPS/{}'.format(file))
|
||||
os.rename(src, dest)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
41
vm/http/preseed.cfg
Normal file
41
vm/http/preseed.cfg
Normal file
@ -0,0 +1,41 @@
|
||||
choose-mirror-bin mirror/http/proxy string
|
||||
choose-mirror-bin mirror/http/proxy string
|
||||
d-i base-installer/kernel/override-image string linux-server
|
||||
d-i clock-setup/utc boolean true
|
||||
d-i clock-setup/utc-auto boolean true
|
||||
d-i finish-install/reboot_in_progress note
|
||||
d-i grub-installer/only_debian boolean true
|
||||
d-i grub-installer/with_other_os boolean true
|
||||
d-i partman-auto/disk string /dev/sda
|
||||
d-i partman-auto-lvm/guided_size string max
|
||||
d-i partman-auto/choose_recipe select atomic
|
||||
d-i partman-auto/method string lvm
|
||||
d-i partman-lvm/confirm boolean true
|
||||
d-i partman-lvm/confirm boolean true
|
||||
d-i partman-lvm/confirm_nooverwrite boolean true
|
||||
d-i partman-lvm/device_remove_lvm boolean true
|
||||
d-i partman/choose_partition select finish
|
||||
d-i partman/confirm boolean true
|
||||
d-i partman/confirm_nooverwrite boolean true
|
||||
d-i partman/confirm_write_new_label boolean true
|
||||
d-i pkgsel/include string openssh-server cryptsetup build-essential libssl-dev libreadline-dev zlib1g-dev linux-source dkms nfs-common
|
||||
d-i pkgsel/install-language-support boolean false
|
||||
d-i pkgsel/update-policy select none
|
||||
d-i pkgsel/upgrade select full-upgrade
|
||||
d-i time/zone string UTC
|
||||
tasksel tasksel/first multiselect standard, ubuntu-server
|
||||
|
||||
d-i console-setup/ask_detect boolean false
|
||||
d-i keyboard-configuration/layoutcode string us
|
||||
d-i keyboard-configuration/modelcode string pc105
|
||||
d-i debian-installer/locale string en_US
|
||||
|
||||
# Create frappe user account.
|
||||
d-i passwd/user-fullname string frappe
|
||||
d-i passwd/username string frappe
|
||||
d-i passwd/user-password password frappe
|
||||
d-i passwd/user-password-again password frappe
|
||||
d-i user-setup/allow-password-weak boolean true
|
||||
d-i user-setup/encrypt-home boolean false
|
||||
d-i passwd/user-default-groups frappe sudo
|
||||
d-i passwd/user-uid string 900
|
13
vm/scripts/debian_family/cleanup.sh
Normal file
13
vm/scripts/debian_family/cleanup.sh
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash -eux
|
||||
|
||||
# Apt cleanup
|
||||
apt-get autoremove
|
||||
apt-get clean
|
||||
apt-get update
|
||||
|
||||
# Zero out the rest of the free space using dd, then delete the written file.
|
||||
dd if=/dev/zero of=/EMPTY bs=1M
|
||||
rm -f /EMPTY
|
||||
|
||||
# Add `sync` so Packer doesn't quit too early, before the large file is deleted.
|
||||
sync
|
10
vm/scripts/debian_family/install_ansible.sh
Normal file
10
vm/scripts/debian_family/install_ansible.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash -eux
|
||||
|
||||
# Install Ansible repository.
|
||||
apt -y update && apt-get -y upgrade
|
||||
apt -y install software-properties-common
|
||||
apt-add-repository ppa:ansible/ansible
|
||||
|
||||
# Install Ansible.
|
||||
apt -y update
|
||||
apt -y install ansible
|
8
vm/scripts/debian_family/install_erpnext_develop.sh
Normal file
8
vm/scripts/debian_family/install_erpnext_develop.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash -eux
|
||||
|
||||
# Install base requirements.
|
||||
apt-get install -y curl git wget vim python-dev gcc
|
||||
|
||||
# Install ERPNext
|
||||
wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py
|
||||
sudo python install.py --develop --user frappe --mysql-root-password frappe --admin-password admin
|
8
vm/scripts/debian_family/install_erpnext_production.sh
Normal file
8
vm/scripts/debian_family/install_erpnext_production.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash -eux
|
||||
|
||||
# Install base requirements.
|
||||
apt-get install -y curl git wget vim python-dev gcc
|
||||
|
||||
# Install ERPNext
|
||||
wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py
|
||||
sudo python install.py --production --user frappe --mysql-root-password frappe --admin-password admin
|
8
vm/scripts/debian_family/setup.sh
Normal file
8
vm/scripts/debian_family/setup.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash -eux
|
||||
|
||||
# Add frappe user to sudoers.
|
||||
echo "frappe ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
|
||||
|
||||
# Disable daily apt unattended updates.
|
||||
echo 'APT::Periodic::Enable "0";' >> /etc/apt/apt.conf.d/10periodic
|
@ -1,4 +0,0 @@
|
||||
sudo apt-get install -y software-properties-common
|
||||
sudo apt-add-repository -y ppa:ansible/ansible
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ansible
|
14
vm/scripts/restart_supervisor.sh
Normal file
14
vm/scripts/restart_supervisor.sh
Normal file
@ -0,0 +1,14 @@
|
||||
#! /bin/bash
|
||||
|
||||
|
||||
# Write out current crontab
|
||||
crontab -l > current_cron
|
||||
|
||||
# Echo new cron into cron file
|
||||
echo "@reboot sleep 20 && systemctl restart supervisor" >> current_cron
|
||||
|
||||
# Install new cron file
|
||||
crontab current_cron
|
||||
|
||||
# Delete the temporary cron file
|
||||
rm current_cron
|
18
vm/scripts/set_message_develop.sh
Normal file
18
vm/scripts/set_message_develop.sh
Normal file
@ -0,0 +1,18 @@
|
||||
#! /bin/bash
|
||||
|
||||
message="
|
||||
ERPNext Evaluation VM (built on `date +\"%B %d, %Y\"`)
|
||||
|
||||
Please access ERPNext by going to http://localhost:8000 on the host system.
|
||||
The username is \"Administrator\" and password is \"admin\"
|
||||
|
||||
Do consider donating at https://frappe.io/buy
|
||||
|
||||
To update, login as
|
||||
username: frappe
|
||||
password: frappe
|
||||
cd frappe-bench
|
||||
bench update
|
||||
"
|
||||
echo "$message" | sudo tee -a /etc/issue
|
||||
echo "$message" | sudo tee -a /etc/motd
|
@ -1,9 +1,10 @@
|
||||
#! /bin/bash
|
||||
|
||||
message="
|
||||
ERPNext evaluation VM (built on `date +\"%B %d, %Y\"`)
|
||||
ERPNext VM (built on `date +\"%B %d, %Y\"`)
|
||||
|
||||
Please access ERPNext by going to http://localhost:8080 on the host system.
|
||||
The username is \"Administrator\" and password is \"admin\"
|
||||
|
||||
Do consider donating at https://frappe.io/buy
|
||||
|
@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
sudo apt-get clean
|
||||
sudo dd if=/dev/zero of=/EMPTY bs=1M
|
||||
sudo rm -f /EMPTY
|
98
vm/vm-develop.json
Normal file
98
vm/vm-develop.json
Normal file
@ -0,0 +1,98 @@
|
||||
{
|
||||
"builders": [{
|
||||
"vm_name": "ERPNext-Develop-{{isotime \"20060102150405\"}}",
|
||||
"output_directory": "Developer Builds",
|
||||
"type": "virtualbox-iso",
|
||||
"boot_command": [
|
||||
"<enter><wait><f6><esc><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"/install/vmlinuz<wait>",
|
||||
" auto<wait>",
|
||||
" console-setup/ask_detect=false<wait>",
|
||||
" console-setup/layoutcode=us<wait>",
|
||||
" console-setup/modelcode=pc105<wait>",
|
||||
" debconf/frontend=noninteractive<wait>",
|
||||
" debian-installer=en_US<wait>",
|
||||
" fb=false<wait>",
|
||||
" initrd=/install/initrd.gz<wait>",
|
||||
" kbd-chooser/method=us<wait>",
|
||||
" keyboard-configuration/layout=USA<wait>",
|
||||
" keyboard-configuration/variant=USA<wait>",
|
||||
" locale=en_US<wait>",
|
||||
" netcfg/get_domain=vm<wait>",
|
||||
" netcfg/get_hostname=ubuntu<wait>",
|
||||
" grub-installer/bootdev=/dev/sda<wait>",
|
||||
" noapic<wait>",
|
||||
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg",
|
||||
" -- <wait>",
|
||||
"<enter><wait>"
|
||||
],
|
||||
"boot_wait": "10s",
|
||||
"format": "ova",
|
||||
"guest_os_type": "Ubuntu_64",
|
||||
"headless": true,
|
||||
"iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04.4-server-amd64.iso",
|
||||
"iso_checksum": "6a7f31eb125a0b2908cf2333d7777c82",
|
||||
"iso_checksum_type": "md5",
|
||||
"ssh_username": "frappe",
|
||||
"ssh_password": "frappe",
|
||||
"ssh_port": 22,
|
||||
"ssh_wait_timeout": "10000s",
|
||||
"http_directory": "http",
|
||||
"guest_additions_mode": "disable",
|
||||
"virtualbox_version_file": ".vbox_version",
|
||||
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
|
||||
"export_opts": [
|
||||
"--vsys", "0",
|
||||
"--product", "ERPNext",
|
||||
"--producturl", "https://erpnext.com",
|
||||
"--vendor", "Frappe Techonologies",
|
||||
"--vendorurl", "https://frappe.io",
|
||||
"--description", "ERPNext Evaluation VM"
|
||||
],
|
||||
"shutdown_command": "echo 'frappe'|sudo -S shutdown -P now",
|
||||
"vboxmanage": [
|
||||
[ "modifyvm", "{{.Name}}", "--memory", "1024" ],
|
||||
[ "modifyvm", "{{.Name}}", "--cpus", "1" ],
|
||||
[ "modifyvm", "{{.Name}}", "--audio", "none" ],
|
||||
[ "modifyvm", "{{.Name}}", "--natpf1", "vm_ssh,tcp,,3022,,22" ],
|
||||
[ "modifyvm", "{{.Name}}", "--natpf1", "vm_http,tcp,,8080,,80" ],
|
||||
[ "modifyvm", "{{.Name}}", "--natpf1", "vm_http2,tcp,,8000,,8000" ]
|
||||
]
|
||||
}],
|
||||
"provisioners": [{
|
||||
"type": "shell",
|
||||
"execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
|
||||
"script": "scripts/debian_family/install_ansible.sh"
|
||||
}, {
|
||||
"type": "shell",
|
||||
"execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
|
||||
"script": "scripts/debian_family/setup.sh"
|
||||
}, {
|
||||
"type": "shell",
|
||||
"execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
|
||||
"script": "scripts/debian_family/install_erpnext_develop.sh"
|
||||
}, {
|
||||
"type": "shell",
|
||||
"execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
|
||||
"script": "scripts/debian_family/cleanup.sh"
|
||||
}, {
|
||||
"type": "shell",
|
||||
"script": "scripts/set_message_develop.sh"
|
||||
}, {
|
||||
"type": "shell",
|
||||
"execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
|
||||
"script": "scripts/restart_supervisor.sh"
|
||||
}],
|
||||
"post-processors": [{
|
||||
"type": "checksum",
|
||||
"checksum_types": ["md5"]
|
||||
}, {
|
||||
"type": "vagrant",
|
||||
"keep_input_artifact": true,
|
||||
"output": "Developer Builds/ERPNext-Vagrant-Develop-{{isotime \"20060102150405\"}}.box",
|
||||
"vagrantfile_template": "Vagrantfile"
|
||||
}]
|
||||
}
|
92
vm/vm-production.json
Normal file
92
vm/vm-production.json
Normal file
@ -0,0 +1,92 @@
|
||||
{
|
||||
"builders": [{
|
||||
"vm_name": "ERPNext-Production-{{isotime \"20060102150405\"}}",
|
||||
"output_directory": "Production Builds",
|
||||
"type": "virtualbox-iso",
|
||||
"boot_command": [
|
||||
"<enter><wait><f6><esc><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"/install/vmlinuz<wait>",
|
||||
" auto<wait>",
|
||||
" console-setup/ask_detect=false<wait>",
|
||||
" console-setup/layoutcode=us<wait>",
|
||||
" console-setup/modelcode=pc105<wait>",
|
||||
" debconf/frontend=noninteractive<wait>",
|
||||
" debian-installer=en_US<wait>",
|
||||
" fb=false<wait>",
|
||||
" initrd=/install/initrd.gz<wait>",
|
||||
" kbd-chooser/method=us<wait>",
|
||||
" keyboard-configuration/layout=USA<wait>",
|
||||
" keyboard-configuration/variant=USA<wait>",
|
||||
" locale=en_US<wait>",
|
||||
" netcfg/get_domain=vm<wait>",
|
||||
" netcfg/get_hostname=ubuntu<wait>",
|
||||
" grub-installer/bootdev=/dev/sda<wait>",
|
||||
" noapic<wait>",
|
||||
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg",
|
||||
" -- <wait>",
|
||||
"<enter><wait>"
|
||||
],
|
||||
"boot_wait": "10s",
|
||||
"format": "ova",
|
||||
"guest_os_type": "Ubuntu_64",
|
||||
"headless": true,
|
||||
"iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04.4-server-amd64.iso",
|
||||
"iso_checksum": "6a7f31eb125a0b2908cf2333d7777c82",
|
||||
"iso_checksum_type": "md5",
|
||||
"ssh_username": "frappe",
|
||||
"ssh_password": "frappe",
|
||||
"ssh_port": 22,
|
||||
"ssh_wait_timeout": "10000s",
|
||||
"http_directory": "http",
|
||||
"guest_additions_mode": "disable",
|
||||
"virtualbox_version_file": ".vbox_version",
|
||||
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
|
||||
"export_opts": [
|
||||
"--vsys", "0",
|
||||
"--product", "ERPNext",
|
||||
"--producturl", "https://erpnext.com",
|
||||
"--vendor", "Frappe Techonologies",
|
||||
"--vendorurl", "https://frappe.io",
|
||||
"--description", "ERPNext Evaluation VM"
|
||||
],
|
||||
"shutdown_command": "echo 'frappe'|sudo -S shutdown -P now",
|
||||
"vboxmanage": [
|
||||
[ "modifyvm", "{{.Name}}", "--memory", "1024" ],
|
||||
[ "modifyvm", "{{.Name}}", "--cpus", "1" ],
|
||||
[ "modifyvm", "{{.Name}}", "--audio", "none" ],
|
||||
[ "modifyvm", "{{.Name}}", "--natpf1", "vm_ssh,tcp,,3022,,22" ],
|
||||
[ "modifyvm", "{{.Name}}", "--natpf1", "vm_http,tcp,,8080,,80" ]
|
||||
]
|
||||
}],
|
||||
"provisioners": [{
|
||||
"type": "shell",
|
||||
"execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
|
||||
"script": "scripts/debian_family/install_ansible.sh"
|
||||
}, {
|
||||
"type": "shell",
|
||||
"execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
|
||||
"script": "scripts/debian_family/setup.sh"
|
||||
}, {
|
||||
"type": "shell",
|
||||
"execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
|
||||
"script": "scripts/debian_family/install_erpnext_production.sh"
|
||||
}, {
|
||||
"type": "shell",
|
||||
"execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
|
||||
"script": "scripts/debian_family/cleanup.sh"
|
||||
}, {
|
||||
"type": "shell",
|
||||
"script": "scripts/set_message_production.sh"
|
||||
}, {
|
||||
"type": "shell",
|
||||
"execute_command": "echo 'frappe' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
|
||||
"script": "scripts/restart_supervisor.sh"
|
||||
}],
|
||||
"post-processors": [{
|
||||
"type": "checksum",
|
||||
"checksum_types": ["md5"]
|
||||
}]
|
||||
}
|
42
vm/vm.json
42
vm/vm.json
@ -1,42 +0,0 @@
|
||||
{
|
||||
"builders":[{
|
||||
"vm_name": "ERPNext-{{isotime \"020106\"}}",
|
||||
"type": "virtualbox-ovf",
|
||||
"format": "ova",
|
||||
"headless": true,
|
||||
"source_path": "base.ova",
|
||||
"ssh_username": "frappe",
|
||||
"ssh_password": "frappe",
|
||||
"guest_additions_mode": "disable",
|
||||
"ssh_port": 22,
|
||||
"ssh_wait_timeout": "300s",
|
||||
"export_opts": ["--vsys", "0", "--product", "ERPNext", "--producturl", "https://erpnext.com", "--vendor", "Frappe Techonologies", "--vendorurl", "https://frappe.io", "--description", "ERPNext Evaluation VM"],
|
||||
"shutdown_command": " echo 'packer' | sudo shutdown -P -h now",
|
||||
"vboxmanage": [
|
||||
[ "modifyvm", "{{.Name}}", "--memory", "512" ],
|
||||
[ "modifyvm", "{{.Name}}", "--audio", "none" ],
|
||||
[ "modifyvm", "{{.Name}}", "--cpus", "1" ],
|
||||
[ "modifyvm", "{{.Name}}", "--natpf1", "vm_ssh,tcp,,3022,,22" ],
|
||||
[ "modifyvm", "{{.Name}}", "--natpf1", "vm_http,tcp,,8080,,80" ]
|
||||
]
|
||||
}
|
||||
],
|
||||
"provisioners": [{
|
||||
"type": "shell",
|
||||
"script": "scripts/install_ansible.sh"
|
||||
}, {
|
||||
"type": "ansible-local",
|
||||
"playbook_file": "ansible/vm.yml",
|
||||
"playbook_dir": "ansible",
|
||||
"group_vars": "ansible/vm_vars",
|
||||
"role_paths": [
|
||||
"ansible/roles"
|
||||
]
|
||||
}, {
|
||||
"type": "shell",
|
||||
"script": "scripts/set_message.sh"
|
||||
}, {
|
||||
"type": "shell",
|
||||
"script": "scripts/zerofree.sh"
|
||||
}]
|
||||
}
|
Loading…
Reference in New Issue
Block a user