PyCon Ireland - Python DevOps flows with Ansible, Packer & Kubernetes - Mihai Criveti
https://www.youtube.com/watch?v=lO884XAdddQ
1 Packer: Image Build Automation
2 OpenSCAP: Automate Security Baselines
3 Ansible: Provisioning and Configuration Management
4 Molecule: Test your Ansible Playbooks on Docker, Vagrant or Cloud
5 Vagrant: Test images with vagrant
6 Package Python Applications with setuptools
7 Kubernetes: Container Orchestration at Scale
8 DevOps Culture and Practice
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Mihai Criveti - PyCon Ireland - Automate Everything
1. Slice of DevOps - Automate Everything
Packer, Ansible, OpenSCAP, Vagrant and Kubernetes
Mihai Criveti, Cloud Native Competency Leader at IBM
October 12, 2019
1
2. 1 Packer: Image Build Automation
2 OpenSCAP: Automate Security Baselines
3 Ansible: Provisioning and Configuration Management
4 Molecule: Test your Ansible Playbooks on Docker, Vagrant or Cloud
5 Vagrant: Test images with vagrant
6 Package Python Applications with setuptools
7 Kubernetes: Container Orchestration at Scale
8 DevOps Culture and Practice 2
3. Introduction
Mihai Criveti, IBM Cloud Solutions
• Cloud Native & Red Hat Solutions Leader
• Builds multi-cloud environments for large customers
• Migrating his current build environment to cloud
Base OS Image Automation
• Build OS master golden images using Packer and Ansible
• Automate your image pipeline using CI/CD with Jenkins
• Continuous Compliance with OpenSCAP
This talk is not affiliated with my employer
• This talk reflects personal opinions and projects
3
4. Example Workflow: Build, Secure and Test Images for Multiple Environments
0. GitHub / GitLab: Configuration & Infrastructure as Code
1. Packer & OpenSCAP: build secure virtual and cloud images
2. Ansible & Molecule: configuration management & testing
3. Jenkins / Travis: setup CI/CD pipelines
4. Vagrant Cloud: publish your images
5. Python Setuptools: Package your Code
6. Black, Yapf, SonarQube, Bandit: Static Analysis
7. Kubernetes, Helm, OpenShift: deploy your application
4
24. Getting Help
Search for an appropriate module (~3000 existing) and get help
ansible-doc -l | grep pip
Using the examples section
ansible-doc pip
# Install (Bottle) into the specified (virtualenv), using Python 2.7
- pip:
name: bottle
virtualenv: /my_app/venv
virtualenv_command: virtualenv-2.7
21
25. Using ansible-doc snippet
ansible-doc -s pip
- name: Manages Python library dependencies
pip:
chdir: # cd into this directory
editable: # Pass the editable flag.
executable: # The explicit executable or a pathname
extra_args: # Extra arguments passed to pip.
name: # Python library to install or the url
requirements: # The path to a pip requirements file
state: # absent, forcereinstall, latest, present
22
28. 4 Molecule: Test your Ansible
Playbooks on Docker, Vagrant or
Cloud
29. Ansible Molecule
Creating a vagrant or docker machine and trigger goss tests:
molecule create -s vagrant-centos-7
molecule converge -s vagrant-centos-7
molecule login
In one step
molecule test
Another OS:
molecule create -s docker-ubuntu-18.04
25
31. Molecule Cookie Cutter Templates
Cookiecutter: Better Project Templates
• Cookiecutter creates projects from project templates, e.g. Ansible role structure,
with molecule tests.
• Molecule provides a native cookiecutter interface, so developers can provide their
own templates.
Create a new role from a template, with molecule tests included
molecule init template
--url https://github.com/crivetimihai/ansible_cookiecutter.git
--role-name httpd
27
33. Test images locally with Vagrant
Run vagrant up on a Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "centos-8-base"
config.vm.hostname = "centos8.lab.local"
config.vm.network "private_network", ip: "172.16.6.4"
config.vm.provider "virtualbox" do |vb|
vb.cpus = "2"
vb.memory = "2048"
vb.customize ["modifyvm", :id, "--vram", "256"]
end
end
28
40. Indenting code: Black and Yapf
Indent code with black
black -l 79 code.py
…or yapf
yapf --style google --style-help > ~/.style.yapf
yapf --style google -i code.py
34
50. DevOps Tools and Practices
DevOps: People, Processes and Tools working together to bring continuous delivery
of value to clients.
Continuous integration/Continuous delivery
• Continuous Integration: merging changes to the main branch as often as possible.
Running automated builds and tests against the build.
• Continuous Delivery: making sure you can release new changes to customers quickly.
Automated release process to deploy your application.
• Continuous Deployment: every change that passes all stages of your pipeline is
released automatically.
Various tools and notifications (ex: Slack to report failed builds) can be integrated
as part of your DevOps toolchain.
42
52. Cultural Transformation
• Culture: Build trust and align your team with better communication and
transparency.
• Discover: Understand the problem domain and align on common goals.
• Think: Know your audience and meet its needs faster than the competition.
• Develop: Collaborate to build, continuously integrate and deliver high-quality code.
• Reason: Apply AI techniques so that you can make better decisions.
• Operate: Harness the power of the cloud to quickly get your minimum viable product
(MVP) into production, and monitor and manage your applications to a high degree of
quality and meet your service level agreements. Grow or shrink your resources
based on demand.
• Learn: Gain insights from your users as they interact with your application.
44
53. The Open Practice Library
Figure 10: openpracticelibrary.com: A
community-driven repository of practices and tools
An Outcome Delivery framework:
• Discovery - generate the Outcomes
• Options - identify how to get there
• Delivery - implement and put ideas to the
test. Learn what works and what doesn’t.
45
54. The Open Practice Library - Discovery
Figure 11: What problems are you trying to solve, for whom and why? 46
55. The Open Practice Library - Options Pivot
Figure 12: What are the different options? What do you need to make this happen? 47
56. The Open Practice Library - Delivery
Figure 13: What was measured impact? What did you learn? 48
57. The Open Practice Library - Foundation
Figure 14: Creating a team culture 49
59. Questions and Contact
Thank you!
Twitter: @CrivetiMihai
LinkedIn: https://www.linkedin.com/in/crivetimihai/
GitHub: crivetimihai
Ansible Galaxy: https://galaxy.ansible.com/crivetimihai
All presentations: https://kubernetes-native.github.io/k8s-workshop/docs/
Ask me about jobs at IBM
51