Lightweight provisioner to speed up CI workflow

 

Bhavik Bhavsar

  1. ARE totally new to the concept of ci?

  2. work on some kind of ci workflow?

  3. use some types of provisioner or hypervisor for ci workflow?

How Many Of You -

"Server provisioning is set of actions to prepare a server with appropriate systems, data and Software and make it ready for network operation." - Wikipedia,  Server Provisioning.

 

Great, But what is provisioning?

Challenges

 

  • different Target Environment for testing and development

  • different Arcs & platforms x86_64, i386,  etc

  • develop, test & deploy on DIFFERENT cloudS

  • container as well as VM workloads

MANAGING  TOPOLOGIES IS

  • COMPLICATED

  • SENSITIVE

  • DEMANDING

COMPLEX TOPOLOGY

SO How DO we Do it?

LINCHPIN

 

Linchpin is a simple and flexible hybrid cloud orchestration tool.

 

Its intended purpose is managing cloud resources across multiple infrastructures.

 

These resources can be provisioned, decommissioned, and configured all using declarative data and a simple command-line interface.

Module

ANSIBLE

LINCHPIN

PinFile

( TOPOLOGY & LAYOUT FILE )

LINCHPIN is ansible?

 

 

Linchpin backend is Ansible & PYTHON but it takes care of the nitty gritty Details so one will manAge cloud resources easily.

 

 

SUPPORTED PROVIDERS?

LinchPin has many default providers.

SO How TO DO it in structured way?

One

DEFINE

TOPOLOGY

TWO

SIMPLE WAY TO

Setup & Destroy topology

example-topology.yml

resource_groups:
-   
    credentials:
        filename: clouds.yaml
        profile: devstack
    resource_group_name: linchpin
    resource_group_type: openstack
    resource_definitions:
    -
        name: server
        count: 1
        fip_pool: 10.8.240.0
        flavor: m1.small
        image: centos-7.4-server-x86_64-updated
        keypair: ci-jenkins
        networks:
          - ci-jenkins
        type: os_server
    -
        name: client
        count: 1
        fip_pool: 10.8.240.0
        flavor: m1.small
        image: centos-7.2-server-x86_64-updated
        keypair: ci-jenkins
        networks:
          - ci-jenkins
        type: os_server
        
topology_name: openstack_topo
---
inventory_layout:
  vars:
    hostname: __IP__
  hosts:
    server:
      count: 1
      host_groups:
        - server
    client:
      count: 1
      host_groups:
        - client

example-layout.yml

clouds:
  devstack:
    auth:
      username: "ci-jenkins"
      password: "<password>"
      project_name: "ci-jenkins"
      auth_url: "https://local-openstack:13000/v2.0"

cloud.yml

[server]
10.8.244.111 hostname=10.8.244.111 

[client]
10.8.244.90 hostname=10.8.244.90 

[all]
10.8.244.111 hostname=10.8.244.111 
10.8.244.90 hostname=10.8.244.90 

 openstack_topo.inventory

CI WORKFLOW

Request VM

Environment

setup

Build and Deploy

app

Test

Ansible-playbook

- openstack

- libvirt KVM

 

linchpin

pytest

pytest-ansible

Ahh!! but what is Pytest-ansible

@pytest.mark.ansible(host_pattern="server")
def test_master_cmd(ansible_module):
    
    #using expect ansible module 
    expect = ansible_module.expect(command="/bin/passwd",responses={"New password:":"redhat", "Retype new password:":"redhat"})

    #running command on master
    output = ansible_module.command("hostname")
    print output
    for result in output.values():
      
        # basic assert checks from the values in output
        assert 'failed' not in result
        assert result['rc'] == 0

DEMO

Text

Great!! How DO I get started

QUESTIONS?

THANK YOU.

lightweight provisioner to speed up CI workflow

By Bhavik Bhavsar

Private

lightweight provisioner to speed up CI workflow