Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.

Commit

Permalink
Merge pull request #19 from ksatchit/master
Browse files Browse the repository at this point in the history
Placeholder for roles & playbooks to address OpenEBS issue #463
  • Loading branch information
kmova committed Oct 16, 2017
2 parents 19e7ad6 + cede7f2 commit 61a4202
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 29 deletions.
27 changes: 9 additions & 18 deletions ansible/ci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
---
- hosts: localhost
- include: pre-requisites.yml

roles:
- inventory

- hosts: openebs-mayamaster
- include: setup-kubernetes.yml

roles:
- master
- {role: vagrant, when: is_vagrant_vm | bool}
- include: setup-openebs.yml

- hosts: openebs-mayahosts
- include: load-images.yml

roles:
- hosts
- {role: vagrant, when: is_vagrant_vm | bool}
- include: run-dedicated-tests.yml
when: deployment_mode == "dedicated"

- hosts: localhost
- include: run-hyperconverged-tests.yml
when: deployment_mode == "hyperconverged"

roles:
- {role: localhost, when: run_demo | bool}
- {role: volume, when: run_demo | bool}
- {role: fio, when: run_demo | bool}
- {role: cleanup, when: run_demo | bool}


102 changes: 91 additions & 11 deletions ansible/inventory/group_vars/all.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,105 @@
---
#Option to run the sample demo of OpenEBS
#Accepted Entries(true, false): default:true

run_demo: true
#########################################
# Kubernetes Deployment Specification #
#########################################

#Option specifically for vagrant VMs.
#Accepted Entries(true, false): default:false
#Kubernetes Version to be used for deployment
#Accepted Entries (Valid Kubernetes Version): default:1.6.3
#Accepted Entries (Valid Weave Version): default:1.9.4

k8s_version: 1.7.5
k8s_version: 2.0.4

is_vagrant_vm: false

#User-defined size for the volume that openebs creates:
#list of kubernetes versions released.
#do not tamper the list unless you know
#what you are doing...

k8s_version_list:
- 1.6.2
- 1.6.3
- 1.6.4
- 1.6.5
- 1.6.6
- 1.7.0
- 1.7.2
- 1.7.4
- 1.7.5

weave_version_list:
- 1.9.4
- 2.0.4

#########################################
# OpenEBS Deployment Specifications #
#########################################

#User-defined size for the volume that openebs creates
#Accepted Entries(Valid Volume Sizes): default:5G

openebs_vol_size: 5G

#Available CIDR for allocating IP Addresses for containers
#Accepted Entries (Valid CIDR): default:172.28.128.1/24

cn_network_cidr: 172.28.128.1/24
cn_network_cidr: 20.10.49.110/25

#Network interface for CIDR.
#Network interface for CIDR
#Accepted Entries (Valid Network Interface): default:enp0s8

cn_interface: enp0s8
cn_interface: ens160

#Mode of openEBS deployment
#Accepted Entries (dedicated, hyperconverged): default:dedicated

deployment_mode: hyperconverged

#Option specifically for vagrant VMs
#Accepted Entries(true, false): default:false

is_vagrant_vm: true

#########################################
# Ansible Runtime Specifications #
#########################################

#Option to run the sample demo of OpenEBS
#Accepted Entries(true, false): default:true

run_demo: true

#Option to setup Ansible Runtime Analysis playbook recorder
#Accepted Entries(true, false): default:true

ara_setup: true

#Option to enable slack notifications to specified channel
#Accepted Entries(true, false): default:true

slack_notify: true

#########################################
# OpenEBS Test Specifications #
#########################################

#Option to run cleanup functions in tests
#Accepted Entries(true, false): default:true

clean: true

#Name of tarfile containing test images

tarfile: test_images.tar

#########################################
# OpenEBS CI Specifications #
#########################################

#Option to select type of CI build
#Accepted Entries(quick, normal): default:normal
#quick build uses preconfigured VMs,
#normal builds upon vanilla VMs

