2
0
mirror of https://github.com/frappe/bench.git synced 2025-02-07 13:18:24 +00:00

minor fixes

This commit is contained in:
Ameya Shenoy 2018-03-04 03:01:41 +05:30
parent 30b12a6dd4
commit 9e28e4cf5b
No known key found for this signature in database
GPG Key ID: 735490161CD5C91E
11 changed files with 51 additions and 37 deletions

View File

@ -48,11 +48,11 @@ def install_nginx(user=None):
@click.command('virtualbox') @click.command('virtualbox')
def install_virtualbox(): def install_virtualbox():
run_playbook('roles/virtualbox/tasks/main.yml') run_playbook('vm_build.yml', tag='virtualbox')
@click.command('packer') @click.command('packer')
def install_packer(): def install_packer():
run_playbook('roles/packer/tasks/main.yml') run_playbook('vm_build.yml', tag='packer')
@click.command('fail2ban') @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('--maxretry', default=6, help="Number of matches (i.e. value of the counter) which triggers ban action on the IP.")

View File

@ -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 - include_tasks: debian_family.yml
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'

View File

@ -1,20 +1,14 @@
--- ---
- name: Check if packer already exists - name: Check if packer already exists
stat: stat:
path: ~/.local/bin/packer path: /opt/packer
register: packer register: packer
- name: Check if packer version is 1.2.1 - name: Check if packer version is 1.2.1
command: ~/.local/bin/packer --version command: /opt/packer --version
register: packer_version register: packer_version
when: packer.stat.exists 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 - include_tasks: debian_family.yml
when: ansible_os_family == 'Debian' and packer.stat.exists == False when: ansible_os_family == 'Debian' and packer.stat.exists == False
@ -24,22 +18,20 @@
- name: Delete packer if < 1.2.1 - name: Delete packer if < 1.2.1
file: file:
state: absent state: absent
path: ~/.local/bin/packer path: /opt/packer
when: (packer.stat.exists) and (packer_version | version_compare('1.2.1', '<')) when: (packer.stat.exists) and (packer_version | version_compare('1.2.1', '<'))
- name: Download packer zip file - name: Download packer zip file
command: wget https://releases.hashicorp.com/packer/1.2.1/packer_1.2.1_linux_amd64.zip command: chdir=/opt/ 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', '<')) when: (packer.stat.exists == False) or (packer_version | version_compare('1.2.1', '<'))
- name: Unzip the packer binary in ~/.local/bin - name: Unzip the packer binary in /opt
chdir: ~/.local/bin/ command: chdir=/opt/ unzip packer_1.2.1_linux_amd64.zip
command: unzip packer_1.2.1_linux_amd64.zip
when: (packer.stat.exists == False) or (packer_version | version_compare('1.2.1', '<')) when: (packer.stat.exists == False) or (packer_version | version_compare('1.2.1', '<'))
- name: Remove the downloaded packer zip file - name: Remove the downloaded packer zip file
file: file:
state: absent state: absent
path: ~/.local/bin/packer_1.2.1_linux_amd64.zip path: /opt/packer_1.2.1_linux_amd64.zip
when: (packer.stat.exists == False) or (packer_version | version_compare('1.2.1', '<')) when: (packer.stat.exists == False) or (packer_version | version_compare('1.2.1', '<'))
... ...

View File

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

View File

@ -0,0 +1,3 @@
---
virtualbox_version: 5.2
...

View 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

View File

@ -1,8 +1,13 @@
--- ---
- name: Install dependencies
apt: pkg={{ item }} state=present
with_items:
- apt-transport-https
- ca-certificates
- name: Add VirtualBox to sources.list - name: Add VirtualBox to sources.list
apt_repository: apt_repository:
repo: deb https://download.virtualbox.org/virtualbox/debian {{ ansible_distribution_release }}contrib repo: deb https://download.virtualbox.org/virtualbox/debian {{ ansible_distribution_release }} contrib
state: present state: present
- name: Add apt signing key for VirtualBox for Debian >= 8 and Ubuntu >= 16 - name: Add apt signing key for VirtualBox for Debian >= 8 and Ubuntu >= 16
@ -15,11 +20,10 @@
apt_key: apt_key:
url: https://www.virtualbox.org/download/oracle_vbox.asc url: https://www.virtualbox.org/download/oracle_vbox.asc
state: present state: present
when: (ansible_distribution == "Debian" and ansible_distribution_major_version >= "8") or (ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "16") when: (ansible_distribution == "Debian" and ansible_distribution_major_version < "8") or (ansible_distribution == "Ubuntu" and ansible_distribution_major_version < "16")
- name: Install VirtualBox - name: Install VirtualBox
apt: pkg={{ item }} update_cache=yes state=present apt: pkg={{ item }} update_cache=yes state=present
with_items: with_items:
- virtualbox-5.2 - virtualbox-{{ virtualbox_version }}
... ...

View File

@ -1,9 +1,7 @@
--- ---
- include_tasks: debian_family.yml - include_tasks: debian_family.yml
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'
- include_tasks: redhat_family.yml - include_tasks: redhat_family.yml
when: ansible_os_family == "RedHat" when: ansible_os_family == "RedHat"
... ...

View File

@ -1,16 +1,17 @@
--- ---
- name: Install the 'Development tools' package group
yum:
name: "@Development tools"
state: present
- name: Add VirtualBox Repository - name: Install dependencies
yum_repository: yum: name={{ item }} state=present
name: Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox with_items:
description: Official VirtualBox Yum Repo - kernel-devel
baseurl: http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch - deltarpm
gpgkey: https://www.virtualbox.org/download/oracle_vbox.asc
gpgcheck: yes - copy: src=virtualbox_centos.repo dest=/etc/yum.repos.d/virtualbox.repo owner=root group=root mode=0644 force=no
- name: Install VirtualBox - name: Install VirtualBox
yum: name={{ item }} enablerepo=mariadb state=present command: yum install -y VirtualBox-{{ virtualbox_version }}
with_items:
- VirtualBox-5.2
... ...

9
playbooks/vm_build.yml Normal file
View File

@ -0,0 +1,9 @@
---
- name: Install Packer
hosts: localhost
become: yes
become_user: root
roles:
- { role: virtualbox, tags: "virtualbox" }
- { role: packer, tags: "packer" }
...

View File

@ -26,7 +26,7 @@ def install_packer():
check_output(['bench', 'install', 'packer']) check_output(['bench', 'install', 'packer'])
def build_vm(): def build_vm():
check_output("./packer build vm.json", shell=True) check_output("/opt/packer build vm.json", shell=True)
def move_to_public(): def move_to_public():
src = get_filepath() src = get_filepath()