T E S T I N G Y O U R L O C A L P K G S R C D E V E L O P M E N T - - PowerPoint PPT Presentation

t e s t i n g y o u r l o c a l p k g s r c d e v e l o p
SMART_READER_LITE
LIVE PREVIEW

T E S T I N G Y O U R L O C A L P K G S R C D E V E L O P M E N T - - PowerPoint PPT Presentation

PA C K E R , VA G R A N T, V I R T U A L B O X & C O T E S T I N G Y O U R L O C A L P K G S R C D E V E L O P M E N T W I N G C O M M A N D E R Thomas Merkel drscream@edgebsd.org 2017-07-01 A G E N D A who? why? what?


slide-1
SLIDE 1

T E S T I N G Y O U R L O C A L P K G S R C D E V E L O P M E N T

PA C K E R , VA G R A N T, V I R T U A L B O X & C O

W I N G C O M M A N D E R

Thomas Merkel drscream@edgebsd.org 2017-07-01

slide-2
SLIDE 2

A G E N D A

  • who?
  • why?
  • what?
slide-3
SLIDE 3

W H O

  • Server Ninja at SkyLime GmbH
  • BashOps :-)
  • Focus on automation, monitoring, system operation
  • Around 800 servers to maintain
  • SmartOS and a little bit pkgsrc, EdgeBSD, FreeBSD
slide-4
SLIDE 4

W H Y

  • pkgsrc has multi-platform and OS support
  • It’s hard to build and test packages on all platforms
  • Big effort to install “all” operating systems and

configure your pkgsrc development environment

  • Like to work on your local computer or notebook

W H Y N O T A U T O M AT E I T ?

slide-5
SLIDE 5

W H AT

PA C K E R

  • “Infrastructure as code”: JSON description file
  • Build images for different operating systems and

platforms

  • Result is always an OS image
slide-6
SLIDE 6

W H AT

PA C K E R

slide-7
SLIDE 7

W H AT

PA C K E R

  • Support multiple builders
  • VirtualBox, VMware, QEMU
  • Google Cloud, AWS, Azure
  • and more
slide-8
SLIDE 8

W H AT

PA C K E R

  • Provisioners to configure the operating system
  • Ansible, Chef, Puppet, Salt
  • Shell, PowerShell
  • and more
slide-9
SLIDE 9

W H AT

PA C K E R

  • Post-Processors
  • Compress, Checksum, Manifests
  • Cloud publish, Shell, Vagrant
  • and more …
slide-10
SLIDE 10

W H AT

PA C K E R - E X A M P L E

  • Define some variables
  • Use these variables

variables : { build_suffix : "", mirror: https://cdn.netbsd.org/pub/NetBSD, mirror2: http://nyftp.netbsd.org/pub/NetBSD-daily, release : 7.1 } iso_urls: [ iso/NetBSD-{{user `release`}}-amd64.iso, {{user `mirror`}}/NetBSD-{{user `release`}}/iso/NetBSD-…-amd64.iso ]

slide-11
SLIDE 11

W H AT

PA C K E R - E X A M P L E

"builders": [ { ¦ "type": "virtualbox-iso", ¦ "boot_command": [ ¦ "<enter><enter>e<enter><enter>dhcpcd wm0<enter>sleep 2<enter>", ¦ "ftp -o /tmp/i.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh<enter>", ¦ "sh /tmp/i.sh<enter>reboot<enter>" ¦ ], ¦ "disk_size": 10140, ¦ "guest_os_type": "NetBSD_64", ¦ "http_directory": "http", ¦ "iso_urls": [ ¦ "iso/NetBSD-{{user `release`}}-amd64.iso", ¦ "{{user `mirror`}}/NetBSD-{{user `release`}}/iso/NetBSD-...-amd64.iso" ¦ ], ¦ "ssh_username": "vagrant" } ], "provisioners": [ { ¦ "scripts": [ "scripts/postinstall.sh" ], ¦ "type": "shell" } ]

slide-12
SLIDE 12

U S E PA C K E R T O B U I L D N E T B S D 7 B O X

DEMO

slide-13
SLIDE 13

W H AT

VA G R A N T

  • Local development environment
  • Vagrant boxes build by packer
  • Virtual machine management
  • Ruby configuration file
slide-14
SLIDE 14

W H AT

VA G R A N T

  • The configuration file describe:
  • which image should be used
  • which provider should be used
  • how to configure the network
  • if files or folders should be shared
  • additional provision scripts
slide-15
SLIDE 15

W H AT

VA G R A N T

  • Vagrant support multiple providers
  • Default is Virtualbox
  • VMware, Hyper-V, etc. also supported
slide-16
SLIDE 16

W H AT

VA G R A N T

  • Provisioners could be:
  • Ansible, Chef, Puppet, Salt
  • Shell scripts, Files, …
slide-17
SLIDE 17

W H AT

VA G R A N T - E X A M P L E

$pkgsrc = File.expand_path("../pkgsrc", __FILE__) Vagrant.configure("2") do |config| config.vm.define "netbsd7" do |netbsd7| netbsd7.vm.box = "builds/netbsd-7.0.1-amd64-virtualbox.box" netbsd7.vm.box_check_update = false netbsd7.vm.network :private_network, ip: "10.11.12.13" netbsd7.vm.synced_folder ".", "/vagrant", nfs: true netbsd7.vm.synced_folder $pkgsrc, "/content/pkgsrc", :nfs => true, :mount_options => ['nolock,vers=3,udp,noatime'] netbsd7.vm.provider "virtualbox" do |vb| vb.memory = "1024" end netbsd7.vm.provision "file", source: "mk.conf.netbsd7", destination: “/etc/mk.conf" netbsd7.vm.provision "shell", inline: <<-SHELL ( uptime 2> /dev/null || /bin/true ) SHELL end end

slide-18
SLIDE 18

S TA R T N E T B S D 7 M A C H I N E W I T H VA G R A N T

DEMO

slide-19
SLIDE 19

W H AT

M Y E N V I R O N M E N T - U S E

  • MacOS for local pkgsrc development
  • Packer to build NetBSD 7 and SmartOS boxes
  • Vagrant to configure and manage machines
  • Link local pkgsrc repository to these machines
  • Bash scripts to run “make” commands on all boxes
slide-20
SLIDE 20

W H AT

M Y E N V I R O N M E N T - B A S H

  • switch.sh: Bash environment for pkgsrc development
  • .bashrc: Use vagrant command to SSH to all boxes

function vmake() { p=$(pwd | sed 's:.*/pkgsrc/::g') /usr/local/bin/vagrant ssh -c "cd /content/pkgsrc/$p && sudo make $@" } # New export PATH export PATH=/Users/tm/pkg/sbin:/Users/tm/pkg/bin:/usr/bin:/bin:/usr/sbin:/sbin # Modify PS1 export PS1="{\!} \[\e[1;37m\]\w\[\033[m\]\[\e[32;1m\]$\[\033[m\] " # Switch mode bash --rcfile /Users/tm/Development/pkgsrc/.bashrc

slide-21
SLIDE 21

B U I L D S O M E T H I N G : - )

DEMO

slide-22
SLIDE 22

h t t p s : / / g i t h u b . c o m / d r s c re a m / p k g s rc - d e v - e n v

QUESTIONS?