SlideShare une entreprise Scribd logo
1  sur  18
Télécharger pour lire hors ligne
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!

Contenu connexe

Tendances

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 HerokuDaniel 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 CodeSATOSHI TAGOMORI
 
Socket.io under the hood
Socket.io under the hoodSocket.io under the hood
Socket.io under the hoodHaokang Den
 
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 ApplicationVorakamol Choonhasakulchok
 
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 linedotCloud
 
Steam Learn: Composer
Steam Learn: ComposerSteam Learn: Composer
Steam Learn: Composerinovia
 
Going real time with Socket.io
Going real time with Socket.ioGoing real time with Socket.io
Going real time with Socket.ioArnout Kazemier
 
asyncio community, one year later
asyncio community, one year laterasyncio community, one year later
asyncio community, one year laterVictor Stinner
 
Dataflow: Declarative concurrency in Ruby
Dataflow: Declarative concurrency in RubyDataflow: Declarative concurrency in Ruby
Dataflow: Declarative concurrency in RubyLarry Diehl
 
Strategies for successfully adopting Elixir
Strategies for successfully adopting ElixirStrategies for successfully adopting Elixir
Strategies for successfully adopting ElixirErlang Solutions
 
What's Special About Elixir
What's Special About ElixirWhat's Special About Elixir
What's Special About ElixirNeven Rakonić
 

Tendances (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
 

En vedette

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 systeembeheerBert Van Vreckem
 
Gebruikers, groepen en permissies
Gebruikers, groepen en permissiesGebruikers, groepen en permissies
Gebruikers, groepen en permissiesBert 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 tipsBert Van Vreckem
 
Een fileserver opzetten met Samba
Een fileserver opzetten met SambaEen fileserver opzetten met Samba
Een fileserver opzetten met SambaBert Van Vreckem
 
Een literatuurstudie maken: hoe & waarom
Een literatuurstudie maken: hoe & waaromEen literatuurstudie maken: hoe & waarom
Een literatuurstudie maken: hoe & waaromBert Van Vreckem
 

En vedette (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
 

Similaire à One vagrantfile to rule them all

Vagrant introduction for Developers
Vagrant introduction for DevelopersVagrant introduction for Developers
Vagrant introduction for DevelopersAntons 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 VagrantJoe 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 VagrantBrian Hogan
 
Esx.sc.quickref
Esx.sc.quickrefEsx.sc.quickref
Esx.sc.quickrefhellocn
 
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
 
DevOps Hackathon - Session 1: Vagrant
DevOps Hackathon - Session 1: VagrantDevOps Hackathon - Session 1: Vagrant
DevOps Hackathon - Session 1: VagrantAntons Kranga
 
Vagrant for real
Vagrant for realVagrant for real
Vagrant for realCodemotion
 
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 beginnersLiora 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 ChefOrtus 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-phpapp01Suresh Kumar
 

Similaire à 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
VagrantVagrant
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-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
 

Dernier

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Dernier (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

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!