+ All Categories
Home > Documents > Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880`...

Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880`...

Date post: 31-Oct-2020
Category:
Upload: others
View: 3 times
Download: 0 times
Share this document with a friend
111
Multi tenanted Munki with Puppet and Sal
Transcript
Page 1: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Multi tenanted Munki with Puppet and Sal

Page 2: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 3: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 4: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Munki = Awesome

Page 5: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

A long time ago, in a country far away...

Page 6: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 7: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 8: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 9: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 10: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 11: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 12: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

$ munkiimport /Volumes/Microsoft\ Office\ 2011\ 14.1.0\ Update/Office\ 2011\ 14.1.0\ Update.mpkg

Page 13: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

$ munkiimport /Volumes/Microsoft\ Office\ 2011\ 14.1.0\ Update/Office\ 2011\ 14.1.0\ Update.mpkg $ munkiimport /Volumes/Microsoft\ Office\ 2011\ 14.1.0\ Update/Office\ 2011\ 14.1.0\ Update.mpkg $ munkiimport /Volumes/Microsoft\ Office\ 2011\ 14.1.0\ Update/Office\ 2011\ 14.1.0\ Update.mpkg $ munkiimport /Volumes/Microsoft\ Office\ 2011\ 14.1.0\ Update/Office\ 2011\ 14.1.0\ Update.mpkg $ munkiimport /Volumes/Microsoft\ Office\ 2011\ 14.1.0\ Update/Office\ 2011\ 14.1.0\ Update.mpkg $ munkiimport /Volumes/Microsoft\ Office\ 2011\ 14.1.0\ Update/Office\ 2011\ 14.1.0\ Update.mpkg $ munkiimport /Volumes/Microsoft\ Office\ 2011\ 14.1.0\ Update/Office\ 2011\ 14.1.0\ Update.mpkg $ munkiimport /Volumes/Microsoft\ Office\ 2011\ 14.1.0\ Update/Office\ 2011\ 14.1.0\ Update.mpkg $ munkiimport /Volumes/Microsoft\ Office\ 2011\ 14.1.0\ Update/Office\ 2011\ 14.1.0\ Update.mpkg $ munkiimport /Volumes/Microsoft\ Office\ 2011\ 14.1.0\ Update/Office\ 2011\ 14.1.0\ Update.mpkg

Page 14: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Manual labour sucks

Page 15: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 16: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Easy for me

Page 17: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

–Johnny Appleseed

“Type a quote here.”

Page 18: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

VPN

VPN

VPN

Page 19: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Then things happened

Page 20: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Bigger clients

Page 21: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Death of the Xserve

Page 22: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 23: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Cloudify all of the things

Page 24: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Amazon Web Services

Page 25: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

VPN

VPN

VPN

Page 26: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

VPN

VPN

VPN

Page 27: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

VPN

VPN

VPN

Page 28: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 29: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Puppet

Page 30: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Why Puppet?

Page 31: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 32: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Drift

Correction

Actual State Desired State

Report

Page 33: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

“Language to describe what you want, not how

you get there.” @glarizza

Page 34: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

file {'/usr/local/somefile': ensure => present, mode => '0644', owner => root, group => root, content => 'puppet:///modules/mymodule/somefile' }

Page 35: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Reposado

Page 36: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

