Sie sind auf Seite 1von 16

Jenkins + Robot + Ansible

= POWER!!
Mike Piecuch
Senior DevOps Software Engineer
Nuage Networks from Nokia
Must Haves:
Deploy on demand or on a schedule
Write configuration at time of deploy
Scripting in plain English sentences
Debuggability
Tracking and archiving
Take over the Internet and eventually the world!
My Minions
• Schedules builds/tests/deploy
• Manages resources
• Tracks and archives results

• Test automation framework


• Almost pure-English syntax
• Easily extendable
• Easy to read web-based results/debugging

• DevOps automation framework


• Incredible library of modules
• Agentless architecture
• Does the work
My Evil Plan

• Create job for deploying app


• Write a script for overseeing deployment
• Create a reusable library with the needed tools
• Write app and Ansible configuration with parameters
• Execute an Ansible playbook to do deployment
• Track and record results
Setup Deploy Job
Scripting in English
*** Settings ***
Library EvilLib

*** Test Cases ***

Execute Evil Plan


Configure App
Deploy App With Ansible

*** Keywords ***

Configure App
Write File From Template
... index.html
... index_template.j2
... num_stars=${num_stars}
... take_over_the_world=${take_over_the_world}

Deploy App With Ansible


Write File From Template
... hosts
... hosts_template.j2
... server_ip=${server_ip}
... port=${port}

Run Ansible Playbook deploy_super_evil_app.yml


Robot Magic
Robot test file EvilLib.py (Python)
Write File From Template def write_file_from_template(to_file,
... index.html template_file,
... index_template.j2 **substitutions):

# Execute Jinja2 templating engine

Run Ansible Playbook


... deploy_app.yml def run_ansible_playbook(playbook):

# Execute ansible-playbook

if exit_code != 0:
raise Exception(
"Playbook %s failed with exit code %d" % (
playbook, exit_code))
Jinja2 Template Substitution
hosts_template.j2
[super_evil_servers] [super_evil_servers]
{{ server_ip }} 10.31.177.12

[super_evil_servers:vars] [super_evil_servers:vars]
ansible_user=root ansible_user=root
port={{ port }} port=80

index_template.j2
<html> <html>
<title> Mike's Super Evil Killer Web <title> Mike's Super Evil Killer
App </title> Web App </title>
App Rating: App Rating:
{% for i in range( num_stars | int ) %} <img src="star.png">
<img src="star.png"> <img src="star.png">
{% endfor %} <img src="star.png">
<img src="star.png">
{% if take_over_the_world == 'true' %} <img src="star.png">
<script src="take_over_the_world.js">
</script> <script
{% else %} src="take_over_the_world.js">
Not taking over the world today... :( </script>
{% endif %} </html>
</html>
Run Deploy Job
Aww, Snap!!
Robot to the Rescue!
Fix it… fix it… FIX IT!!
deploy_super_evil_app.yml (Ansible Playbook)
---
- hosts: super_evil_servers
tasks:
- name: Start app
shell: "start server {{ server_port }}"

hosts_template.j2

[super_evil_servers] [super_evil_servers]
{{ server_ip }} {{ server_ip }}

[super_evil_servers:vars] [super_evil_servers:vars]
ansible_user=root ansible_user=root
port={{ port }} server_port={{ port }}
Tracking and Archiving
App Rating:
Presentation Material

Libraries and files from presentation available at:


https://devops.nuagenetworks.net/jenkins-ci-robot-framework-ansible-power/

Mike Piecuch
Senior DevOps Software Engineer
Nuage Networks from Nokia

Das könnte Ihnen auch gefallen