2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-23 04:29:02 +00:00

VM build fixes

- added bench command to install packer 1.2.1
This commit is contained in:
Ameya Shenoy 2018-03-04 02:29:37 +05:30
parent fe858bfa36
commit 30b12a6dd4
No known key found for this signature in database
GPG Key ID: 735490161CD5C91E
5 changed files with 66 additions and 3 deletions

View File

@ -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}
@ -48,7 +48,11 @@ def install_nginx(user=None):
@click.command('virtualbox')
def install_virtualbox():
run_playbook('roles/virtualbox/tasks/main.yml', extra_vars=extra_vars)
run_playbook('roles/virtualbox/tasks/main.yml')
@click.command('packer')
def install_packer():
run_playbook('roles/packer/tasks/main.yml')
@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.")
@ -67,3 +71,4 @@ install.add_command(install_supervisor)
install.add_command(install_nginx)
install.add_command(install_failtoban)
install.add_command(install_virtualbox)
install.add_command(install_packer)

View File

@ -0,0 +1,6 @@
---
- name: Install unzip
apt: pkg={{ item }} update_cache=yes state=present
with_items:
- unzip
...

View File

@ -0,0 +1,45 @@
---
- name: Check if packer already exists
stat:
path: ~/.local/bin/packer
register: packer
- name: Check if packer version is 1.2.1
command: ~/.local/bin/packer --version
register: packer_version
when: packer.stat.exists
- name: Create the ~/.local/bin, if it doesnt exist already
file:
path: ~/.local/bin/
state: directory
when: packer.stat.exists == False
- 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: ~/.local/bin/packer
when: (packer.stat.exists) and (packer_version | version_compare('1.2.1', '<'))
- name: Download packer zip file
command: wget https://releases.hashicorp.com/packer/1.2.1/packer_1.2.1_linux_amd64.zip
chdir: ~/.local/bin/
when: (packer.stat.exists == False) or (packer_version | version_compare('1.2.1', '<'))
- name: Unzip the packer binary in ~/.local/bin
chdir: ~/.local/bin/
command: 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: ~/.local/bin/packer_1.2.1_linux_amd64.zip
when: (packer.stat.exists == False) or (packer_version | version_compare('1.2.1', '<'))
...

View File

@ -0,0 +1,7 @@
---
- name: Install unzip
yum: name={{ item }} enablerepo=mariadb state=present
with_items:
- unzip
...

View File

@ -23,7 +23,7 @@ def install_virtualbox():
check_output(['bench', 'install', 'virtualbox'])
def install_packer():
pass
check_output(['bench', 'install', 'packer'])
def build_vm():
check_output("./packer build vm.json", shell=True)