SlideShare a Scribd company logo
One Vagrantfile to rule them all
Config Management Camp 2016, Ghent
Bert Van Vreckem (bert.vanvreckem@hogent.be)
I use Vagrant a lot
$ find ~ -type f -name Vagrantfile | wc --lines
350
$ vagrant init
⇓
# Comments
Vagrant.configure(2) do |config|
# more comments
config.vm.box = "base"
# Lots more comments
end
typical single machine setup
Vagrant.configure(2) do |config|
config.vm.box = ’bertvv/centos71’
config.vm.hostname = ’box001’
config.vm.network ’private_network’,
ip: 192.168.56.10
config.vm.provision ’ansible’ do |ansible|
ansible_playbook = ’ansible/site.yml’
end
end
Multi-machine setup
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define ’box001’ do |node|
node.vm.hostname = ’box001’
node.vm.box = ’bertvv/centos7’
node.vm.network :private_network, ip: ’192.168.56.10’
end
config.vm.define ’box002’ do |node|
node.vm.hostname = ’box002’
node.vm.box = ’bertvv/centos7’
node.vm.network :private_network, ip: ’192.168.56.11’
end
config.vm.provision ’ansible’ do |ansible|
ansible_playbook = ’ansible/site.yml’
end
end
this starts to smell
• not a config file, but code!
• copy/paste code blocks
• hard-coded values
• will become unmaintanable!
what I want
• reusable
• sane defaults
• DRY code
• separation of data and instructions
• avoid Ruby
in Vagrantfile:
hosts = YAML.load_file(’vagrant-hosts.yml’)
# vagrant-hosts.yml
---
- name: box001
ip: 192.168.56.10
- name: box002
ip: 192.168.56.11
# vagrant-hosts.yml
---
- name: box003
box: fedora22
box_url: https://example.com/boxes/fedora22.box
ip: 172.22.0.5
netmask: 255.255.0.0
mac: ’00:11:22:33:44:55’
intnet: true
synced_folders:
- src: test
dest: /tmp/test
- src: www
dest: /var/www/html
options:
:create: true
:owner: root
:group: root
Vagrantfile
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
hosts.each do |host|
config.vm.define host[’name’] do |node|
node.vm.box = host[’box’] ||= DEFAULT_BASE_BOX
if host.has_key? ’box_url’
node.vm.box_url = host[’box_url’]
end
node.vm.hostname = host[’name’]
node.vm.network :private_network,
network_options(host)
custom_synced_folders(node.vm, host)
# ...
Vagrantfile (cont’d)
node.vm.provider :virtualbox do |vb|
vb.name = host[’name’]
vb.customize [’modifyvm’, :id,
’--groups’, PROJECT_NAME]
end
end
end
provision_ansible(config)
end
helper functions
Helper functions:
• provision_ansible(): support running from Windows
host
• network_options(): parse Yaml config to Ruby argument
list
• custom_synced_folders()
Workflow
1 atb-init testbox bertvv.el7 bertvv.httpd
• Download scaffolding code from Github into directory
testbox/
• Optionally, installs roles from Ansible Galaxy
• Initialise Git repo & initial commit
Workflow (cont’d)
2 Edit vagrant-hosts.yml
# vagrant-hosts.yml
---
- name: testbox
ip: 192.168.56.56
Workflow (cont’d)
3 Assign role in ansible/site.yml
# ansible/site.yml
---
- hosts: testbox
sudo: true
roles:
- bertvv.el7
- bertvv.http
4 vagrant up
Code
• https://github.com/bertvv/ansible-skeleton
• https://github.com/bertvv/ansible-toolbox
• https://github.com/bertvv/ansible-role-skeleton
Need something fancier? See James Shubin’s Oh My Vagrant
https://github.com/purpleidea/oh-my-vagrant
Other stuff
• Twitter: @bertvanvreckem
• Blog: https://bertvv.github.io/notes-to-self/
• Ansible roles (CentOS 7):
https://galaxy.ansible.com/bertvv/
Thanks for listening!
Talk to me about system administration and
education!

More Related Content

What's hot

Dockerfish-Tutorial
Dockerfish-TutorialDockerfish-Tutorial
Dockerfish-TutorialBrian Hood
 
