diff --git a/.gitignore b/.gitignore index b7642fcb..d73e4456 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,138 @@ -*.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 -*.iso \ No newline at end of file + +# 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/ + +## For built virtualmachines +*.ova +*.iso + +## For built boxes +*.box + diff --git a/vm/Readme.md b/vm/Readme.md index 9f0c6b01..7b4c3152 100644 --- a/vm/Readme.md +++ b/vm/Readme.md @@ -1,17 +1,42 @@ ### ERPNext VM Builder + #### Steps to build a VM Image -* `/opt/packer build vm.json` builds a new VM +* `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/debian_family/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 diff --git a/vm/build.py b/vm/build.py index 96a02e2b..b4b29c27 100644 --- a/vm/build.py +++ b/vm/build.py @@ -10,7 +10,7 @@ import errno from subprocess import check_output OUTPUT_DIR = 'output-virtualbox-ovf' -PUBLIC_DIR = os.path.join(os.path.expanduser('~'), 'public') +PUBLIC_DIR = os.path.join(os.path.expanduser('~'), 'public') def main(): install_virtualbox() diff --git a/vm/vm-develop.json b/vm/vm-develop.json index 23823420..09eab9de 100644 --- a/vm/vm-develop.json +++ b/vm/vm-develop.json @@ -1,7 +1,7 @@ { "builders": [{ "vm_name": "ERPNext-Develop-{{isotime \"20060102150405\"}}", - "output_directory": "ERPNext-Develop-Images", + "output_directory": "Builds", "type": "virtualbox-iso", "boot_command": [ "", @@ -87,7 +87,7 @@ }, { "type": "vagrant", "keep_input_artifact": true, - "output": "Vagrant_builds/ERPNext-Vagrant-Develop.box", + "output": "Builds//ERPNext-Vagrant-Develop-{{isotime \"20060102150405\"}}.box", "vagrantfile_template": "Vagrantfile" }] } diff --git a/vm/vm-production.json b/vm/vm-production.json index a0d14333..a45d8102 100644 --- a/vm/vm-production.json +++ b/vm/vm-production.json @@ -1,7 +1,7 @@ { "builders": [{ "vm_name": "ERPNext-Production-{{isotime \"20060102150405\"}}", - "output_directory": "ERPNext-Production-Images", + "output_directory": "Builds", "type": "virtualbox-iso", "boot_command": [ "", @@ -87,7 +87,7 @@ }, { "type": "vagrant", "keep_input_artifact": true, - "output": "Vagrant_builds/ERPNext-Vagrant-Production.box", + "output": "Builds/ERPNext-Vagrant-Production-{{isotime \"20060102150405\"}}.box", "vagrantfile_template": "Vagrantfile" }] }