mirror of
https://github.com/frappe/bench.git
synced 2025-01-09 08:30:39 +00:00
Fixes for VM builds
- removed the packer binary - added a bench command to install virtualbox
This commit is contained in:
parent
16603ec8c9
commit
fe858bfa36
@ -46,6 +46,10 @@ def install_nginx(user=None):
|
||||
if user:
|
||||
setup_sudoers(user)
|
||||
|
||||
@click.command('virtualbox')
|
||||
def install_virtualbox():
|
||||
run_playbook('roles/virtualbox/tasks/main.yml', extra_vars=extra_vars)
|
||||
|
||||
@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.")
|
||||
@ -62,3 +66,4 @@ install.add_command(install_psutil)
|
||||
install.add_command(install_supervisor)
|
||||
install.add_command(install_nginx)
|
||||
install.add_command(install_failtoban)
|
||||
install.add_command(install_virtualbox)
|
||||
|
25
playbooks/roles/virtualbox/tasks/debian_family.yml
Normal file
25
playbooks/roles/virtualbox/tasks/debian_family.yml
Normal file
@ -0,0 +1,25 @@
|
||||
---
|
||||
|
||||
- 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-5.2
|
||||
|
||||
...
|
9
playbooks/roles/virtualbox/tasks/main.yml
Normal file
9
playbooks/roles/virtualbox/tasks/main.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
- include_tasks: debian_family.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- include_tasks: redhat_family.yml
|
||||
when: ansible_os_family == "RedHat"
|
||||
|
||||
...
|
16
playbooks/roles/virtualbox/tasks/redhat_family.yml
Normal file
16
playbooks/roles/virtualbox/tasks/redhat_family.yml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
|
||||
- name: Add VirtualBox Repository
|
||||
yum_repository:
|
||||
name: Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox
|
||||
description: Official VirtualBox Yum Repo
|
||||
baseurl: http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch
|
||||
gpgkey: https://www.virtualbox.org/download/oracle_vbox.asc
|
||||
gpgcheck: yes
|
||||
|
||||
- name: Install VirtualBox
|
||||
yum: name={{ item }} enablerepo=mariadb state=present
|
||||
with_items:
|
||||
- VirtualBox-5.2
|
||||
|
||||
...
|
16
vm/build.py
16
vm/build.py
@ -1,22 +1,32 @@
|
||||
"""
|
||||
Builds a vm and puts it in ~/public with a latest.json that has its filename and md5sum
|
||||
"""
|
||||
|
||||
# imports - standard imports
|
||||
import os
|
||||
import subprocess
|
||||
import json
|
||||
import stat
|
||||
from subprocess import check_output
|
||||
|
||||
OUTPUT_DIR = 'output-virtualbox-ovf'
|
||||
PUBLIC_DIR = os.path.join(os.path.expanduser('~'), 'public')
|
||||
|
||||
def main():
|
||||
install_virtualbox()
|
||||
install_packer()
|
||||
build_vm()
|
||||
update_latest()
|
||||
move_to_public()
|
||||
cleanup()
|
||||
|
||||
def install_virtualbox():
|
||||
check_output(['bench', 'install', 'virtualbox'])
|
||||
|
||||
def install_packer():
|
||||
pass
|
||||
|
||||
def build_vm():
|
||||
subprocess.check_call("./packer build vm.json", shell=True)
|
||||
check_output("./packer build vm.json", shell=True)
|
||||
|
||||
def move_to_public():
|
||||
src = get_filepath()
|
||||
@ -30,7 +40,7 @@ def update_latest():
|
||||
json.dump(get_latest(), f)
|
||||
|
||||
def get_latest():
|
||||
md5 = subprocess.check_output("md5sum {}".format(get_filepath()), shell=True).split()[0]
|
||||
md5 = check_output("md5sum {}".format(get_filepath()), shell=True).split()[0]
|
||||
return {
|
||||
"filename": get_filename(),
|
||||
"md5": md5
|
||||
|
Loading…
Reference in New Issue
Block a user