build_type: normal


15 changes: 15 additions & 0 deletions ansible/load-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- hosts: kubernetes-kubeminions

tasks:
- name: Check for presence of tarfile
stat:
path: "{{ playbook_dir }}/roles/load-test-images/files/{{ tarfile }}"
register: tar
delegate_to: 127.0.0.1

- name: Execute load-test-images role if tarfile exists
include_role:
name: load-test-images
when: tar.stat.exists is defined and tar.stat.exists

6 changes: 6 additions & 0 deletions ansible/roles/load-test-images/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

tarfile: test_images.tar

# Applies to non-vagrant VMs/baremetal
tarfile_path: "{{ ansible_env.HOME}}"
28 changes: 28 additions & 0 deletions ansible/roles/load-test-images/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
- block:

- name: Load test images from Archive
command: docker load --input "{{ tarfile }}"
args:
chdir: "/vagrant/roles/load-test-images/files"
become: true

when: is_vagrant_vm

- block:

- name: Copy test image tarfile to kubernetes hosts
copy:
src: "{{ tarfile }}"
dest: "{{ tarfile_path }}"
become: true
when: is_vagrant_vm

- name: Load test images from Archive
command: docker load --input "{{ tarfile }}"
args:
chdir: "{{ tarfile_path }}"
become: true

when: not is_vagrant_vm

28 changes: 28 additions & 0 deletions ansible/roles/setup-test-images/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
deb_local_packages:
- docker.io

pip_local_packages:
- 'docker-py==1.9.0'

test_images:

# I/O-tool-specific images

#- openebs/tests-fio
#- openebs/tests-vdbench

# App-specific images

- percona
- satyamz/docker-jupyter:v0.4
- crunchydata/crunchy-postgres:centos7-9.6-1.4.0
#- openebs/tests-mysql-master
#- openebs/tests-mysql-slave

# App-load-generator images

- openebs/tests-mysql-client
#- openebs/tests-tpcc-client

tarfile: test_images.tar
68 changes: 68 additions & 0 deletions ansible/roles/setup-test-images/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
- name: Install APT Packages
apt:
name: "{{item}}"
state: present
with_items: "{{deb_local_packages}}"
become: true
delegate_to: 127.0.0.1

- name: Install PIP Packages
pip:
name: "{{ item }}"
state: present
with_items: "{{ pip_local_packages }}"
delegate_to: 127.0.0.1
become: true

- name: Fetch test images from dockerhub
docker_image:
name: "{{item}}"
state: present
pull: true
force: yes
register: result
until: "'Pulled image' and item in result.actions[0]"
delay: 60
retries: 3
with_items: "{{ test_images }}"
become: true

- name: Print test image names
shell: printf "{{ item }}\n" >> imagelist.tmp
with_items: "{{ test_images }}"

- name: Create files directory in load-test-images role
file:
path: "{{ playbook_dir }}/roles/load-test-images/files"
state: directory
mode: 0755

- name: TAR the test images
shell: docker save $(cat imagelist.tmp) -o {{playbook_dir}}/roles/load-test-images/files/{{ tarfile }}
become: true

- name: Remove the .tmp file created to hold image list
file: path="{{playbook_dir}}/imagelist.tmp" state=absent

- name: Get current user details
command: whoami
register: user

- name: Change permissions of tarfile
file:
path: "{{playbook_dir}}/roles/load-test-images/files"
owner: "{{ user.stdout }}"
group: "{{ user.stdout }}"
recurse: true
become: true

- name: Remove test images from localhost
docker_image:
name: "{{ item }}"
state: absent
with_items: "{{ test_images }}"
become: true



7 changes: 7 additions & 0 deletions ansible/setup-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- hosts: localhost
roles:
- {role: setup-test-images}



0 comments on commit 61a4202

Please sign in to comment.