class reposado_child ( $base_dir = $reposado_child::params::base_dir, $install_dir = $reposado_child::params::install_dir, $host_name, ) inherits reposado_child::params { #create directory for files file { "${base_dir}": ensure => 'directory', } file {"${install_dir}": ensure => 'directory', } ! # clone repo vcsrepo { "${install_dir}": ensure => present, provider => git, source => 'https://github.com/wdas/reposado.git', revision => 'e10abdc52cf5a967b4d2397297ebb4c653d126ac' }

Page 37: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

if $::operatingsystem == "Ubuntu"{ if ! defined (Package['curl']){ package {'curl': ensure => installed, } } if ! defined (Package['git']){ package {'git': ensure => installed, } } }

Page 38: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

include apache host { "${host_name}": ensure => 'present', ip => "$::ipaddress", target => '/etc/hosts', } apache::vhost { "${host_name}": priority => '10', vhost_name => "${host_name}", port => '80', docroot => "${base_dir}/catalogs", require => File["${base_dir}"], } #cron to run script $offset = fqdn_rand(59) cron { 'repo_sync': command => "${install_dir}/code/repo_sync >/dev/null", user => root, minute => $offset, hour => '*/6' }

Page 39: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

# Reposado's preferences plist file { "${install_dir}/code/preferences.plist": ensure => present, mode => 644, owner => root, group => $the_group, content => template('reposado_child/preferences.plist.erb'), require => Vcsrepo["${install_dir}"], }

Page 40: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CurlPath</key> <string>/usr/bin/curl</string> <key>LocalCatalogURLBase</key> <string>http://<%= @host_name-%></string> <key>UpdatesMetadataDir</key> <string><%= @base_dir -%>/metadata</string> <key>UpdatesRootDir</key> <string><%= @base_dir -%>/catalogs</string> </dict> </plist>

Page 41: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Local vs Cloud

Page 42: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

RewriteEngine On Options FollowSymLinks !# Client 1 Site 1 RewriteCond %{REMOTE_ADDR} ^12\.34\.57\.78$ RewriteRule ^content/downloads/(.+) http://sus.site1.client1.co.uk/content/downloads/$1 [R=302,L] !# Client 1 Site 2 RewriteCond %{REMOTE_ADDR} ^90\.12\.34\.56$ RewriteRule ^content/downloads/(.+) http://sus.site2.client1.co.uk/content/downloads/$1 [R=302,L] !# Client 2 London RewriteCond %{REMOTE_ADDR} ^78\.90\.12\.23$ RewriteRule ^content/downloads/(.+) http://sus.ldn.client2.com/content/downloads/$1 [R=302,L] !# Client 2 SF RewriteCond %{REMOTE_ADDR} ^45\.67\.89\.10$ RewriteRule ^content/downloads/(.+) http://sus.sf.client2.com/content/downloads/$1 [R=302,L] !# Client 2 NY RewriteCond %{REMOTE_ADDR} ^98\.87\.76\.65$ RewriteRule ^content/downloads/(.+) http://sus.ny.client2.com/content/downloads/$1 [R=302,L] !...

Page 43: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

RewriteCond %{HTTP_USER_AGENT} Darwin/8 RewriteRule ^index(.*)\.sucatalog$ content/catalogs/index$1.sucatalog [L] RewriteCond %{HTTP_USER_AGENT} Darwin/9 RewriteRule ^index(.*)\.sucatalog$ content/catalogs/others/index-leopard.merged-1$1.sucatalog [L] RewriteCond %{HTTP_USER_AGENT} Darwin/10 RewriteRule ^index(.*)\.sucatalog$ content/catalogs/others/index-leopard-snowleopard.merged-1$1.sucatalog [L] RewriteCond %{HTTP_USER_AGENT} Darwin/11 RewriteRule ^index(.*)\.sucatalog$ content/catalogs/others/index-lion-snowleopard-leopard.merged-1$1.sucatalog [L] RewriteCond %{HTTP_USER_AGENT} Darwin/12 RewriteRule ^index(.*)\.sucatalog$ content/catalogs/others/index-mountainlion-lion-snowleopard-leopard.merged-1$1.sucatalog [L] RewriteCond %{HTTP_USER_AGENT} Darwin/13 RewriteRule ^index(.*)\.sucatalog$ content/catalogs/others/index-10.9-mountainlion-lion-snowleopard-leopard.merged-1$1.sucatalog [L]

Page 44: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

class {'reposado_child': host_name => 'sus.someclient.com', }

Page 45: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Munki

Page 46: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

class munki_sync ( $masterurl = $munki_sync::params::masterurl, $repopath = $munki_sync::params::repopath, $installpath = $munki_sync::params::installpath, $tmpdir = $munki_sync::params::tmpdir, $exclude_folders = undef, $source = $munki_sync::params::source, $sshoptions = '', $scpoptions = '', $username = '', $password = '', $host_name, ) inherits munki_sync::params { !

Page 47: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

#create directory for files file {"${installpath}": ensure => 'directory', } if $::operatingsystem == 'Ubuntu'{ file {"${repopath}": ensure => 'directory', owner => 'www-data', group => 'www-data', recurse => true, } }

Page 48: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

# create file with excluded directories for the sync file {"${installpath}/exclude.txt": ensure => present, mode => 700, owner => root, group => root, content => template('munki_sync/exclude.txt.erb'), } !# create sync script file {"${installpath}/sync.sh": ensure => present, mode => 700, owner => root, group => root, content => template('munki_sync/sync.sh.erb'), }

Page 49: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

host { "${host_name}": ensure => 'present', ip => "$::ipaddress", target => '/etc/hosts', }

Page 50: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

if $username == '' { apache::vhost { "${host_name}": priority => '10', vhost_name => "${host_name}", port => '80', docroot => $repopath, } }else{ # create .htpasswd file file {"${installpath}/.htpasswd": ensure => present, mode => 700, owner => www-data, group => www-data, content => template('munki_sync/htpasswd.erb'), } ! apache::vhost { "${host_name}": priority => '10', vhost_name => "${host_name}", port => '80', docroot => $repopath, custom_fragment => template('munki_sync/fragment.erb'), } }

Page 51: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

class someclient::munki{ ! $the_name = $::ipaddress ? { '10.30.0.6' => 'munki.ldn.someclient.com', '10.30.10.6' => 'munki.sf.someclient.com', } ! class {'munki_sync': masterurl => 'https://ourmunkimaster.aws.somwhere.com', source => '[email protected]:/var/www/munki/pkgs/', repopath => '/var/www/pkgs', exclude_folders => ['clients/a_different_client', 'clients/another_client'], host_name => $the_name, } !}

Page 52: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Hiera

Page 53: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

# /etc/puppet/hiera.yaml --- :hierarchy: - "%{::customer_name}/%{::customer_site}/%{::customer_build}" - "%{::customer_name}/%{::customer_build}" - "%{::customer_name}" - "WAN_IP/%{::public_ipaddress_underscore}" - "%{::virtual}" - "%{::fqdn}" - common :backends: - yaml :logger: console :yaml: :datadir: '/etc/puppet/hieradata'

Page 54: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

# /etc/puppet/hieradata/client1.yaml --- "munki_sync::masterurl": "https://ourmunkimaster.aws.somwhere.com" "munki_sync::username": "munkisyncuser" "munki_sync::password": "$jkdskjsdhfklsjfsd83" "munki_sync::source": "[email protected]:/var/www/munki/pkgs/" "munki_sync::exclude_folders": - "clients/client2" - "clients/client3" - "clients/client4"

Page 55: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

include munki_sync

Page 56: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

/Volumes/Munki catalogs manifests pkgs pkgsinfo apple_updates apps clients client1 client2 client3 ... drivers updates

Page 57: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

#!/bin/bashrsync -av --delete-excluded --exclude-from 'exclude.txt' '<%= @source -%>' '<%= @repopath -%>'

Page 58: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 59: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

<Location "/pkgs/clients/client1/"> AuthType Basic AuthName "Munki Repository - Client 1" AuthUserFile /etc/apache2/htpasswd/client1 Require valid-user </location> !<Location "/pkgs/clients/client2/"> AuthType Basic AuthName "Munki Repository - Client 2" AuthUserFile /etc/apache2/htpasswd/client2 Require valid-user </location> ... <Location "/"> AuthType Basic AuthName "Munki Repository" AuthUserFile /etc/apache2/htpasswd/all Require valid-user </location>

Page 60: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

But not all was good in the land of Munki syncing...

Page 61: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 62: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Nope

Yep

Page 63: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

#!/bin/bash cd <%= @installpath %> if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi !if [ -e "/tmp/munki_sync.pid" ] then echo "PID file found, exiting" exit 0 fi touch /tmp/munki_sync.pid !# Check if the timestamp file on the server is newer than ours scp <% if @scpoptions -%><%= @scpoptions -%> <% end -%><%= @source -%>/last_update /tmp/last_update our_date="0" server_date=`cat /tmp/last_update` if [ -a "<%= @repopath -%>/last_update" ]; then our_date=`cat <%= @repopath -%>/last_update` fi !if [ "$server_date" != "$our_date" ]; then ! rsync <% if @sshoptions -%>-e "ssh <%= @sshoptions -%>" <% end -%> --progress --partial -z --delete -r --exclude-from 'exclude.txt' --exclude ".*" '<%= @source -%>' '<%= @repopath -%>'&& Completed=1 if [ $Completed == 1 ]; then echo $server_date > <%= @repopath -%>/last_update fi chown -R <%= @web_group -%> <%= @repopath %> !fi rm /tmp/munki_sync.pid rm /tmp/last_update

Page 64: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Clients

Page 65: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

$pkgurl = $::public_ipaddress ? { '123.230.3.24' => 'munki.ldn.someclient.com/pkgs', '223.230.5.24' => 'munki.sf.someclient.com/pkgs', default => 'munki.example.com/pkgs', } !!class { 'mac_admin::munki': repourl => "https://munki.example.com", suppressstopbuttononinstall => true, bootstrap => true, clientidentifier => "demo_client", packageurl => $pkgurl }

Page 66: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

What if they're out of sync?

Page 67: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

/usr/local/munki/preflight

Page 68: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Yep

Yep

Nope

YepNope

Nope (x5)

Yep

Nope

Page 69: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

class munki_sync::client ( $local_urls = $munki_sync::params::local_urls ) inherits munki_sync::params { ! file {'/usr/local/munki/preflight': owner => 0, group => 0, mode => '0755', content => template('munki_sync/preflight.erb'), require => Class['mac_admin::munki'], } ! if ! defined(File['/usr/local/munki/conditions']) { file{ '/usr/local/munki/conditions': ensure => directory, } } ! file{ '/usr/local/munki/conditions/location.py': ensure => present, source => 'puppet:///modules/munki_sync/location.py', mode => '0755', owner => 0, group => 0, } }

Page 70: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

[insert preflight script here]

Page 71: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

try: from munkilib import fetch, munkicommon except: sys.path.append('/usr/local/munki') from munkilib import fetch, munkicommon !def network_on(): try: response=urllib2.urlopen(munkicommon.pref('SoftwareRepoURL'),timeout=1) return True except urllib2.URLError as err: pass return False !def check_bootstrap_file(): bootstrap_file = '/Users/Shared/.com.googlecode.munki.checkandinstallatstartup' if os.path.exists(bootstrap_file): # check that the server is reachable serverUp = False for unused_i in range(5): if network_on(): serverUp = True break time.sleep(2) if not serverUp: # if the server is down, remove the file os.unlink(bootstrap_file)

Page 72: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

LOCAL_URLS = { #'8.8.8.8':'http://192.168.33.12/pkgs', #'86.185.150.242':'http://my.munki.box/pkgs' ! <% local_urls.each_pair do |key, value_hash| %> '<%= value_hash['ip'] %>':'<%= value_hash['server'] %>', <% end %> } !def get_wan(): ext_ip = urllib2.urlopen('http://icanhazip.com/').read().strip() return ext_ip !def get_local_server(): wan_ip = get_wan() local_url = MASTER_URL for ip, address in LOCAL_URLS.iteritems(): if ip == wan_ip: local_url = address return local_url

Page 73: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

CUSTOM_HTTP_HEADER = munkicommon.pref( munkicommon.ADDITIONAL_HTTP_HEADERS_KEY) !def main(): ! local_server = get_local_server() ! # if local url = master url, set PackageURL to the master and exit if local_server == MASTER_URL: munkicommon.set_pref('PackageURL', MASTER_URL) print 'Using Cloud Server' write_conditional('Cloud') check_bootstrap_file() sys.exit(0)

Page 74: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

temp_dir = tempfile.mkdtemp() # Download http://local/pkgs/last_update local_temp_file = os.path.join(temp_dir, 'local_temp') local_remote_file = local_server + '/last_update' try: ! local_last_update = fetch.curl(local_remote_file, local_temp_file, None, CUSTOM_HTTP_HEADER) f = open(local_temp_file) local_timestamp = f.read().strip() f.close() except: local_last_update = '' local_timestamp = ''

Page 75: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

# clean up the tempdir shutil.rmtree(temp_dir) # If master is newer, use that if master_timestamp != local_timestamp: munkicommon.set_pref('PackageURL', MASTER_URL) # We worry if repositories are regularly out of sync, so we show them in Sal write_conditional('Out-of-sync') print 'Out of Sync' check_bootstrap_file() sys.exit(0) else: munkicommon.set_pref('PackageURL', local_server) write_conditional('Local') print 'Using Local Server' check_bootstrap_file() sys.exit(0)

Page 76: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Drift

Correction

Actual State Desired State

Report

Page 77: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Actual State Desired State

Report

Page 78: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 79: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 80: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 81: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

List of facts

Page 82: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 83: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

–Johnny Appleseed

“Type a quote here.”

Page 84: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Single dashboard

Page 85: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 86: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Python to the rescue

Page 87: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 88: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Why build Sal?

Page 89: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Multi-tenanted

Page 90: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Extensible

Page 91: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Facter

Page 92: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

pluginsync

Page 93: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

#!/usr/bin/env ruby !#mac_encryption_enabled.rb require 'facter' Facter.add(:mac_encryption_enabled) do confine :kernel => "Darwin" setcode do osver = Facter.value('macosx_productversion_major') if osver == "10.8" or osver =="10.9" output = Facter::Util::Resolution.exec("/usr/bin/fdesetup status") enabled = output.split("\n").first if enabled=="FileVault is On." "true" else "false" end else "Not supported" end end end

Page 94: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

/usr/local/sal/facter

Page 95: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

/etc/facter/facts.d

Page 96: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

#!/bin/bash !echo salkey=`defaults read /Library/Preferences/com.grahamgilbert.sal key`

Page 97: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

#!/usr/bin/env python !from CoreFoundation import CFPreferencesCopyAppValue !key = CFPreferencesCopyAppValue("key", "com.grahamgilbert.sal") !print 'salkey=%s' % key

Page 98: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

salkey=something

Page 99: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 100: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 101: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 102: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 103: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 104: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 105: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 106: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Installing Sal

Page 107: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

PaaS or your own server?

Page 108: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID
Page 109: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Demo

Page 110: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

Questions?

Page 111: Multi site Munki - graham gilbert...2014/07/09  · if test `find "/tmp/munki_sync.pid" -mmin +2880` then rm /tmp/munki_sync.pid fi ! if [ -e "/tmp/munki_sync.pid" ] then echo "PID

@grahamgilbert grahamgilbert.com !

feedback: http://j.mp/psumac36


Recommended