[LaravelConf Taiwan 2019] 編輯器之華山論劍
[LaravelConf Taiwan 2019] 編輯器之華山論劍[LaravelConf Taiwan 2019] 編輯器之華山論劍
[LaravelConf Taiwan 2019] 編輯器之華山論劍
LaravelConfTaiwan
 
Quick and Dirty Python Deployments with Heroku
Quick and Dirty Python Deployments with HerokuQuick and Dirty Python Deployments with Heroku
Quick and Dirty Python Deployments with Heroku
Daniel Pritchett
 
What Is Async, How Does It Work, And When Should I Use It?
What Is Async, How Does It Work, And When Should I Use It?What Is Async, How Does It Work, And When Should I Use It?
What Is Async, How Does It Work, And When Should I Use It?
emptysquare
 
Talk about Ansible and Infrastructure as Code
Talk about Ansible and Infrastructure as CodeTalk about Ansible and Infrastructure as Code
Talk about Ansible and Infrastructure as Code
SATOSHI TAGOMORI
 
Socket.io under the hood
Socket.io under the hoodSocket.io under the hood
Socket.io under the hood
Haokang Den
 
aiohttp intro
aiohttp introaiohttp intro
aiohttp intro
Anton Kasyanov
 
Socket.IO
Socket.IOSocket.IO
Socket.IO
Arnout Kazemier
 
Socket.IO - Alternative Ways for Real-time Application
Socket.IO - Alternative Ways for Real-time ApplicationSocket.IO - Alternative Ways for Real-time Application
Socket.IO - Alternative Ways for Real-time Application
Vorakamol Choonhasakulchok
 
Test driven infrastructure
Test driven infrastructureTest driven infrastructure
Test driven infrastructure
Skills Matter Talks
 
Installing and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command lineInstalling and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command line
dotCloud
 
Ansible 2.0
Ansible 2.0Ansible 2.0
Ansible 2.0
Dennis Rowe
 
Steam Learn: Composer
Steam Learn: ComposerSteam Learn: Composer
Steam Learn: Composer
inovia
 
Going real time with Socket.io
Going real time with Socket.ioGoing real time with Socket.io
Going real time with Socket.io
Arnout Kazemier
 
asyncio community, one year later
asyncio community, one year laterasyncio community, one year later
asyncio community, one year later
Victor Stinner
 
Dataflow: Declarative concurrency in Ruby
Dataflow: Declarative concurrency in RubyDataflow: Declarative concurrency in Ruby
Dataflow: Declarative concurrency in Ruby
Larry Diehl
 
Strategies for successfully adopting Elixir
Strategies for successfully adopting ElixirStrategies for successfully adopting Elixir
Strategies for successfully adopting Elixir
Erlang Solutions
 
Vim for you
Vim for youVim for you
Vim for you
창훈 정
 
What's Special About Elixir
What's Special About ElixirWhat's Special About Elixir
What's Special About Elixir
Neven Rakonić
 

What's hot (19)

Dockerfish-Tutorial
Dockerfish-TutorialDockerfish-Tutorial
Dockerfish-Tutorial
 
[LaravelConf Taiwan 2019] 編輯器之華山論劍
[LaravelConf Taiwan 2019] 編輯器之華山論劍[LaravelConf Taiwan 2019] 編輯器之華山論劍
[LaravelConf Taiwan 2019] 編輯器之華山論劍
 
Quick and Dirty Python Deployments with Heroku
Quick and Dirty Python Deployments with HerokuQuick and Dirty Python Deployments with Heroku
Quick and Dirty Python Deployments with Heroku
 
What Is Async, How Does It Work, And When Should I Use It?
What Is Async, How Does It Work, And When Should I Use It?What Is Async, How Does It Work, And When Should I Use It?
What Is Async, How Does It Work, And When Should I Use It?
 
Talk about Ansible and Infrastructure as Code
Talk about Ansible and Infrastructure as CodeTalk about Ansible and Infrastructure as Code
Talk about Ansible and Infrastructure as Code
 
Socket.io under the hood
Socket.io under the hoodSocket.io under the hood
Socket.io under the hood
 
aiohttp intro
aiohttp introaiohttp intro
aiohttp intro
 
Socket.IO
Socket.IOSocket.IO
Socket.IO
 
Socket.IO - Alternative Ways for Real-time Application
Socket.IO - Alternative Ways for Real-time ApplicationSocket.IO - Alternative Ways for Real-time Application
Socket.IO - Alternative Ways for Real-time Application
 
