Created
April 11, 2019 23:23
-
-
Save tspeigner/980b0e541bc3b590343635c5431d10e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use Case 1 - use IP and OS logic to determine which configs to apply to node | |
# This file should live in your control-repo or on the PE Master at | |
# /etc/puppetlabs/code/environments/production/site/profile/manifests/platform/baseline.pp | |
class profile::platform::baseline { | |
# IP Ranges equate to different environments (DEV, UAT, PROD) | |
# OS specific configurations based on OS Type. | |
$plat = $facts.get('os.family') ? { | |
#If os.family == 'windows' then $plat = 'windows', default is 'linux' | |
/windows/ => 'windows', | |
default => 'linux' | |
} | |
$env = $facts.get('ipaddress') ? { | |
# If a node has an IP in the range 10.0.24.253-255 it's in the Dev VPC | |
/^10\.0\.24\.(2(5[3-5]))$/ => 'dev', | |
# If a node has an IP in the range 10.0.24.243-245 it's in the UAT VPC | |
/^10\.0\.24\.(2(4[3-5]))$/ => 'uat', | |
# If a node has an IP in the range 10.0.24.233-235 it's in the Prod VPC | |
/^10\.0\.24\.(2(3[3-5]))$/ => 'prod', | |
default => fail('Environment does not exist'), | |
} | |
# If env = dev and plat = linux == profile::platform::baseline::linux::dev | |
# This is interpolated in the 'include' below | |
include "profile::platform::baseline::${plat}::${env}" | |
} | |
# Use Case 2 - manage packages on MacOS | |
Install packages in Mac and manage by Puppet for all workstations windows , MAC example. | |
c. Basic packages i:e automox , jumpcloud , etc. (send example on installing a package) | |
Resource Type: package - https://puppet.com/docs/puppet/5.5/types/package.html | |
Install multiple packages - https://www.puppetcookbook.com/posts/install-multiple-packages.html | |
Example: | |
# One of two ways of doing this -- first installs each package individually -- second uses some default class parameters | |
class profile::platform::baseline::mac::packages { | |
# Option 1 (remove Option 2 to use this version) sets a default provider of 'homebrew', which can be different for each OS (homebrew, yum, apt, chocolatey, etc.) | |
Package { provider => 'homebrew'} | |
# List of packages to install with the 'homebrew' provider | |
# Managing packages on MacOSX with Puppet and Home Brew - | |
# https://www.example42.com/2018/09/03/managing-osx-packages-with-puppet-and-homebrew/ | |
package { 'mlocate': ensure => 'installed' } | |
package { 'wget': ensure => 'installed' } | |
package { 'chrome': ensure => 'installed' } | |
package { 'otherapplication': } | |
#Option 2 (remove Option 1 to use this version) | |
# First line are default parameters = 'Make sure this package is installed/absent/version and use HomeBrew/Yum/Chocolatey/Apt/Zypper/etc as the package provider' | |
Package { ensure => 'installed', provider = 'homebrew'} | |
package { 'mlocate': } | |
package { 'wget': } | |
package { 'chrome': } | |
package { 'otherapplication': } | |
} | |
# Use Case 3 - Code Manager setup/config | |
We want all the configuration and templates to be on bitbucket. | |
Code Manager setup documentation. (send documentation) | |
Follow the instructions for this module - PE Code Manager Easy Setup - https://forge.puppet.com/beersy/pe_code_manager_easy_setup | |
Install the module | |
Run the task via the PE UI | |
Input values into Bitbucket (webhook/ssh key/etc.) | |
# Use Case 4 - deploy Puppet Agent during Terraform provision | |
Terraform integration with puppet (will discuss in call with scenario we have currently). - send documentation on Puppet Terraform Provider | |
Here is an example of installing the PE agent with Terraform in the past. There are many ways of doing this, but this was a simple fix for me a while ago. Otherwise Terraform will have a built-in provider for Puppet in the near future. | |
https://github.com/tspeigner/terraforming/blob/master/create/aws/deploy.tf#L16-L34 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment