├── .gitignore ├── Puppetfile ├── README.md ├── Vagrantfile ├── architectures ├── hiera_only │ ├── hiera-vagrant.yaml │ ├── hiera.yaml │ ├── hieradata │ │ ├── Debian.eyaml │ │ ├── RedHat.eyaml │ │ ├── common.eyaml │ │ ├── env │ │ │ ├── devel.eyaml │ │ │ ├── prod.eyaml │ │ │ ├── staging.eyaml │ │ │ └── test.eyaml │ │ ├── role │ │ │ ├── db.eyaml │ │ │ ├── el.eyaml │ │ │ ├── lb.eyaml │ │ │ ├── log.eyaml │ │ │ ├── monitor.eyaml │ │ │ ├── puppet.eyaml │ │ │ ├── puppetdb.eyaml │ │ │ └── web.eyaml │ │ └── zones │ │ │ └── it.eyaml │ └── manifests │ │ └── site.pp ├── nodeless │ ├── README.md │ ├── hiera-vagrant.yaml │ ├── hiera.yaml │ ├── hieradata │ │ ├── common.eyaml │ │ ├── env │ │ │ ├── devel.eyaml │ │ │ ├── prod.eyaml │ │ │ ├── staging.eyaml │ │ │ └── test.eyaml │ │ ├── role │ │ │ ├── db.eyaml │ │ │ ├── el.eyaml │ │ │ ├── lb.eyaml │ │ │ ├── log.eyaml │ │ │ ├── monitor.eyaml │ │ │ ├── puppet.eyaml │ │ │ ├── puppetdb.eyaml │ │ │ └── web.eyaml │ │ └── zones │ │ │ └── it.eyaml │ ├── manifests │ │ └── site.pp │ └── site │ │ └── site │ │ └── manifests │ │ ├── debug.pp │ │ ├── general.pp │ │ ├── init.pp │ │ ├── minimal.pp │ │ └── roles │ │ ├── db.pp │ │ ├── el.pp │ │ ├── lb.pp │ │ ├── log.pp │ │ ├── mon.pp │ │ ├── puppet.pp │ │ └── web.pp └── nodes_inheritance │ ├── README.md │ ├── hiera-vagrant.yaml │ ├── hiera.yaml │ ├── hieradata │ └── common.eyaml │ ├── manifests │ └── site.pp │ └── site │ └── site │ └── manifests │ ├── debug.pp │ ├── general.pp │ ├── init.pp │ └── roles │ ├── db.pp │ ├── el.pp │ ├── lb.pp │ ├── log.pp │ ├── mon.pp │ ├── puppet.pp │ └── web.pp ├── bin ├── dist.sh ├── setup-debian.sh ├── setup-envpuppet.sh ├── setup-puppetmaster.sh ├── setup-redhat.sh └── view.sh ├── keys ├── private_key.pkcs7.pem └── public_key.pkcs7.pem ├── parc ├── r10k.yaml └── samples ├── 01_essentials └── nodes.pp ├── 09_scaling ├── config.ru ├── passenger_setup.pp └── puppetmaster.conf ├── 11_beyondsystem ├── devices.conf └── nodes.pp └── 12_futuretests ├── array_concatenate.pp ├── array_last.pp ├── arrays.pp ├── assert.pp ├── colons.pp ├── file.pp ├── hash_merge.pp ├── heredoc.pp ├── lambdas.pp ├── lambdas2.pp ├── lambdas3.pp ├── numbers.pp └── values_at.pp /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | .librarian 3 | .tmp/ 4 | /modules 5 | /Puppetfile.lock 6 | README.architecture.md 7 | /site 8 | /hieradata 9 | /manifests 10 | hiera.yaml 11 | hiera-vagrant.yaml 12 | -------------------------------------------------------------------------------- /Puppetfile: -------------------------------------------------------------------------------- 1 | forge "http://forge.puppetlabs.com" 2 | 3 | mod 'puppetlabs/stdlib' 4 | mod 'puppetlabs/concat' 5 | mod 'puppetlabs/apache' 6 | mod 'puppetlabs/puppetdb' 7 | mod 'puppetlabs/postgresql' 8 | mod 'puppetlabs/inifile' 9 | 10 | mod 'dalen/puppetdbquery' 11 | mod 'example42/puppi' 12 | mod 'example42/stdmod' 13 | 14 | mod 'example42/hosts' 15 | mod 'example42/puppet' 16 | mod 'example42/timezone' 17 | mod 'example42/openssh' 18 | mod 'example42/resolver' 19 | mod 'example42/monitor' 20 | mod 'example42/yum' 21 | mod 'example42/apt' 22 | mod 'example42/java' 23 | mod 'example42/tomcat' 24 | mod 'example42/jboss' 25 | mod 'example42/haproxy' 26 | mod 'example42/elasticsearch' 27 | mod 'example42/kibana' 28 | mod 'example42/logstash' 29 | mod 'example42/rsyslog' 30 | mod 'example42/mysql' 31 | mod 'example42/nagios' 32 | mod 'example42/php' 33 | 34 | mod "example42/stack", 35 | :git => "git://github.com/example42/puppet-stack.git" 36 | 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deprecation notice 2 | 3 | This repo is no longer maintained. 4 | 5 | Check [example42 control-repo](https://github.com/example42/control-repo) for updated works. 6 | 7 | 8 | # Puppet Architectures 9 | 10 | This repository contains sample Puppet architecture layouts that can be tested in a Vagrant environment. 11 | 12 | Consider it as a live reference, mostly oriented to show different usage patterns on how code and data can be managed in Puppet architectures. 13 | 14 | This is an ongoing work in progress, not all combinations of architectures, machine types and Linux distributions have been tested, and new problems might arise with future Puppet and Vagrant versions. 15 | 16 | 17 | ## Installation 18 | 19 | This is basically a multi VM Vagrant environment where you can test different Puppet setups. 20 | 21 | The usual vagrant commands apply. Type ```vagrant help``` for Vagrant commands. 22 | 23 | Different architectures examples can be installed with the ```parc``` script. 24 | 25 | Needed software: 26 | - [Puppet](http://www.puppetlabs.com/) 27 | - [VirtualBox](https://www.virtualbox.org/) 28 | - [Vagrant](http://www.vagrantup.com/) 29 | - [Librarian Puppet](http://librarian-puppet.com/) 30 | - [Git](http://git-scm.com/) 31 | - Plugin: [vagrant-cachier](http://fgrehm.viewdocs.io/vagrant-cachier) 32 | This is Required. Can be installed with: vagrant plugin install vagrant-cachier 33 | - Plugin: [vagrant-vbguest](https://github.com/dotless-de/vagrant-vbguest) (Optional) 34 | This is Optional. Can be installed with: vagrant plugin install vagrant-vbguest 35 | 36 | Once you have these tools installed you can setup the environment with the architecture layout you prefer. 37 | 38 | To list the available architectures layout samples: 39 | 40 | ./parc list 41 | 42 | To install one architecture layout (here: 'nodeless'): 43 | 44 | ./parc install nodeless 45 | 46 | To list the available Vagrant VMs: 47 | 48 | vagrant list 49 | 50 | To start one VM (here: web01) Note that the first time you do it it may take some time to download the Vagrant box from the net : 51 | 52 | vagrant up web01 53 | 54 | To start all the VMs (Warning: This might consume a lot of resources for your system) : 55 | 56 | vagrant up 57 | 58 | For help on Vagrant usage: 59 | 60 | vagrant help 61 | 62 | 63 | ## Understanding Vagrant and the directory layout 64 | 65 | The most important contents of this repository are: 66 | 67 | Puppetfile # The configuration file for librarian-puppet and r10k. 68 | # It contains the list of modules to install in the modules/ dir 69 | 70 | Vagrantfile # The Vagrant configuration file. Find below info on how to customize it. 71 | 72 | architectures # A directory that contains different sample Puppet architectures 73 | 74 | bin # Directory with scripts used by Vagrant during provisioning and other tools 75 | 76 | keys # Directory that contains the hiera-eyaml keys to encrypt data. 77 | 78 | parc # Script that installs a new architecture, changing links in the main directory. 79 | # It creates links to files in the architectures/$linked_architecture/ directory 80 | 81 | manifests # Directory that contains the manifests used by Vagrant 82 | # Link to -> architectures/$linked_architecture/manifests 83 | 84 | modules # Directory that contains the public shared modules. 85 | # As installed by librarian-puppet or r10k 86 | 87 | site # Directory that contains custom, site modules. 88 | # Link to -> architectures/$linked_architecture/site 89 | 90 | hieradata # The directory that contains Hiera's data, organized as defined in hiera.yaml 91 | # Link to -> architectures/$linked_architecture/hieradata 92 | 93 | hiera-vagrant.yaml # The Hiera file used by Vagrant during Puppet provisioning in apply mode. 94 | # Link to -> architectures/$linked_architecture/hiera-vagrant.yaml 95 | 96 | hiera.yaml # The Hiera file used on the Master, when provisioning in agent mode. 97 | # Link to -> architectures/$linked_architecture/hiera.yaml 98 | 99 | r10k.yaml # Sample configuration file for r10k 100 | 101 | samples # Directory containing various sample files. Related to specific book chapters 102 | 103 | 104 | ## Customizing the Vagrantfile 105 | 106 | The Vagrantfile provided in this repository can be customized in various ways. 107 | 108 | Open it and check is contents. At its beginning you can set: 109 | 110 | The default OS to use on your VMs. You can choose any name form the 'boxes' list you see later in the Vagrantfile (Note: Tests were done mostly with Centos6_64 and Ubuntu1204_64: 111 | 112 | default_os = 'Centos64_64' 113 | 114 | The domain to use for all your nodes: 115 | 116 | domain = 'example42.com' 117 | 118 | How much RAM to allocate for each VM by default (can be overridden per node): 119 | 120 | default_ram = '256' 121 | 122 | How many Vrtual CPUs to allocate for each VM (can be overridden per node) 123 | 124 | default_cpu = '1' 125 | 126 | You can also change the VM available under Vagrant, editing the 'nodes' hash, for each node you can set RAM, CPU and puppet provisioning mode (note that ```puppetmode => agent``` requires the puppet node to be configured and running correctly as Puppet Master) 127 | 128 | { :hostname => 'my_node', :ip => '10.42.42.10', :puppetmode => 'apply', ram: '515', cpu: '2' }, 129 | 130 | You can update or modify the Vagrant boxes to use, editing the ```boxes``` hash. You can set the base url, the local name, and the breed, which is used to provide different setup scripts for different kind of distributions. Check the line: 131 | 132 | config.vm.provision "shell", path: 'bin/setup-' + boxes[default_os.to_sym][:breed] + '.sh' 133 | 134 | 135 | :Centos64_64 => { 136 | :box => 'centos-64-x64-vbox4210', 137 | :box_url => 'http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box', 138 | :breed => 'redhat' 139 | }, 140 | 141 | The puppet version to install on the nodes. Various options are available: 142 | - '```original```': Keep the Puppet version provided in the Vagrant box 143 | - '```latest```': Install latest Puppet version from PuppetLabs repos 144 | - '```x.y.z-k```': Install a specific version from PuppetLabs repos 145 | 146 | puppetversion = '3.5.1-1' 147 | 148 | You can change the Puppet options to test future parser or enable debugging options: 149 | 150 | puppet.options = [ 151 | '--verbose', 152 | '--report', 153 | '--show_diff', 154 | '--pluginsync', 155 | '--summarize', 156 | # '--evaltrace', 157 | # '--debug', 158 | # '--parser future', 159 | ] 160 | 161 | 162 | ## Possible issues 163 | 164 | Many, many things can go wrong in an open and relatively complex setup like this. 165 | 166 | Many elements are involved: 167 | - Correct setup of Vagrant and dependent software on your machine 168 | - Availability of the Vagrant base boxes and their compatibility with your Virtual Box version (for this the vbguest plugin can help) 169 | - The installed Puppet version might not be compatible with the used modules (especially if you apply the ```--parser future``` option) 170 | - The sample architectures might not have all the correct settings for all the nodes' roles 171 | - The used OS, depending on the used Vagrant box might not be fully supported in all the combinations 172 | - Many more or less arcane or untested conditions 173 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # Based on https://github.com/patrickdlee/vagrant-examples/blob/master/example7/Vagrantfile 2 | 3 | # Select the OS you want to use (see boxes list below) 4 | #default_os = 'Centos64_64' 5 | default_os = 'Ubuntu1204_64' 6 | 7 | # Define your domain 8 | domain = 'example42.com' 9 | 10 | # Default ram (can be overriden per node) 11 | default_ram = '256' 12 | 13 | # Default number of cpu (can be overriden per node) 14 | default_cpu = '1' 15 | 16 | # Default puppetmode (How Puppet is run: agent, needs the puppet VM running, apply (default) is masterless) 17 | mode = 'apply' 18 | 19 | # Puppet version to install: 20 | # 'original': As provided in the box 21 | # 'latest': Installed from PuppetLabs repos 22 | # 'x.y.z-k': Specific version, installed from PuppetLabs repos 23 | puppetversion = '3.5.1-1' 24 | 25 | # Nodes list 26 | nodes = [ 27 | { :hostname => 'puppet', :ip => '10.42.42.10', :puppetmode => 'apply', ram: '515', cpu: '2' }, 28 | { :hostname => 'lb01', :ip => '10.42.42.91', :puppetmode => mode }, 29 | { :hostname => 'web01', :ip => '10.42.42.101', :puppetmode => mode }, 30 | { :hostname => 'web02', :ip => '10.42.42.102', :puppetmode => mode }, 31 | { :hostname => 'db01', :ip => '10.42.42.141', :puppetmode => mode , ram: '512' }, 32 | { :hostname => 'el01', :ip => '10.42.42.151', :puppetmode => mode }, 33 | { :hostname => 'log', :ip => '10.42.42.15', :puppetmode => mode }, 34 | { :hostname => 'mon', :ip => '10.42.42.16', :puppetmode => mode }, 35 | ] 36 | 37 | # Boxes available 38 | boxes = { 39 | :Centos64_64 => { :box => 'centos-64-x64-vbox4210', :box_url => 'http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box', :breed => 'redhat' }, 40 | :Centos59_64 => { :box => 'centos-59-x64-vbox4210', :box_url => 'http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210.box', :breed => 'redhat' }, 41 | :Ubuntu1404_64 => { :box => 'trusty-server-cloudimg-amd64-vagrant-disk1.box', :box_url => 'https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box', :breed => 'debian' }, 42 | :Ubuntu1204_64 => { :box => 'ubuntu-server-12042-x64-vbox4210', :box_url => 'http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210.box', :breed => 'debian' }, 43 | :Ubuntu1004_64 => { :box => 'ubuntu-server-10044-x64-vbox4210', :box_url => 'http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210.box', :breed => 'debian' }, 44 | :Debian7_64 => { :box => 'debian-70rc1-x64-vbox4210', :box_url => 'http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210.box', :breed => 'debian' }, 45 | :Debian6_64 => { :box => 'debian-607-x64-vbox4210', :box_url => 'http://puppet-vagrant-boxes.puppetlabs.com/debian-607-x64-vbox4210.box', :breed => 'debian' }, 46 | :Suse11_64 => { :box => 'sles-11sp1-x64-vbox4210', :box_url => 'http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210.box', :breed => 'suse' }, 47 | } 48 | 49 | # Vagrant configuration 50 | Vagrant.configure("2") do |config| 51 | 52 | # Cache plugin 53 | config.cache.auto_detect = true 54 | 55 | # Shell provisioner, to setup minimal conditions for Puppet provisioning 56 | config.vm.provision "shell", path: 'bin/setup-' + boxes[default_os.to_sym][:breed] + '.sh', args: puppetversion 57 | 58 | # See https://github.com/mitchellh/vagrant/issues/1673 59 | config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" 60 | 61 | # Nodes configuration 62 | nodes.each do |node| 63 | 64 | if node[:hostname] == 'puppet' 65 | # config.vm.provision "shell", path: 'bin/setup-puppetmaster.sh' 66 | end 67 | 68 | config.vm.define node[:hostname] do |node_config| 69 | node_config.vm.box = boxes[default_os.to_sym][:box] 70 | node_config.vm.box_url = boxes[default_os.to_sym][:box_url] 71 | node_config.vm.host_name = node[:hostname] + '.' + domain 72 | node_config.vm.network :private_network, ip: node[:ip] if node[:ip] 73 | 74 | if node[:forwards] 75 | node[:forwards].each do |from,to| 76 | node_config.vm.forward_port from, to 77 | end 78 | end 79 | 80 | memory = node[:ram] ? node[:ram] : default_ram ; 81 | cpu = node[:cpu] ? node[:cpu] : default_cpu ; 82 | node_config.vm.provider "virtualbox" do |v| 83 | v.customize [ 'modifyvm', :id, '--name', node[:hostname], '--memory', memory.to_s ] 84 | v.customize [ 'modifyvm', :id, '--cpus', cpu.to_s ] 85 | v.customize [ 'setextradata', :id, 'VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root', '1'] 86 | end 87 | end 88 | end 89 | 90 | # Puppet provisioner configuration 91 | config.vm.provision :puppet do |puppet| 92 | puppet.hiera_config_path = 'hiera-vagrant.yaml' 93 | puppet.working_directory = '/vagrant' 94 | puppet.manifests_path = 'manifests' 95 | puppet.manifest_file = 'site.pp' 96 | puppet.module_path = [ 'modules' , 'site' ] 97 | # puppet.puppet_server = 'puppet01' + domain if nodes[:puppetmode] == 'agent' 98 | 99 | puppet.options = [ 100 | '--verbose', 101 | '--report', 102 | '--show_diff', 103 | '--pluginsync', 104 | '--summarize', 105 | # '--evaltrace', 106 | # '--debug', 107 | # '--parser future', 108 | ] 109 | end 110 | end 111 | 112 | -------------------------------------------------------------------------------- /architectures/hiera_only/hiera-vagrant.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | :backends: 3 | - eyaml 4 | - file 5 | 6 | :hierarchy: 7 | - "nodes/%{fqdn}" 8 | - "role/%{role}_%{env}" 9 | - "role/%{role}" 10 | - common 11 | 12 | :eyaml: 13 | :datadir: /vagrant/hieradata 14 | :pkcs7_private_key: /vagrant/keys/private_key.pkcs7.pem 15 | :pkcs7_public_key: /vagrant/keys/public_key.pkcs7.pem 16 | -------------------------------------------------------------------------------- /architectures/hiera_only/hiera.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | :backends: 3 | - eyaml 4 | - file 5 | 6 | :hierarchy: 7 | - "nodes/%{fqdn}" 8 | - "role/%{role}_%{env}" 9 | - "role/%{role}" 10 | - "%{osfamily}" 11 | - common 12 | 13 | :eyaml: 14 | :datadir: /etc/puppet/hieradata 15 | :pkcs7_private_key: /etc/puppet/keys/private_key.pkcs7.pem 16 | :pkcs7_public_key: /etc/puppet/keys/public_key.pkcs7.pem 17 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/Debian.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | classes: 4 | - apt 5 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/RedHat.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | classes: 4 | - yum 5 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/common.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Common classes on all nodes 4 | classes: 5 | - puppet 6 | - openssh 7 | - timezone 8 | - resolver 9 | - stack::logstash 10 | 11 | # General Settings 12 | timezone::timezone: 'Europe/Rome' 13 | puppet::server: 'puppet01' 14 | 15 | resolver::dns_servers: 16 | - 8.8.8.8 17 | - 8.8.4.4 18 | 19 | # LogStash stack 20 | stack::logstash::syslog_server: '10.42.42.15' 21 | stack::logstash::elasticsearch_server: '10.42.42.151' 22 | stack::logstash::install_syslog: true 23 | 24 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/env/devel.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/env/prod.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/env/staging.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/env/test.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/role/db.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/role/el.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | stack::logstash::install_elasticsearch: true 3 | 4 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/role/lb.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/role/log.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | stack::logstash::install_logstash: true 3 | 4 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/role/monitor.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/role/puppet.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/role/puppetdb.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/role/web.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | stack::logstash::install_kibana: true 3 | 4 | -------------------------------------------------------------------------------- /architectures/hiera_only/hieradata/zones/it.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | timezone::timezone: 'Europe/Rome' 3 | -------------------------------------------------------------------------------- /architectures/hiera_only/manifests/site.pp: -------------------------------------------------------------------------------- 1 | # Debug mode. 2 | # $debug = true 3 | 4 | # Site wide resource defaults 5 | File { 6 | owner => 'root', 7 | group => 'root', 8 | mode => '0644', 9 | } 10 | 11 | Exec { 12 | path => '/bin:/usr/bin:/sbin:/usr/sbin', 13 | } 14 | 15 | # Hiera as ENC 16 | hiera_include('classes') 17 | -------------------------------------------------------------------------------- /architectures/nodeless/README.md: -------------------------------------------------------------------------------- 1 | # Sample NodeLess + Site module Puppet setup 2 | 3 | ## Structure 4 | 5 | - site.pp: 6 | - Sets identifying variables as top scope, according to hostname or other facts 7 | - Just includes the site class 8 | - No nodes declarations 9 | 10 | - Module site: 11 | - Provides local files and templates 12 | - Manages classes grouping logic (here a general + role classes) 13 | - Uses a stack::logstash class for logs management 14 | 15 | - Hiera: 16 | - Used for data. 17 | 18 | - ENC is not used. 19 | 20 | -------------------------------------------------------------------------------- /architectures/nodeless/hiera-vagrant.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | :backends: 3 | - eyaml 4 | 5 | :logger: 'noop' 6 | 7 | :hierarchy: 8 | - "nodes/%{fqdn}" 9 | - "role/%{role}_%{env}" 10 | - "role/%{role}" 11 | - common 12 | 13 | :eyaml: 14 | :datadir: '/vagrant/hieradata' 15 | :pkcs7_private_key: '/vagrant/keys/private_key.pkcs7.pem' 16 | :pkcs7_public_key: '/vagrant/keys/public_key.pkcs7.pem' 17 | -------------------------------------------------------------------------------- /architectures/nodeless/hiera.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | :backends: 3 | - eyaml 4 | 5 | :hierarchy: 6 | - nodes/%{fqdn} 7 | - role/%{role}_%{env} 8 | - role/%{role} 9 | - common 10 | 11 | :eyaml: 12 | :datadir: /etc/puppet/hieradata 13 | :pkcs7_private_key: /etc/puppet/keys/private_key.pkcs7.pem 14 | :pkcs7_public_key: /etc/puppet/keys/public_key.pkcs7.pem 15 | 16 | -------------------------------------------------------------------------------- /architectures/nodeless/hieradata/common.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # General Settings 4 | timezone::timezone: 'Europe/Rome' 5 | puppet::server: 'puppet01' 6 | 7 | resolver::dns_servers: 8 | - 8.8.8.8 9 | - 8.8.4.4 10 | 11 | # LogStash stack 12 | stack::logstash::syslog_server: '10.42.42.15' 13 | stack::logstash::elasticsearch_server: '10.42.42.151' 14 | stack::logstash::syslog_install: true 15 | 16 | -------------------------------------------------------------------------------- /architectures/nodeless/hieradata/env/devel.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | -------------------------------------------------------------------------------- /architectures/nodeless/hieradata/env/prod.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | -------------------------------------------------------------------------------- /architectures/nodeless/hieradata/env/staging.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | -------------------------------------------------------------------------------- /architectures/nodeless/hieradata/env/test.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | -------------------------------------------------------------------------------- /architectures/nodeless/hieradata/role/db.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | -------------------------------------------------------------------------------- /architectures/nodeless/hieradata/role/el.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | stack::logstash::elasticsearch_install: true 3 | 4 | -------------------------------------------------------------------------------- /architectures/nodeless/hieradata/role/lb.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | -------------------------------------------------------------------------------- /architectures/nodeless/hieradata/role/log.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | stack::logstash::logstash_install: true 3 | 4 | -------------------------------------------------------------------------------- /architectures/nodeless/hieradata/role/monitor.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | -------------------------------------------------------------------------------- /architectures/nodeless/hieradata/role/puppet.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | -------------------------------------------------------------------------------- /architectures/nodeless/hieradata/role/puppetdb.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | -------------------------------------------------------------------------------- /architectures/nodeless/hieradata/role/web.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | stack::logstash::kibana_install: true 3 | 4 | -------------------------------------------------------------------------------- /architectures/nodeless/hieradata/zones/it.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | timezone::timezone: 'Europe/Rome' 3 | -------------------------------------------------------------------------------- /architectures/nodeless/manifests/site.pp: -------------------------------------------------------------------------------- 1 | # Debug mode. 2 | # $debug = true 3 | 4 | # Site wide resource defaults 5 | File { 6 | owner => 'root', 7 | group => 'root', 8 | mode => '0644', 9 | } 10 | 11 | Exec { 12 | path => '/bin:/usr/bin:/sbin:/usr/sbin', 13 | } 14 | 15 | # Roles are based on hostnames 16 | case $::hostname { 17 | /^web/: { $role = 'web' } 18 | /^puppet/: { $role = 'puppet' } 19 | /^lb/: { $role = 'lb' } 20 | /^log/: { $role = 'log' } 21 | /^db/: { $role = 'db' } 22 | /^el/: { $role = 'el' } 23 | /^mon/: { $role = 'mon' } 24 | default: { } 25 | } 26 | 27 | # Env is based on hostname or (sub) domain 28 | if 'devel' in $::fqdn { $env = 'devel' } 29 | elsif 'test' in $::fqdn { $env = 'test' } 30 | elsif 'qa' in $::fqdn { $env = 'qa' } 31 | else { $end = 'prod' } 32 | 33 | 34 | # In site module is managed our grouping logic 35 | include site 36 | -------------------------------------------------------------------------------- /architectures/nodeless/site/site/manifests/debug.pp: -------------------------------------------------------------------------------- 1 | class site::debug { 2 | 3 | file { '/tmp/puppet.debug': 4 | ensure => present, 5 | loglevel => debug, # this is needed to avoid it being logged and reported on every run 6 | content => inline_template('<%= scope.to_yaml %>'), 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /architectures/nodeless/site/site/manifests/general.pp: -------------------------------------------------------------------------------- 1 | class site::general { 2 | 3 | include resolver 4 | include openssh 5 | include timezone 6 | include puppet 7 | include stack::logstash 8 | 9 | } 10 | -------------------------------------------------------------------------------- /architectures/nodeless/site/site/manifests/init.pp: -------------------------------------------------------------------------------- 1 | class site { 2 | 3 | include site::minimal 4 | 5 | include site::general 6 | 7 | if $::role { 8 | include "site::roles::${::role}" 9 | } 10 | 11 | if $debug { include site::debug } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /architectures/nodeless/site/site/manifests/minimal.pp: -------------------------------------------------------------------------------- 1 | class site::minimal { 2 | 3 | case $::osfamily { 4 | redhat: { 5 | # include yum::repo::epel 6 | # include yum::repo::puppetlabs 7 | package { 'redhat-lsb': ensure => present } 8 | } 9 | debian: { 10 | # include apt::repo::puppetlabs 11 | package { 'lsb-release': ensure => present } 12 | } 13 | suse: { 14 | package { 'lsb': ensure => present } 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /architectures/nodeless/site/site/manifests/roles/db.pp: -------------------------------------------------------------------------------- 1 | class site::roles::db { 2 | include mysql 3 | } 4 | -------------------------------------------------------------------------------- /architectures/nodeless/site/site/manifests/roles/el.pp: -------------------------------------------------------------------------------- 1 | class site::roles::el { 2 | 3 | # Elastic search managed via stack 4 | # class { '::elasticsearch': 5 | # } 6 | 7 | } 8 | -------------------------------------------------------------------------------- /architectures/nodeless/site/site/manifests/roles/lb.pp: -------------------------------------------------------------------------------- 1 | class site::roles::lb { 2 | class { '::haproxy': 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /architectures/nodeless/site/site/manifests/roles/log.pp: -------------------------------------------------------------------------------- 1 | class site::roles::log { 2 | # Logstash installed via stack parameters 3 | } 4 | -------------------------------------------------------------------------------- /architectures/nodeless/site/site/manifests/roles/mon.pp: -------------------------------------------------------------------------------- 1 | class site::roles::mon { 2 | include nagios 3 | } 4 | -------------------------------------------------------------------------------- /architectures/nodeless/site/site/manifests/roles/puppet.pp: -------------------------------------------------------------------------------- 1 | class site::roles::puppet { 2 | class { '::puppetdb': 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /architectures/nodeless/site/site/manifests/roles/web.pp: -------------------------------------------------------------------------------- 1 | class site::roles::web { 2 | include php 3 | } 4 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/README.md: -------------------------------------------------------------------------------- 1 | = Sample Nodes Inheritances + Site module Puppet setup 2 | 3 | This a sample setup based on nodes inheritance. 4 | 5 | == Structure: 6 | 7 | - site.pp: 8 | -- Sets identifying variables via nodes inheritance 9 | -- Includes the site class in each node 10 | 11 | - Module site: 12 | -- Provides local files and templates 13 | -- Manages classes grouping logic (here a general + role classes) 14 | -- Uses explicit class declarations with parameters style 15 | 16 | - Hiera is not used. 17 | - ENC is not used. 18 | 19 | == Alternatives 20 | 21 | - Data moved to Hiera and no class declarations with parameters style in site module 22 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/hiera-vagrant.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | :backends: 3 | - eyaml 4 | 5 | :hierarchy: 6 | - common 7 | 8 | :eyaml: 9 | :datadir: /vagrant/hieradata 10 | :pkcs7_private_key: /vagrant/keys/private_key.pkcs7.pem 11 | :pkcs7_public_key: /vagrant/keys/public_key.pkcs7.pem 12 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/hiera.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | :backends: 3 | - eyaml 4 | 5 | :hierarchy: 6 | - common 7 | 8 | :eyaml: 9 | :datadir: /etc/puppet/hieradata 10 | :pkcs7_private_key: /etc/puppet/keys/private_key.pkcs7.pem 11 | :pkcs7_public_key: /etc/puppet/keys/public_key.pkcs7.pem 12 | 13 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/hieradata/common.eyaml: -------------------------------------------------------------------------------- 1 | --- 2 | :nodata: here 3 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/manifests/site.pp: -------------------------------------------------------------------------------- 1 | # Debug mode. 2 | # $debug = true 3 | 4 | # Site wide resource defaults 5 | File { 6 | owner => 'root', 7 | group => 'root', 8 | mode => '0644', 9 | } 10 | 11 | Exec { 12 | path => '/bin:/usr/bin:/sbin:/usr/sbin', 13 | } 14 | 15 | # Default node 16 | node default { 17 | $role = 'default' 18 | 19 | # Infrastructure parameters ( May stay here and be managed by inheritance or be set in site module) 20 | $dns_servers = [ '8.8.8.8' , '8.8.4.4' ] 21 | $timezone = 'Europe/Rome' 22 | } 23 | 24 | # Environments 25 | node prod inherits default { 26 | $env = 'prod' 27 | } 28 | node qa inherits default { 29 | $env = 'qa' 30 | } 31 | node dev inherits default { 32 | $env = 'dev' 33 | } 34 | node test inherits default { 35 | $env = 'test' 36 | } 37 | 38 | # Nodes 39 | node /^web\d+\.example42\.com$/ inherits prod { 40 | $role = 'web' 41 | include site 42 | } 43 | node 'puppet.example42.com' inherits prod { 44 | $role = 'puppet' 45 | include site 46 | } 47 | node /^lb\d+\.example42\.com$/ inherits prod { 48 | $role = 'lb' 49 | include site 50 | } 51 | node 'log.example42.com' inherits prod { 52 | $role = 'log' 53 | include site 54 | } 55 | node /^db\d+\.example42\.com$/ inherits prod { 56 | $role = 'db' 57 | include site 58 | } 59 | node /^el\d+\.example42\.com$/ inherits prod { 60 | $role = 'el' 61 | include site 62 | } 63 | node 'mon.example42.com' inherits prod { 64 | $role = 'mon' 65 | include site 66 | } 67 | 68 | # Sample test node 69 | node /^web\d+\.test\.example42\.com$/ inherits test { 70 | $role = 'web' 71 | include site 72 | } 73 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/site/site/manifests/debug.pp: -------------------------------------------------------------------------------- 1 | class site::debug { 2 | 3 | file { '/tmp/puppet.debug': 4 | ensure => present, 5 | loglevel => debug, # this is needed to avoid it being logged and reported on every run 6 | content => inline_template('<%= scope.to_yaml %>'), 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/site/site/manifests/general.pp: -------------------------------------------------------------------------------- 1 | class site::general { 2 | 3 | class { '::resolver': 4 | dns_servers => [ '8.8.8.8' , '8.8.4.4' ], 5 | } 6 | 7 | class { '::openssh': } 8 | 9 | class { '::timezone': 10 | timezone => 'Europe/Rome', 11 | } 12 | 13 | class { '::puppet': 14 | server => 'puppet', 15 | } 16 | 17 | class { '::stack::logstash': 18 | syslog_server => '10.42.42.15', 19 | elasticsearch_server => '10.42.42.151', 20 | syslog_install => true, 21 | logstash_install => $::role ? { 22 | 'log' => true, 23 | default => false, 24 | }, 25 | kibana_install => $::role ? { 26 | 'web' => true, 27 | default => false, 28 | }, 29 | elasticsearch_install => $::role ? { 30 | 'el' => true, 31 | default => false, 32 | }, 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/site/site/manifests/init.pp: -------------------------------------------------------------------------------- 1 | class site { 2 | 3 | include site::general 4 | 5 | if $::role { 6 | include "site::roles::${::role}" 7 | } 8 | 9 | if $debug { include site::debug } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/site/site/manifests/roles/db.pp: -------------------------------------------------------------------------------- 1 | class site::roles::db { 2 | class { '::mysql': 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/site/site/manifests/roles/el.pp: -------------------------------------------------------------------------------- 1 | class site::roles::el { 2 | class { '::elasticsearch': 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/site/site/manifests/roles/lb.pp: -------------------------------------------------------------------------------- 1 | class site::roles::lb { 2 | class { '::haproxy': 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/site/site/manifests/roles/log.pp: -------------------------------------------------------------------------------- 1 | class site::roles::log { 2 | class { '::logstash': 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/site/site/manifests/roles/mon.pp: -------------------------------------------------------------------------------- 1 | class site::roles::mon { 2 | class { '::nagios': 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/site/site/manifests/roles/puppet.pp: -------------------------------------------------------------------------------- 1 | class site::roles::puppet { 2 | class { '::puppetdb': 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /architectures/nodes_inheritance/site/site/manifests/roles/web.pp: -------------------------------------------------------------------------------- 1 | class site::roles::web { 2 | class { '::apache': 3 | } 4 | class { '::php': 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /bin/dist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source=$1 3 | 4 | function die(){ 5 | echo $1 6 | exit 1 7 | } 8 | 9 | [ $1 ] || die "Provide the file or dir to copy to all the architectures" 10 | [ -d './architectures' ] || die "Run this command from the puppet-arhitectures basedir" 11 | [ -f "./$source" ] || die "Can't find $source" 12 | 13 | for a in $(ls -1 architectures) ; do 14 | echo "Copying $source to architectures/$a/$source" 15 | cp -a $source architectures/$a/$source 16 | done 17 | -------------------------------------------------------------------------------- /bin/setup-debian.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd /root 4 | case "$1" in 5 | original) puppetsuffix='' ;; 6 | latest) puppetsuffix='' ;; 7 | *) puppetsuffix="=${1}puppetlabs1" ;; 8 | esac 9 | 10 | if [ "x$1" != "xoriginal" ] ; then 11 | if [ ! -f puppetlabs-release-precise.deb ] ; then 12 | echo "## Installing Puppetlabs repository" 13 | wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb >/dev/null 2>&1 14 | dpkg -i puppetlabs-release-precise.deb >/dev/null 2>&1 15 | apt-get update >/dev/null 2>&1 16 | fi 17 | fi 18 | 19 | echo "## Installing Puppet and its dependencies" 20 | dpkg -s puppet >/dev/null 2>&1 || apt-get update >/dev/null 2>&1 ; apt-get install puppet$puppetsuffix puppet-common$puppetsuffix -y >/dev/null 2>&1 21 | dpkg -s rubygems >/dev/null 2>&1 || apt-get install rubygems -y >/dev/null 2>&1 22 | dpkg -s git >/dev/null 2>&1 || apt-get install git -y >/dev/null 2>&1 23 | 24 | gem list | grep hiera-file >/dev/null 2>&1 25 | if [ "x$?" == "x1" ] ; then 26 | gem install --no-ri --no-rdoc hiera-file 27 | fi 28 | 29 | gem list | grep hiera-eyaml >/dev/null 2>&1 30 | if [ "x$?" == "x1" ] ; then 31 | gem install --no-ri --no-rdoc hiera-eyaml 32 | fi 33 | 34 | puppet resource host puppet ip=10.42.42.10 >/dev/null 2>&1 35 | 36 | -------------------------------------------------------------------------------- /bin/setup-envpuppet.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | puppet_version='3.0.2' 4 | facter_version='1.6.17' 5 | hiera_version='1.3.1' 6 | 7 | useradd puppet 8 | 9 | cd /usr/src && wget https://raw.github.com/puppetlabs/puppet/master/ext/envpuppet 10 | cd /usr/src && git clone git://github.com/puppetlabs/puppet.git 11 | cd /usr/src && git clone git://github.com/puppetlabs/facter.git 12 | cd /usr/src && git clone git://github.com/puppetlabs/hiera.git 13 | 14 | cd /usr/src/puppet && git checkout tags/${puppet_version} 15 | cd /usr/src/facter && git checkout tags/${facter_version} 16 | cd /usr/src/hiera && git checkout tags/${hiera_version} 17 | 18 | echo '/usr/src/envpuppet puppet $@' > /bin/puppet 19 | echo '/usr/src/envpuppet facter $@' > /bin/facter 20 | echo 'export ENVPUPPET_BASEDIR=/usr/src/' >> /etc/profile 21 | 22 | chown vagrant:vagrant /usr/src/envpuppet 23 | chown vagrant:vagrant /bin/puppet 24 | chown vagrant:vagrant /bin/facter 25 | chown -R vagrant:vagrant /usr/src/puppet 26 | chown -R vagrant:vagrant /usr/src/facter 27 | 28 | chmod 751 /usr/src/envpuppet 29 | chmod 751 /bin/puppet 30 | chmod 751 /bin/facter 31 | 32 | # apt-get install -y augeas-tools augeas-lenses libaugeas-ruby 33 | # gem install hiera hiera-puppet --no-ri --no-rdoc 34 | 35 | gem list | grep hiera-file > /dev/null 36 | if [ "x$?" == "x1" ] ; then 37 | gem install hiera-file 38 | fi 39 | 40 | gem list | grep hiera-eyaml > /dev/null 41 | if [ "x$?" == "x1" ] ; then 42 | gem install hiera-eyaml 43 | fi 44 | -------------------------------------------------------------------------------- /bin/setup-puppetmaster.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Based on https://github.com/gehel/vagrant-vms/blob/master/vagrant-puppetmaster/init.sh 3 | 4 | # Set here the default branch to use for first puppet apply 5 | default_branch='nodeless' 6 | DNS_DOMAIN='example42.com' 7 | DNS_ALT_NAMES="puppet01,puppet02,puppet01.${DNS_DOMAIN},puppet02.${DNS_DOMAIN}" 8 | 9 | 10 | puppet resource package git ensure=present allow_virtual=true 11 | puppet resource file /etc/puppet/modules ensure=/vagrant/modules force=true 12 | puppet resource file /etc/puppet/manifests ensure=/vagrant/manifests force=true 13 | puppet resource file /etc/puppet/hieradata ensure=/vagrant/hieradata force=true 14 | 15 | echo '## librarian-puppet deploy' 16 | export PATH=$PATH:/opt/ruby/bin 17 | 18 | gem list | grep librarian-puppet > /dev/null 19 | if [ "x$?" == "x1" ] ; then 20 | gem install librarian-puppet 21 | fi 22 | 23 | cd /vagrant ; librarian-puppet install 24 | 25 | # service puppetmaster stop 26 | 27 | echo '## CA setup' 28 | # Uncomment to clean up all certificate 29 | # puppet cert clean --all `hostname -f` 30 | [ -f /var/lib/puppet/ssl/ca/ca_pub.pem ] || puppet ca generate --dns-alt-names ${DNS_ALT_NAMES} puppet 31 | 32 | # service puppetmaster start 33 | # service puppetmaster stop 34 | 35 | echo '## puppet apply' 36 | puppet apply --modulepath=/vagrant/modules:/vagrant/site \ 37 | --hiera_config=/vagrant/hiera.yaml \ 38 | /vagrant/manifests/site.pp 39 | 40 | echo '## puppet agent' 41 | sleep 10 42 | puppet agent -t 43 | 44 | -------------------------------------------------------------------------------- /bin/setup-redhat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd /root 3 | 4 | case "$1" in 5 | original) puppetsuffix='' ;; 6 | latest) puppetsuffix='' ;; 7 | *) puppetsuffix="-${1}.el6" ;; 8 | esac 9 | 10 | echo "## Installing latest Puppet version and dependencies" 11 | 12 | if [ "x$1" != "xoriginal" ] ; then 13 | rpm -qa | grep puppetlabs-release >/dev/null 2>&1 14 | if [ "x$?" == "x1" ] ; then 15 | rpm -ivh https://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-7.noarch.rpm >/dev/null 2>&1 16 | fi 17 | fi 18 | 19 | rpm -qa | grep "^puppet${puppetsuffix}" >/dev/null 2>&1 20 | if [ "x$?" == "x1" ] ; then 21 | yum install -y puppet$puppetsuffix >/dev/null 2>&1 22 | fi 23 | 24 | rpm -qa | grep 'rubygems' >/dev/null 2>&1 25 | if [ "x$?" == "x1" ] ; then 26 | yum install -y rubygems >/dev/null 2>&1 27 | fi 28 | 29 | gem list | grep hiera-file >/dev/null 2>&1 30 | if [ "x$?" == "x1" ] ; then 31 | gem install --no-ri --no-rdoc hiera-file 32 | fi 33 | 34 | gem list | grep hiera-eyaml 2>&1>/dev/null 35 | if [ "x$?" == "x1" ] ; then 36 | gem install --no-ri --no-rdoc hiera-eyaml 37 | fi 38 | 39 | puppet resource host puppet ip=10.42.42.10 >/dev/null 2>&1 40 | 41 | -------------------------------------------------------------------------------- /bin/view.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source=$1 3 | 4 | function die(){ 5 | echo $1 6 | exit 1 7 | } 8 | 9 | [ $1 ] || die "Provide the file to show for all the architectures" 10 | [ -d './architectures' ] || die "Run this command from the puppet-architectures basedir" 11 | [ -f "./$source" ] || die "Can't find $source" 12 | 13 | for a in $(ls -1 architectures) ; do 14 | echo "## Showing $source to architectures/$a/$source" 15 | cat architectures/$a/$source 16 | done 17 | -------------------------------------------------------------------------------- /keys/private_key.pkcs7.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEogIBAAKCAQEA7pO1wdKhv2ZYOtm8BDuK8SrbDx9HyN5XP5BmVBIV1NKn3PJm 3 | 2BHet58/IJqQA08wmlVihGtszJBdzmv0Gj5eikCXLmAViXm6XLLdhMKyN7QswlG5 4 | BmZKiY5QBxAO48lrAc5LHt0m/nuNnlzChekdl05l7gwQYM8ea4Au4mqbZ3LibTQb 5 | 1BMkxA5WJdXEzRyldPqCkYK8Fjlk2Abf76mHsfKEvz5eo/9u0r1Q8RJ77LLxhNmP 6 | P+3vLRcmi+cbEuwg+gHdL9ce7W8XC4/Y5epaKPh8vySnJx7bNKY5UZ7szsryUfdt 7 | 80IF1RNljIgO3v2eHQeHggfXiHhmxBG6tXOY7wIDAQABAoIBACs8f7MJniCWxqSb 8 | sxQ9SjfcoWiDLbo8eSle3PydbnFsX9mN4I+F5Yv3gzRAbpr67f76PGltIoGMJEP1 9 | kn5zESUTAZL4/M42TkzgaX7W3f90Wqw4rUR4o0d8kApHobssVIU2QqzsPVXfRFIP 10 | 03z7O06heZ2DeDBjOMsYpuaHlXRQpx0bWX5FM7mcIwbUMs3uh3Gkl8DHzEUK/0E0 11 | HYbzB4YQ9YlwSBFabJwkKbJfspnuJB0/Q8qcSTqdq/n57r4SvqASg7e0lz8loGqk 12 | ubdG8+DmuAGV9vfOOghBVUkCcE5CFHcvtOWMJ7HV7BNpbPsLq62UmDOih+O7ZOdY 13 | RrfIPYECgYEA+jmEv01XHodSnJQdLgbcuMQUtRn8QpncHnTXzuECMkdDpcPJpTGb 14 | R2m8hBW6cF8MNN9NzRVIZT0x+Hp62wD2+3Yddz/zor2H8zuH5UfsqduPtvvGZLPM 15 | ZhStsZHlhgEgQM7nPYNGsJ+OccGbS4CIgzBQ6fy5uLzanmUhmmaXXkECgYEA9BVe 16 | pjqA7DQoXb+xAn/0PUzdEIklEds4C1iSONhTLPUSlvB3mgzWpqeD8JqQmqN4Q9Oe 17 | 61wGmeOtFT7A4N1l1rd9daU3znGf5BIiirZlxVetgtSiQFfWEkRCpMvzkdqRyFqP 18 | Htf63/9GiHd/wTmV6q5JS/na1jdstiQ96gh8iy8CgYADVkUI8BUbWR6m6+q/tGO5 19 | KxRDngcZNEgVN+Ww4ptO5Fhom4XS6Chz+VsEP+3ulbXp9phpBcGjZ/+Ems2MoiSp 20 | EdguwPGU2AY6Hi8fxafIVB9Eh3ML4MH3EouGdLWk5dryQlAfJ+MHc/lIVxalGR+4 21 | 8CoEFNS9O/eGaT7bekbGgQKBgHhQxFwqQHyuZSt5H1b9HbbN2baZ8+Tua5zkJwfQ 22 | Uoe5slUm6b3NEE4MCvSiLB+d7t14RkD8FuDqotnzGf5+BAIoZraEH5Mq3Ub+TXqU 23 | 2GvDgWsZR3VyFrrgXP2A72p5FB1vzlbE3gxmeC0ywo3LxgNtsAG8gsvPfE34ZXCk 24 | iEfPAoGAVd7BLYTcWTrg5HSuxePRiodZprxvEm4ZghcJ0cc+t4IIk/9XsW6Gp3UH 25 | gtmhuIGNidh+vKN5aJ6i7o4nDOjSU4X8wsNlN4ezeV/dyohDgZ5po6X6cafQkKSS 26 | 7CTtnmgE3EZcpOfG7bZGc8B+YczQCEJ6vtw9jPwmYX2xc6OP97I= 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /keys/public_key.pkcs7.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC2TCCAcGgAwIBAgIBADANBgkqhkiG9w0BAQUFADAAMCAXDTEzMTIwOTA4MzQw 3 | NFoYDzIwNjMxMTI3MDgzNDA0WjAAMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB 4 | CgKCAQEA7pO1wdKhv2ZYOtm8BDuK8SrbDx9HyN5XP5BmVBIV1NKn3PJm2BHet58/ 5 | IJqQA08wmlVihGtszJBdzmv0Gj5eikCXLmAViXm6XLLdhMKyN7QswlG5BmZKiY5Q 6 | BxAO48lrAc5LHt0m/nuNnlzChekdl05l7gwQYM8ea4Au4mqbZ3LibTQb1BMkxA5W 7 | JdXEzRyldPqCkYK8Fjlk2Abf76mHsfKEvz5eo/9u0r1Q8RJ77LLxhNmPP+3vLRcm 8 | i+cbEuwg+gHdL9ce7W8XC4/Y5epaKPh8vySnJx7bNKY5UZ7szsryUfdt80IF1RNl 9 | jIgO3v2eHQeHggfXiHhmxBG6tXOY7wIDAQABo1wwWjAPBgNVHRMBAf8EBTADAQH/ 10 | MB0GA1UdDgQWBBQht7yUqo1d+imoQUyRGnS/GW29YDAoBgNVHSMEITAfgBQht7yU 11 | qo1d+imoQUyRGnS/GW29YKEEpAIwAIIBADANBgkqhkiG9w0BAQUFAAOCAQEAQpU0 12 | pGPJL0IbcRblcDdvEyhNr1BN2ibVb9ESVr/0XSxWBULAq9BrdCXn1ReBSr2bXVqK 13 | fhh0EMh+Fq0xXYfDfM4d8TobnfstXGuY14Ch2+SVblPjUCHVEiT61+dL+iKmGnOt 14 | p5CjQR1twJtjY3TcmvxiVJcFALCg72yEggqJClAl6x9fk+0MpG9n2Jz/h1fi9PN3 15 | 7Jl/DlmaCJZ9t5A7+m8z/lzkJVrVPH7hTPp2Y/QKMf3PlnkSFWd1LkEVwXtY9acL 16 | pGfDS3a1Vyt/VagKlC9N7trGzhR2NXBh0Nd9p3R2VDYs3u5C5541aKYnRmg+I7R0 17 | tmxMObq4vBUjMsmPvQ== 18 | -----END CERTIFICATE----- 19 | -------------------------------------------------------------------------------- /parc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ( [ ! -f Vagrantfile ] || [ ! -d architectures ] ) ; then 4 | echo "Cant find Vagrantfile" 5 | echo "Change your cwd to your cloned puppet-architectures directory and then run ./parc" 6 | exit 1 7 | fi 8 | 9 | architecturedir='architectures' 10 | 11 | showhelp () { 12 | cat << EOF 13 | 14 | Play in Puppet Playground. 15 | 16 | This command manages the playground: Vagrantfile, modules/ and manifests/ 17 | 18 | Usage: parc [argument] 19 | parc status - Show status 20 | parc list - List the architectures available for symlinking 21 | parc install - Link the specified architecture 22 | 23 | See README for more details. 24 | EOF 25 | } 26 | 27 | SETCOLOR_NORMAL="echo -en \\033[0;39m" 28 | SETCOLOR_TITLE="echo -en \\033[0;35m" 29 | SETCOLOR_BOLD="echo -en \\033[0;1m" 30 | 31 | echo_title () { 32 | echo 33 | $SETCOLOR_BOLD ; echo $1 ; $SETCOLOR_NORMAL 34 | } 35 | 36 | ask_confirm () { 37 | cat << EOF 38 | Going to relink another architecture. 39 | Are you sure you want to continue (y/n)? 40 | EOF 41 | 42 | read answer 43 | [ "x$answer" == "xy" ] || exit 3 44 | } 45 | 46 | list_architecture() { 47 | echo_title "Available architectures for $0 install" 48 | ls -1 $architecturedir 49 | } 50 | 51 | install_architecture() { 52 | if [ -d "$(pwd)/${1}" ]; then 53 | clean 54 | echo_title "Installing $1" 55 | else 56 | echo_title "Architecture not found" 57 | list_architecture 58 | exit 1 59 | fi 60 | install_cmd="ln -sf" 61 | # install_cmd="cp -a" 62 | $install_cmd $1/manifests . 63 | $install_cmd $1/site . 64 | $install_cmd $1/hieradata . 65 | $install_cmd $1/README.md README.architecture.md 66 | $install_cmd $1/hiera-vagrant.yaml hiera-vagrant.yaml 67 | $install_cmd $1/hiera.yaml hiera.yaml 68 | # [ -f $1/Vagrantfile ] && $install_cmd $1/Vagrantfile Vagrantfile 69 | 70 | echo_title "Running librarian-puppet install" 71 | librarian-puppet install 72 | } 73 | 74 | clean() { 75 | ask_confirm 76 | rm hieradata >/dev/null 2>&1 77 | rm site >/dev/null 2>&1 78 | rm manifests >/dev/null 2>&1 79 | } 80 | 81 | clean_librarian() { 82 | echo_title "Executing librarian-puppet clean" 83 | librarian-puppet clean 84 | } 85 | 86 | status() { 87 | echo_title "Modules status (puppet module list --modulepath=modules/) " 88 | puppet module list --modulepath=modules/ 89 | 90 | echo_title "Current Vagrant directory" 91 | ls -l 92 | } 93 | 94 | while [ $# -gt 0 ]; do 95 | case "$1" in 96 | list) 97 | action=$1 98 | shift 99 | ;; 100 | status) 101 | action=$1 102 | shift 103 | ;; 104 | install) 105 | action=$1 106 | architecture=$2 107 | shift 2 108 | ;; 109 | *) 110 | showhelp 111 | exit 112 | ;; 113 | esac 114 | done 115 | 116 | case $action in 117 | list) list_architecture ;; 118 | install) install_architecture $architecturedir/$architecture ;; 119 | status) status ;; 120 | * ) showhelp ;; 121 | esac 122 | 123 | -------------------------------------------------------------------------------- /r10k.yaml: -------------------------------------------------------------------------------- 1 | :cachedir: '/var/cache/r10k' 2 | :sources: 3 | :site: 4 | remote: 'https://github.com/example42/puppet-architectures' 5 | basedir: '/etc/puppet/environments' 6 | -------------------------------------------------------------------------------- /samples/01_essentials/nodes.pp: -------------------------------------------------------------------------------- 1 | # Node with explicit resources 2 | node 'mysql.example.com' { 3 | package { 'mysql-server': 4 | ensure => present, 5 | } 6 | service { 'mysql': 7 | ensure => 'running', 8 | } 9 | } 10 | 11 | # Node where classes are included (as provided by the relevant modules) 12 | node 'web.example.com' { 13 | include common 14 | include apache 15 | } 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/09_scaling/config.ru: -------------------------------------------------------------------------------- 1 | # if puppet is not in your RUBYLIB: 2 | # $LOAD_PATH.unshift('/opt/puppet/lib') 3 | $0 = "master" 4 | # ARGV << "--debug" # Uncomment to debug 5 | ARGV << "--rack" 6 | ARGV << "--confdir" << "/etc/puppet" 7 | ARGV << "--vardir" << "/var/lib/puppet" 8 | require 'puppet/util/command_line' 9 | <% if @rubyversion[0..2].to_f >= 1.9 -%> 10 | # https://projects.puppetlabs.com/issues/20897 11 | Encoding.default_external = Encoding::UTF_8 12 | Encoding.default_internal = Encoding::UTF_8 13 | <% end -%> 14 | run Puppet::Util::CommandLine.new.execute 15 | 16 | -------------------------------------------------------------------------------- /samples/09_scaling/passenger_setup.pp: -------------------------------------------------------------------------------- 1 | # Passenger setup on RedHat 6 2 | # To test this manifest run, from the directory that contains this file, and the 3 | # used templates: 4 | # puppet apply -t passenger_setup.pp --templatedir ./ 5 | 6 | 7 | # Epel repo 8 | yumrepo { 'epel': 9 | mirrorlist => 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=$basearch', 10 | gpgcheck => 1, 11 | enabled => 1, 12 | gpgkey => 'https://fedoraproject.org/static/0608B895.txt', 13 | } -> 14 | 15 | # Passenger repo 16 | yumrepo { 'passenger': 17 | baseurl => 'http://passenger.stealthymonkeys.com/rhel/$releasever/$basearch', 18 | mirrorlist => 'http://passenger.stealthymonkeys.com/rhel/mirrors', 19 | enabled => 1, 20 | gpgkey => 'http://passenger.stealthymonkeys.com/RPM-GPG-KEY-stealthymonkeys.asc', 21 | } -> 22 | 23 | # Packages 24 | package { [ 'mod_passenger' , 'httpd' , 'mod_ssl' , 'rubygems']: 25 | ensure => present, 26 | } -> 27 | 28 | package { 'rack': 29 | ensure => present, 30 | provider => gem, 31 | } -> 32 | 33 | file { '/etc/httpd/conf.d/puppetmaster.conf': 34 | ensure => present, 35 | content => template('puppetmaster.conf'), 36 | } -> 37 | 38 | # Rack setup for Passenger 39 | file { ['/etc/puppet/rack','/etc/puppet/rack/public','/etc/puppet/rack/tmp']: 40 | ensure => directory, 41 | owner => 'puppet', 42 | group => 'puppet', 43 | } -> 44 | 45 | file { '/etc/puppet/rack/config.ru': 46 | ensure => present, 47 | content => template('config.ru'), 48 | owner => 'puppet', 49 | group => 'puppet', 50 | } -> 51 | 52 | service { 'puppetmaster': 53 | ensure => stopped, 54 | enable => false, 55 | } -> 56 | 57 | service { 'httpd': 58 | ensure => running, 59 | enable => true, 60 | require => Service['puppetmaster'], 61 | } 62 | -------------------------------------------------------------------------------- /samples/09_scaling/puppetmaster.conf: -------------------------------------------------------------------------------- 1 | # File Managed by Puppet 2 | 3 | PassengerHighPerformance on 4 | PassengerMaxPoolSize 12 5 | PassengerPoolIdleTime 1500 6 | PassengerStatThrottleRate 120 7 | RackAutoDetect On 8 | RailsAutoDetect Off 9 | 10 | Listen 8140 11 | 12 | SSLEngine on 13 | SSLProtocol -ALL +SSLv3 +TLSv1 14 | SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP 15 | SSLCertificateFile /var/lib/puppet/ssl/certs/<%= @fqdn %>.pem 16 | SSLCertificateKeyFile /var/lib/puppet/ssl/private_keys/<%= @fqdn %>.pem 17 | SSLCertificateChainFile /var/lib/puppet/ssl/certs/ca.pem 18 | SSLCACertificateFile /var/lib/puppet/ssl/certs/ca.pem 19 | # SSLCARevocationFile /var/lib/puppet/ssl/certs/ca_crl.prm 20 | SSLVerifyClient optional 21 | SSLVerifyDepth 1 22 | SSLOptions +StdEnvVars 23 | 24 | RequestHeader set X-SSL-Subject %{SSL_CLIENT_S_DN}e 25 | RequestHeader set X-Client-DN %{SSL_CLIENT_S_DN}e 26 | RequestHeader set X-Client-Verify %{SSL_CLIENT_VERIFY}e 27 | 28 | PassengerEnabled On 29 | DocumentRoot /etc/puppet/rack/public/ 30 | RackBaseURI / 31 | 32 | Options None 33 | AllowOverride None 34 | Order allow,deny 35 | allow from all 36 | 37 | 38 | ErrorLog /var/log/httpd/passenger-error.log 39 | CustomLog /var/log/httpd/passenger-access.log combined 40 | 41 | -------------------------------------------------------------------------------- /samples/11_beyondsystem/devices.conf: -------------------------------------------------------------------------------- 1 | # Sample devices.conf for puppet device command 2 | 3 | 4 | # Cisco IOS Devices - Native Puppet 5 | [switch01.example42.lan] 6 | type cisco 7 | url ssh://puppet:my_password@switch01.example42.lan/ 8 | 9 | [router01.example42.lan] 10 | type cisco 11 | url telnet://puppet:my_pass@router01.example42.lan/?enable=enablepassword 12 | 13 | 14 | # Cisco IOS devices - https://github.com/uniak/puppet-networkdevice 15 | [switch01.example42.lan] 16 | type cisco_ios 17 | url sshios://user:password@switch01.example42.lan:22/?$flags 18 | 19 | 20 | # F5 firewalls - https://github.com/puppetlabs/puppetlabs-f5 21 | [f5.example42.lan] 22 | type f5 23 | url https://username:password@f5.example42.lan/ 24 | 25 | 26 | # Google Compute Engine 27 | [example42] 28 | type gce 29 | url [/dev/null]:project_id 30 | 31 | 32 | # NetApp - https://forge.puppetlabs.com/fatmcgav/netapp 33 | [netapp.example42.lan] 34 | type netapp 35 | url https://root:password@netapp.example42.lan 36 | 37 | -------------------------------------------------------------------------------- /samples/11_beyondsystem/nodes.pp: -------------------------------------------------------------------------------- 1 | # Sample Nodes declarations for network devices 2 | 3 | # Juniper Network device 4 | # - https://github.com/puppetlabs/puppet-netdev-stdlib 5 | # - https://github.com/Juniper/puppet-netdev-stdlib-junos 6 | 7 | node 'switch02.example42.lan' { 8 | 9 | # A single etdev_devic resource must be present 10 | netdev_device { $hostname: } 11 | 12 | # Sample configuration of an interface 13 | netdev_interface { 'ge-0/0/0': 14 | admin => down, 15 | mtu => 2000, 16 | } 17 | 18 | # Sample configuration of a VLAN 19 | netdev_vlan { 'vlan102': 20 | vlan_id => '102', 21 | description => 'Public network', 22 | } 23 | 24 | # Configuration of an access port without VLAN tag 25 | netdev_l2_interface { 'ge-0/0/0': 26 | untagged_vlan => Red 27 | } 28 | 29 | # Configuration of a trunk port with multiple VLAN tags 30 | # And untagged packets go to 'native VLAN' 31 | netdev_l2_interface { 'xe-0/0/2': 32 | tagged_vlans => [ Red, Green, Blue ], 33 | untagged_vlan => Yellow 34 | } 35 | 36 | # Configuration of Link Aggregation ports (bonding) 37 | netdev_lag { 'ae0': 38 | links => [ 'ge-0/0/0', 'ge-1/0/0', 'ge-0/0/2', 'ge-1/0/2' ], 39 | lacp => active, 40 | minimum_links => 2 41 | } 42 | } 43 | 44 | 45 | # Cisco onePK 46 | # - http://puppetlabs.com/presentations/managing-cisco-devices-using-puppet 47 | node 'switch01.example42.lan' { 48 | # Definition of the Device, needed for each device 49 | cisco_device { 'switch01.example42.lan': 50 | ensure => present, 51 | } 52 | 53 | Configuration of a VLAN on an access interface 54 | cisco_interface { 'Ethernet1/5': 55 | switchport => access, 56 | access_vlan => 1000, 57 | } 58 | 59 | # Configuration of a VLAN 60 | cisco_vlan { '1000': 61 | ensure => present, 62 | vlan_name => 'DMZ', 63 | state => active, 64 | } 65 | } 66 | 67 | 68 | 69 | # VCenter (Windows) 70 | # - https://github.com/puppetlabs/puppetlabs-vcenter 71 | 72 | node 'vcenter.example42.com { 73 | class vcenter { 74 | media => 'e:\\', 75 | jvm_memory_option => 'M', 76 | } 77 | 78 | vc_folder { '/prod': 79 | ensure => present, 80 | } 81 | 82 | vc_datacenter { [ '/prod/uk', '/prod/it' ]: 83 | ensure => present, 84 | } 85 | 86 | vc_cluster { [ '/prod/uk/fe', '/prod/it/fe' ]: 87 | ensure => present, 88 | } 89 | 90 | vc_host { '10.42.20.11': 91 | ensure => 'present', 92 | username => 'root', 93 | password => 'password', 94 | tag => 'fe', 95 | } 96 | 97 | } 98 | 99 | 100 | -------------------------------------------------------------------------------- /samples/12_futuretests/array_concatenate.pp: -------------------------------------------------------------------------------- 1 | $users = ['al','ma'] 2 | $default_users = [ 'joe' ] 3 | $all_users = $users + $default_users 4 | 5 | $all_users.each |$user| { 6 | notice "User: $user" 7 | } 8 | -------------------------------------------------------------------------------- /samples/12_futuretests/array_last.pp: -------------------------------------------------------------------------------- 1 | [ 1,2,3 ] + [ 4,5 ] 2 | 3 | notice test 4 | -------------------------------------------------------------------------------- /samples/12_futuretests/arrays.pp: -------------------------------------------------------------------------------- 1 | $array_plus = [1,2,3] + [4,5,6] 2 | $array_append = [1,2,3] << [2,4] 3 | 4 | notice $array_plus 5 | notice $array_append 6 | 7 | -------------------------------------------------------------------------------- /samples/12_futuretests/assert.pp: -------------------------------------------------------------------------------- 1 | $country = [ 'it','uk'] 2 | assert_type(Array[2,2], $country) 3 | 4 | -------------------------------------------------------------------------------- /samples/12_futuretests/colons.pp: -------------------------------------------------------------------------------- 1 | $package_name = $service_name = 'httpd' 2 | notice $package_name 3 | notice $service_name 4 | 5 | -------------------------------------------------------------------------------- /samples/12_futuretests/file.pp: -------------------------------------------------------------------------------- 1 | $file_mode = 0755 2 | file { '/tmp/testmode': 3 | ensure => present, 4 | mode => $file_mode, 5 | } 6 | -------------------------------------------------------------------------------- /samples/12_futuretests/hash_merge.pp: -------------------------------------------------------------------------------- 1 | $config_hash = { 2 | doc_root => '/my_docs', 3 | } 4 | 5 | $config_default_hash = { 6 | servername => $::fqdn, 7 | doc_doot => '/docs', 8 | } 9 | 10 | $real_config_hash = $config_default_hash + $config_hash 11 | 12 | notice $real_config_hash 13 | -------------------------------------------------------------------------------- /samples/12_futuretests/heredoc.pp: -------------------------------------------------------------------------------- 1 | $my_content = @(DOC) 2 | This is a sample heredoc test. 3 | With "double quotes" and 'single quotes' happily cohexisting. 4 | New lines are obiously present: 5 | - and indentations 6 | | DOC 7 | 8 | notice $my_content 9 | -------------------------------------------------------------------------------- /samples/12_futuretests/lambdas.pp: -------------------------------------------------------------------------------- 1 | $sites = ['example42.com','lab42.it','google.com'] 2 | each($sites) |$my_site| { 3 | 4 | file { "/tmp/$my_site": 5 | ensure => present, 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /samples/12_futuretests/lambdas2.pp: -------------------------------------------------------------------------------- 1 | $names = ['fred','al'] 2 | $names.each |$user| { notice "User ${user} available on ${fqdn}"} 3 | -------------------------------------------------------------------------------- /samples/12_futuretests/lambdas3.pp: -------------------------------------------------------------------------------- 1 | 2 | 3 | $my_array = [ 'al' , 'joe' ] 4 | $my_array.each |$x| { notice "${x} is the array value" } 5 | $my_array.each |$index, $value| { 6 | notice "${index} is the array index (Starts from 0)" 7 | notice "${value} is the array value" 8 | } 9 | 10 | $my_hash = { name => 'al' , group => 'admins' } 11 | $my_hash.each |$x| { 12 | notice "${x[0]} is the hash key" 13 | notice "${x[1]} is the hash value" 14 | } 15 | $my_hash.each |$key, $value| { 16 | notice "${key} is the hash key" 17 | notice "${value} is the hashvalue" 18 | } 19 | -------------------------------------------------------------------------------- /samples/12_futuretests/numbers.pp: -------------------------------------------------------------------------------- 1 | $a = 0x0EE 2 | $b = 0778 3 | -------------------------------------------------------------------------------- /samples/12_futuretests/values_at.pp: -------------------------------------------------------------------------------- 1 | notice [one,two,three,four,five][1,3] 2 | $x = '123d' 3 | if $x =~ String[4,5] { notice $x } 4 | --------------------------------------------------------------------------------