Test driven infrastructure
Test driven infrastructureTest driven infrastructure
Test driven infrastructure
 
Installing and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command lineInstalling and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command line
 
Ansible 2.0
Ansible 2.0Ansible 2.0
Ansible 2.0
 
Steam Learn: Composer
Steam Learn: ComposerSteam Learn: Composer
Steam Learn: Composer
 
Going real time with Socket.io
Going real time with Socket.ioGoing real time with Socket.io
Going real time with Socket.io
 
asyncio community, one year later
asyncio community, one year laterasyncio community, one year later
asyncio community, one year later
 
Dataflow: Declarative concurrency in Ruby
Dataflow: Declarative concurrency in RubyDataflow: Declarative concurrency in Ruby
Dataflow: Declarative concurrency in Ruby
 
Strategies for successfully adopting Elixir
Strategies for successfully adopting ElixirStrategies for successfully adopting Elixir
Strategies for successfully adopting Elixir
 
Vim for you
Vim for youVim for you
Vim for you
 
What's Special About Elixir
What's Special About ElixirWhat's Special About Elixir
What's Special About Elixir
 

Viewers also liked

Linux Enterprise - inleiding cursus, 5 trends in systeembeheer
Linux Enterprise - inleiding cursus, 5 trends in systeembeheerLinux Enterprise - inleiding cursus, 5 trends in systeembeheer
Linux Enterprise - inleiding cursus, 5 trends in systeembeheer
Bert Van Vreckem
 
Workshop latex
Workshop latexWorkshop latex
Workshop latex
Bert Van Vreckem
 
Gebruikers, groepen en permissies
Gebruikers, groepen en permissiesGebruikers, groepen en permissies
Gebruikers, groepen en permissies
Bert Van Vreckem
 
Wachtwoorden in Linux
Wachtwoorden in LinuxWachtwoorden in Linux
Wachtwoorden in Linux
Bert Van Vreckem
 
A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...
A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...
A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...
Bert Van Vreckem
 
Linux troubleshooting tips
Linux troubleshooting tipsLinux troubleshooting tips
Linux troubleshooting tips
Bert Van Vreckem
 
Een fileserver opzetten met Samba
Een fileserver opzetten met SambaEen fileserver opzetten met Samba
Een fileserver opzetten met Samba
Bert Van Vreckem
 
Een literatuurstudie maken: hoe & waarom
Een literatuurstudie maken: hoe & waaromEen literatuurstudie maken: hoe & waarom
Een literatuurstudie maken: hoe & waarom
Bert Van Vreckem
 

Viewers also liked (8)

Linux Enterprise - inleiding cursus, 5 trends in systeembeheer
Linux Enterprise - inleiding cursus, 5 trends in systeembeheerLinux Enterprise - inleiding cursus, 5 trends in systeembeheer
Linux Enterprise - inleiding cursus, 5 trends in systeembeheer
 
Workshop latex
Workshop latexWorkshop latex
Workshop latex
 
Gebruikers, groepen en permissies
Gebruikers, groepen en permissiesGebruikers, groepen en permissies
Gebruikers, groepen en permissies
 
Wachtwoorden in Linux
Wachtwoorden in LinuxWachtwoorden in Linux
Wachtwoorden in Linux
 
A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...
A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...
A Reinforcement Learning Approach for Hybrid Flexible Flowline Scheduling Pro...
 
Linux troubleshooting tips
Linux troubleshooting tipsLinux troubleshooting tips
Linux troubleshooting tips
 
Een fileserver opzetten met Samba
Een fileserver opzetten met SambaEen fileserver opzetten met Samba
Een fileserver opzetten met Samba
 
Een literatuurstudie maken: hoe & waarom
Een literatuurstudie maken: hoe & waaromEen literatuurstudie maken: hoe & waarom
Een literatuurstudie maken: hoe & waarom
 

Similar to One vagrantfile to rule them all

Intro to vagrant
Intro to vagrantIntro to vagrant
Intro to vagrant
Mantas Klasavicius
 
Vagrant introduction for Developers
Vagrant introduction for DevelopersVagrant introduction for Developers
Vagrant introduction for Developers
Antons Kranga
 
Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))
Michele Orselli
 
Quick & Easy Dev Environments with Vagrant
Quick & Easy Dev Environments with VagrantQuick & Easy Dev Environments with Vagrant
Quick & Easy Dev Environments with Vagrant
Joe Ferguson
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with Vagrant
Brian Hogan
 
Vagrant Up in 5 Easy Steps
Vagrant Up in 5 Easy StepsVagrant Up in 5 Easy Steps
Vagrant Up in 5 Easy Steps
Trevor Roberts Jr.
 
vagrant-php
vagrant-phpvagrant-php
vagrant-php
dominikzogg
 
Esx.sc.quickref
Esx.sc.quickrefEsx.sc.quickref
Esx.sc.quickref
hellocn
 
Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...
Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...
Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...
Atlassian
 
FreeBSD: Dev to Prod
FreeBSD: Dev to ProdFreeBSD: Dev to Prod
FreeBSD: Dev to Prod
Sean Chittenden
 
DevOps Hackathon - Session 1: Vagrant
DevOps Hackathon - Session 1: VagrantDevOps Hackathon - Session 1: Vagrant
DevOps Hackathon - Session 1: Vagrant
Antons Kranga
 
Tech Talk - Vagrant
Tech Talk - VagrantTech Talk - Vagrant
Tech Talk - Vagrant
Thomas Krille
 
Vagrant for real
Vagrant for realVagrant for real
Vagrant for real
Codemotion
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
Michele Orselli
 
Vagrant hands on workshop for beginners
Vagrant hands on workshop for beginnersVagrant hands on workshop for beginners
Vagrant hands on workshop for beginners
Liora Milbaum
 
ITB2015 - Winning with Vagrant, Puppet and Chef
ITB2015 - Winning with Vagrant, Puppet and ChefITB2015 - Winning with Vagrant, Puppet and Chef
ITB2015 - Winning with Vagrant, Puppet and Chef
Ortus Solutions, Corp
 
Vm ware server-tips-tricks
Vm ware server-tips-tricksVm ware server-tips-tricks
Vm ware server-tips-tricksunixadminrasheed
 
Vmwareserver tips-tricks-110218231744-phpapp01
Vmwareserver tips-tricks-110218231744-phpapp01Vmwareserver tips-tricks-110218231744-phpapp01
Vmwareserver tips-tricks-110218231744-phpapp01
Suresh Kumar
 

Similar to One vagrantfile to rule them all (20)

Intro to vagrant
Intro to vagrantIntro to vagrant
Intro to vagrant
 
Vagrant introduction for Developers
Vagrant introduction for DevelopersVagrant introduction for Developers
Vagrant introduction for Developers
 
Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))
 
Quick & Easy Dev Environments with Vagrant
Quick & Easy Dev Environments with VagrantQuick & Easy Dev Environments with Vagrant
Quick & Easy Dev Environments with Vagrant
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with Vagrant
 
Vagrant Up in 5 Easy Steps
Vagrant Up in 5 Easy StepsVagrant Up in 5 Easy Steps
Vagrant Up in 5 Easy Steps
 
Vagrant
VagrantVagrant
Vagrant
 
vagrant-php
vagrant-phpvagrant-php
vagrant-php
 
Esx.sc.quickref
Esx.sc.quickrefEsx.sc.quickref
Esx.sc.quickref
 
Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...
Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...
Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...
 
FreeBSD: Dev to Prod
FreeBSD: Dev to ProdFreeBSD: Dev to Prod
FreeBSD: Dev to Prod
 
Introduction to Vagrant
Introduction to VagrantIntroduction to Vagrant
Introduction to Vagrant
 
DevOps Hackathon - Session 1: Vagrant
DevOps Hackathon - Session 1: VagrantDevOps Hackathon - Session 1: Vagrant
DevOps Hackathon - Session 1: Vagrant
 
Tech Talk - Vagrant
Tech Talk - VagrantTech Talk - Vagrant
Tech Talk - Vagrant
 
Vagrant for real
Vagrant for realVagrant for real
Vagrant for real
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
 
Vagrant hands on workshop for beginners
Vagrant hands on workshop for beginnersVagrant hands on workshop for beginners
Vagrant hands on workshop for beginners
 
ITB2015 - Winning with Vagrant, Puppet and Chef
ITB2015 - Winning with Vagrant, Puppet and ChefITB2015 - Winning with Vagrant, Puppet and Chef
ITB2015 - Winning with Vagrant, Puppet and Chef
 
Vm ware server-tips-tricks
Vm ware server-tips-tricksVm ware server-tips-tricks
Vm ware server-tips-tricks
 
Vmwareserver tips-tricks-110218231744-phpapp01
Vmwareserver tips-tricks-110218231744-phpapp01Vmwareserver tips-tricks-110218231744-phpapp01
Vmwareserver tips-tricks-110218231744-phpapp01
 

Recently uploaded

From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 

Recently uploaded (20)

From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 

One vagrantfile to rule them all

  • 1. One Vagrantfile to rule them all Config Management Camp 2016, Ghent Bert Van Vreckem (bert.vanvreckem@hogent.be)
  • 2. I use Vagrant a lot $ find ~ -type f -name Vagrantfile | wc --lines 350
  • 3. $ vagrant init ⇓ # Comments Vagrant.configure(2) do |config| # more comments config.vm.box = "base" # Lots more comments end
  • 4. typical single machine setup Vagrant.configure(2) do |config| config.vm.box = ’bertvv/centos71’ config.vm.hostname = ’box001’ config.vm.network ’private_network’, ip: 192.168.56.10 config.vm.provision ’ansible’ do |ansible| ansible_playbook = ’ansible/site.yml’ end end
  • 5. Multi-machine setup Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.define ’box001’ do |node| node.vm.hostname = ’box001’ node.vm.box = ’bertvv/centos7’ node.vm.network :private_network, ip: ’192.168.56.10’ end config.vm.define ’box002’ do |node| node.vm.hostname = ’box002’ node.vm.box = ’bertvv/centos7’ node.vm.network :private_network, ip: ’192.168.56.11’ end config.vm.provision ’ansible’ do |ansible| ansible_playbook = ’ansible/site.yml’ end end
  • 6. this starts to smell • not a config file, but code! • copy/paste code blocks • hard-coded values • will become unmaintanable!
  • 7. what I want • reusable • sane defaults • DRY code • separation of data and instructions • avoid Ruby
  • 8. in Vagrantfile: hosts = YAML.load_file(’vagrant-hosts.yml’) # vagrant-hosts.yml --- - name: box001 ip: 192.168.56.10 - name: box002 ip: 192.168.56.11
  • 9. # vagrant-hosts.yml --- - name: box003 box: fedora22 box_url: https://example.com/boxes/fedora22.box ip: 172.22.0.5 netmask: 255.255.0.0 mac: ’00:11:22:33:44:55’ intnet: true synced_folders: - src: test dest: /tmp/test - src: www dest: /var/www/html options: :create: true :owner: root :group: root
  • 10. Vagrantfile Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| hosts.each do |host| config.vm.define host[’name’] do |node| node.vm.box = host[’box’] ||= DEFAULT_BASE_BOX if host.has_key? ’box_url’ node.vm.box_url = host[’box_url’] end node.vm.hostname = host[’name’] node.vm.network :private_network, network_options(host) custom_synced_folders(node.vm, host) # ...
  • 11. Vagrantfile (cont’d) node.vm.provider :virtualbox do |vb| vb.name = host[’name’] vb.customize [’modifyvm’, :id, ’--groups’, PROJECT_NAME] end end end provision_ansible(config) end
  • 12. helper functions Helper functions: • provision_ansible(): support running from Windows host • network_options(): parse Yaml config to Ruby argument list • custom_synced_folders()
  • 13. Workflow 1 atb-init testbox bertvv.el7 bertvv.httpd • Download scaffolding code from Github into directory testbox/ • Optionally, installs roles from Ansible Galaxy • Initialise Git repo & initial commit
  • 14. Workflow (cont’d) 2 Edit vagrant-hosts.yml # vagrant-hosts.yml --- - name: testbox ip: 192.168.56.56
  • 15. Workflow (cont’d) 3 Assign role in ansible/site.yml # ansible/site.yml --- - hosts: testbox sudo: true roles: - bertvv.el7 - bertvv.http 4 vagrant up
  • 16. Code • https://github.com/bertvv/ansible-skeleton • https://github.com/bertvv/ansible-toolbox • https://github.com/bertvv/ansible-role-skeleton Need something fancier? See James Shubin’s Oh My Vagrant https://github.com/purpleidea/oh-my-vagrant
  • 17. Other stuff • Twitter: @bertvanvreckem • Blog: https://bertvv.github.io/notes-to-self/ • Ansible roles (CentOS 7): https://galaxy.ansible.com/bertvv/
  • 18. Thanks for listening! Talk to me about system administration and education!