├── .github └── FUNDING.yml ├── .gitignore ├── README.md ├── Vagrantfile └── examples ├── Dockerfile.hello ├── Dockerfile.nginx ├── Dockerfile.nginx.epp ├── Dockerfile.pbg-demo ├── Dockerfile.website.epp ├── Puppetfile.apache ├── Puppetfile.archive ├── Puppetfile.aws ├── Puppetfile.docker ├── Puppetfile.mysql ├── Puppetfile.ntp ├── Puppetfile.stdlib ├── aws_credentials.epp ├── aws_hiera.pp ├── aws_instance.pp ├── aws_sdk.pp ├── aws_vpc.pp ├── case.pp ├── cron.pp ├── date.sh ├── defined_resource_type.pp ├── dirname.pp ├── docker_absent.pp ├── docker_build_hello.pp ├── docker_build_nginx.pp ├── docker_image.pp ├── docker_install.pp ├── docker_mount.pp ├── docker_network.pp ├── docker_non_service.pp ├── docker_run.pp ├── docker_run_hello.pp ├── docker_run_many.pp ├── docker_run_nginx.pp ├── docker_template.pp ├── docker_volume.pp ├── docker_volume2.pp ├── docker_website.pp ├── empty.pp ├── epp_hiera.pp ├── epp_params.pp ├── exec.pp ├── exec_onlyif.pp ├── exec_refreshonly.pp ├── exec_user.pp ├── expression_boolean.pp ├── expression_numeric.pp ├── eyaml_edit.sh ├── fact_cloud.pp ├── fact_external.txt ├── fact_if.pp ├── fact_memory.pp ├── fact_networking.pp ├── facts_architecture.pp ├── facts_distro_codename.pp ├── facts_hash.pp ├── file_directory.pp ├── file_epp.pp ├── file_group.pp ├── file_hello.pp ├── file_http.pp ├── file_inline_epp.pp ├── file_line.pp ├── file_line_absent.pp ├── file_line_match.pp ├── file_mode.pp ├── file_owner.pp ├── file_source.pp ├── file_symlink.pp ├── file_tree.pp ├── files ├── config_dir │ ├── 1 │ ├── 2 │ └── 3 ├── database.yml ├── motd.txt ├── mysql.cnf └── run-puppet.sh ├── fqdn_rand.pp ├── grep.pp ├── hash_attributes.pp ├── hiera_aws.yaml ├── hiera_eyaml.config.yaml ├── hiera_fact.yaml ├── hiera_gpg_sample.yaml ├── hiera_hash.pp ├── hiera_hostname.yaml ├── hiera_minimal.config.yaml ├── hiera_os_codename.yaml ├── hiera_os_release.yaml ├── hiera_sample.yaml ├── hiera_users.pp ├── hiera_users.yaml ├── hiera_users2.pp ├── hiera_users2.yaml ├── iam_policy.json ├── if.pp ├── iteration_each.pp ├── iteration_hash.pp ├── iteration_simple.pp ├── join.pp ├── lint_test.pp ├── loadyaml.pp ├── lookup.pp ├── lookup2.pp ├── lookup3.pp ├── lookup_merge.pp ├── lookup_type.pp ├── member_has_key.pp ├── module_apache.pp ├── module_archive.pp ├── module_mysql.pp ├── node_app1.pp ├── node_modules.pp ├── node_regex.pp ├── ntp.pp ├── ntp2.pp ├── package.pp ├── package_ensure.pp ├── package_ensure_params.pp ├── package_file_service.pp ├── package_file_service_require.pp ├── package_gem.pp ├── package_puppet_gem.pp ├── package_remove.pp ├── package_url.pp ├── package_version.pp ├── pick.pp ├── profile_nginx.pp ├── profile_tomcat.pp ├── pry.pp ├── pry_install.pp ├── regex.pp ├── resource_array.pp ├── role_app_server.pp ├── role_app_server_profiles.pp ├── run-puppet.pp ├── service.pp ├── service_custom_restart.pp ├── service_hasrestart.pp ├── service_hasstatus.pp ├── service_pattern.pp ├── ssh_authorized_key.pp ├── string_interpolation.pp ├── template_compute.epp ├── template_hiera.epp ├── template_hiera_params.epp ├── template_if.epp ├── template_iterate.epp ├── template_iterate2.epp ├── template_params.epp ├── user.pp ├── user_remove.pp ├── variable_array.pp ├── variable_hash.pp ├── variable_simple.pp └── variable_string.pp /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: bitfield 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | *.swp 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Puppet Beginner's Guide, 2nd Edition 2 | 3 | 4 | ![It's great having a robot butler](http://bitfieldconsulting.com/files/1240_03_01_small.png) 5 | 6 | Keyboards wear out; that's a scientific fact. As a small measure to prevent this, I'm making all the code examples in the forthcoming second edition of [The Puppet Beginner's Guide](http://bitfieldconsulting.com/pbg2) freely available to download and use in this repo, so you don't have to type them in from the book. You'll find them in the [examples](https://github.com/bitfield/puppet-beginners-guide/tree/master/examples) directory. 7 | 8 | If you're already using Puppet, you can dive straight in and look at the examples. You can read, use, and modify them without needing to buy the book, although obviously I will be happier if you do. (Buy two copies, in case you leave one on the bus by mistake.) 9 | 10 | Throughout the book, we'll be developing a complete, working example infrastructure, which you can use as a basis for your own. You can view and download it at the [Puppet Beginner's Guide demo repo](https://github.com/bitfield/control-repo). 11 | 12 | If you're new to Puppet, a great way to try it out quickly is to use a Vagrant virtual machine, which will run on your own computer, and there's a specific [Vagrant image](https://atlas.hashicorp.com/puppetlabs/boxes/ubuntu-16.04-64-puppet) recommended for use with this book. Follow the instructions below to install Virtualbox and Vagrant, and you'll be able to run the examples in this repo in just a few minutes. 13 | 14 | Download and install [Virtualbox](https://www.virtualbox.org/). 15 | 16 | Download and install [Vagrant](https://www.vagrantup.com/downloads.html). 17 | 18 | In the `puppet-beginners-guide` repo directory, run: 19 | 20 | vagrant plugin install vagrant-vbguest 21 | vagrant up 22 | ... 23 | 24 | Machine booted and ready! 25 | 26 | Connect to the VM with the following command: 27 | 28 | vagrant ssh 29 | 30 | You now have a command line shell on the VM. Check that Puppet is installed and working: 31 | 32 | puppet --version 33 | 4.9.2 34 | 35 | Try the 'Hello, world' example: 36 | 37 | puppet apply /vagrant/examples/file_hello.pp 38 | Notice: Compiled catalog for localhost in environment production in 0.07 seconds 39 | Notice: /Stage[main]/Main/File[/tmp/hello.txt]/ensure: defined content as '{md5}22c3683b094136c3398391ae71b20f04' 40 | Notice: Applied catalog in 0.01 seconds 41 | 42 | cat /tmp/hello.txt 43 | hello, world 44 | 45 | To make sure you have the latest version of Puppet installed, run the following commands (answer `y` to any prompts): 46 | 47 | curl https://apt.puppetlabs.com/DEB-GPG-KEY-puppet |sudo apt-key add 48 | sudo apt-get update 49 | sudo apt-get install -y puppetlabs-release-pc1 50 | sudo apt-get install -y puppet-agent 51 | 52 | To check that Puppet is installed and working, run this command (you may get a different version number, which is fine): 53 | 54 | sudo /opt/puppetlabs/bin/puppet --version 55 | 4.10.0 56 | 57 | Well, that was easy! Reward yourself with a big cup of tea and a slice of cake. It's important to keep your strength up. 58 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # All Vagrant configuration is done below. The "2" in Vagrant.configure 5 | # configures the configuration version (we support older styles for 6 | # backwards compatibility). Please don't change it unless you know what 7 | # you're doing. 8 | Vagrant.configure("2") do |config| 9 | # The most common configuration options are documented and commented below. 10 | # For a complete reference, please see the online documentation at 11 | # https://docs.vagrantup.com. 12 | 13 | # Every Vagrant development environment requires a box. You can search for 14 | # boxes at https://atlas.hashicorp.com/search. 15 | # If you have trouble running the 64-bit Vagrant VM, try this instead: 16 | # config.vm.box = "puppetlabs/ubuntu-16.04-32-puppet" 17 | config.vm.box = "puppetlabs/ubuntu-16.04-64-puppet" 18 | 19 | # Disable automatic box update checking. If you disable this, then 20 | # boxes will only be checked for updates when the user runs 21 | # `vagrant box outdated`. This is not recommended. 22 | # config.vm.box_check_update = false 23 | 24 | # Create a forwarded port mapping which allows access to a specific port 25 | # within the machine from a port on the host machine. In the example below, 26 | # accessing "localhost:8080" will access port 80 on the guest machine. 27 | config.vm.network "forwarded_port", guest: 80, host: 8080 28 | 29 | # Create a private network, which allows host-only access to the machine 30 | # using a specific IP. 31 | # config.vm.network "private_network", ip: "192.168.33.10" 32 | 33 | # Create a public network, which generally matched to bridged network. 34 | # Bridged networks make the machine appear as another physical device on 35 | # your network. 36 | # config.vm.network "public_network" 37 | 38 | # Share an additional folder to the guest VM. The first argument is 39 | # the path on the host to the actual folder. The second argument is 40 | # the path on the guest to mount the folder. And the optional third 41 | # argument is a set of non-required options. 42 | # config.vm.synced_folder "../data", "/vagrant_data" 43 | 44 | # Provider-specific configuration so you can fine-tune various 45 | # backing providers for Vagrant. These expose provider-specific options. 46 | # Example for VirtualBox: 47 | # 48 | # config.vm.provider "virtualbox" do |vb| 49 | # # Display the VirtualBox GUI when booting the machine 50 | # vb.gui = true 51 | # 52 | # # Customize the amount of memory on the VM: 53 | # vb.memory = "1024" 54 | # end 55 | # 56 | # View the documentation for the provider you are using for more 57 | # information on available options. 58 | 59 | # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies 60 | # such as FTP and Heroku are also available. See the documentation at 61 | # https://docs.vagrantup.com/v2/push/atlas.html for more information. 62 | # config.push.define "atlas" do |push| 63 | # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" 64 | # end 65 | 66 | # Enable provisioning with a shell script. Additional provisioners such as 67 | # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the 68 | # documentation for more information about their specific syntax and use. 69 | # config.vm.provision "shell", inline: <<-SHELL 70 | # apt-get update 71 | # apt-get install -y apache2 72 | # SHELL 73 | end 74 | -------------------------------------------------------------------------------- /examples/Dockerfile.hello: -------------------------------------------------------------------------------- 1 | FROM library/alpine:3.1 2 | CMD /bin/sh -c "while true; do echo Hello, world; sleep 1; done" 3 | 4 | LABEL org.label-schema.vendor="Bitfield Consulting" \ 5 | org.label-schema.url="http://bitfieldconsulting.com" \ 6 | org.label-schema.name="Hello World" \ 7 | org.label-schema.version="1.0.0" \ 8 | org.label-schema.vcs-url="github.com:bitfield/puppet-beginners-guide.git" \ 9 | org.label-schema.docker.schema-version="1.0" 10 | -------------------------------------------------------------------------------- /examples/Dockerfile.nginx: -------------------------------------------------------------------------------- 1 | FROM nginx:1.13.0-alpine 2 | RUN echo "Hello, world" >/usr/share/nginx/html/index.html 3 | 4 | LABEL org.label-schema.vendor="Bitfield Consulting" \ 5 | org.label-schema.url="http://bitfieldconsulting.com" \ 6 | org.label-schema.name="Nginx Hello World" \ 7 | org.label-schema.version="1.0.0" \ 8 | org.label-schema.vcs-url="github.com:bitfield/puppet-beginners-guide.git" \ 9 | org.label-schema.docker.schema-version="1.0" 10 | -------------------------------------------------------------------------------- /examples/Dockerfile.nginx.epp: -------------------------------------------------------------------------------- 1 | <% | String $message | -%> 2 | FROM nginx:1.13.0-alpine 3 | RUN echo "<%= $message %>" >/usr/share/nginx/html/index.html 4 | 5 | LABEL org.label-schema.vendor="Bitfield Consulting" \ 6 | org.label-schema.url="http://bitfieldconsulting.com" \ 7 | org.label-schema.name="Nginx Dynamic Message" \ 8 | org.label-schema.version="1.0.0" \ 9 | org.label-schema.vcs-url="github.com:bitfield/puppet-beginners-guide.git" \ 10 | org.label-schema.docker.schema-version="1.0" 11 | -------------------------------------------------------------------------------- /examples/Dockerfile.pbg-demo: -------------------------------------------------------------------------------- 1 | FROM nginx:1.13.0-alpine 2 | RUN apk update \ 3 | && apk add redis 4 | 5 | LABEL org.label-schema.vendor="Bitfield Consulting" \ 6 | org.label-schema.url="http://bitfieldconsulting.com" \ 7 | org.label-schema.name="Redis Demo" \ 8 | org.label-schema.version="1.0.0" \ 9 | org.label-schema.vcs-url="github.com:bitfield/puppet-beginners-guide.git" \ 10 | org.label-schema.docker.schema-version="1.0" 11 | -------------------------------------------------------------------------------- /examples/Dockerfile.website.epp: -------------------------------------------------------------------------------- 1 | <% | String $git_url | -%> 2 | FROM nginx:1.13.0-alpine 3 | RUN apk update \ 4 | && apk add git \ 5 | && cd /usr/share/nginx \ 6 | && mv html html.orig \ 7 | && git clone <%= $git_url %> html 8 | 9 | LABEL org.label-schema.vendor="Bitfield Consulting" \ 10 | org.label-schema.url="http://bitfieldconsulting.com" \ 11 | org.label-schema.name="Nginx Git Website" \ 12 | org.label-schema.version="1.0.0" \ 13 | org.label-schema.vcs-url="github.com:bitfield/puppet-beginners-guide.git" \ 14 | org.label-schema.docker.schema-version="1.0" 15 | -------------------------------------------------------------------------------- /examples/Puppetfile.apache: -------------------------------------------------------------------------------- 1 | forge 'http://forge.puppetlabs.com' 2 | 3 | mod 'puppetlabs/apache', '1.11.0' 4 | mod 'puppetlabs/concat', '2.2.1' 5 | mod 'puppetlabs/stdlib', '4.17.0' 6 | -------------------------------------------------------------------------------- /examples/Puppetfile.archive: -------------------------------------------------------------------------------- 1 | forge 'http://forge.puppetlabs.com' 2 | 3 | mod 'puppet/archive', '1.3.0' 4 | mod 'puppetlabs/stdlib', '4.17.0' 5 | -------------------------------------------------------------------------------- /examples/Puppetfile.aws: -------------------------------------------------------------------------------- 1 | forge 'http://forge.puppetlabs.com' 2 | 3 | mod 'puppetlabs/aws', '2.0.0' 4 | mod 'puppetlabs/stdlib', '4.17.0' 5 | -------------------------------------------------------------------------------- /examples/Puppetfile.docker: -------------------------------------------------------------------------------- 1 | forge 'http://forge.puppetlabs.com' 2 | 3 | mod 'garethr/docker', '5.3.0' 4 | mod 'puppetlabs/apt', '3.0.0' 5 | mod 'puppetlabs/docker_platform', '2.2.1' 6 | mod 'puppetlabs/stdlib', '4.17.0' 7 | mod 'stahnma/epel', '1.2.2' 8 | -------------------------------------------------------------------------------- /examples/Puppetfile.mysql: -------------------------------------------------------------------------------- 1 | forge 'http://forge.puppetlabs.com' 2 | 3 | mod 'puppet/staging', '2.2.0' 4 | mod 'puppetlabs/mysql', '3.11.0' 5 | mod 'puppetlabs/stdlib', '4.17.0' 6 | -------------------------------------------------------------------------------- /examples/Puppetfile.ntp: -------------------------------------------------------------------------------- 1 | forge 'http://forge.puppetlabs.com' 2 | 3 | mod 'puppetlabs/stdlib', '4.15.0' 4 | 5 | mod 'pbg/ntp', 6 | :git => 'https://github.com/bitfield/pbg-ntp.git', 7 | :tag => '0.1.1' 8 | -------------------------------------------------------------------------------- /examples/Puppetfile.stdlib: -------------------------------------------------------------------------------- 1 | forge 'http://forge.puppetlabs.com' 2 | 3 | mod 'puppetlabs/stdlib', '4.17.0' 4 | -------------------------------------------------------------------------------- /examples/aws_credentials.epp: -------------------------------------------------------------------------------- 1 | aws_access_key_id = <%= $aws_access_key %> 2 | -------------------------------------------------------------------------------- /examples/aws_hiera.pp: -------------------------------------------------------------------------------- 1 | $aws_resources = lookup('aws_resources', Hash, 'hash') 2 | $aws_resources.each | String $r_type, Hash $resources | { 3 | $resources.each | String $r_title, Hash $attrs | { 4 | Resource[$r_type] { $r_title: 5 | * => $attrs, 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/aws_instance.pp: -------------------------------------------------------------------------------- 1 | $ami = 'YOUR_AMI_ID' 2 | $region = 'us-east-1' 3 | 4 | ec2_securitygroup { 'pbg-sg': 5 | ensure => present, 6 | description => 'PBG security group', 7 | region => $region, 8 | vpc => 'default-vpc', 9 | ingress => [ 10 | { 11 | description => 'SSH access from world', 12 | protocol => 'tcp', 13 | port => 22, 14 | cidr => '0.0.0.0/0', 15 | }, 16 | { 17 | description => 'Ping access from world', 18 | protocol => 'icmp', 19 | cidr => '0.0.0.0/0', 20 | }, 21 | ], 22 | } 23 | 24 | ec2_instance { 'pbg-demo': 25 | ensure => present, 26 | region => $region, 27 | subnet => 'default-subnet', 28 | security_groups => 'pbg-sg', 29 | image_id => $ami, 30 | instance_type => 't1.micro', 31 | associate_public_ip_address => true, 32 | key_name => 'pbg', 33 | } 34 | -------------------------------------------------------------------------------- /examples/aws_sdk.pp: -------------------------------------------------------------------------------- 1 | ensure_packages([ 2 | 'aws-sdk-core', 3 | 'retries' 4 | ], 5 | { provider => puppet_gem }) 6 | -------------------------------------------------------------------------------- /examples/aws_vpc.pp: -------------------------------------------------------------------------------- 1 | $ami = 'YOUR_AMI_ID' 2 | $region = 'us-east-1' 3 | 4 | ec2_vpc { 'pbg-vpc': 5 | ensure => present, 6 | region => $region, 7 | cidr_block => '10.99.0.0/16', 8 | } 9 | 10 | ec2_vpc_internet_gateway { 'pbg-igw': 11 | ensure => present, 12 | region => $region, 13 | vpc => 'pbg-vpc', 14 | } 15 | 16 | ec2_vpc_routetable { 'pbg-rt': 17 | ensure => present, 18 | region => $region, 19 | vpc => 'pbg-vpc', 20 | routes => [ 21 | { 22 | destination_cidr_block => '10.99.0.0/16', 23 | gateway => 'local' 24 | }, 25 | { 26 | destination_cidr_block => '0.0.0.0/0', 27 | gateway => 'pbg-igw' 28 | }, 29 | ], 30 | } 31 | 32 | ec2_vpc_subnet { 'pbg-vpc-subnet': 33 | ensure => present, 34 | vpc => 'pbg-vpc', 35 | region => $region, 36 | cidr_block => '10.99.0.0/24', 37 | availability_zone => "${region}a", 38 | route_table => 'pbg-rt', 39 | } 40 | 41 | ec2_securitygroup { 'pbg-vpc-sg': 42 | ensure => present, 43 | description => 'PBG security group', 44 | region => $region, 45 | vpc => 'pbg-vpc', 46 | ingress => [ 47 | { 48 | description => 'SSH access from world', 49 | protocol => 'tcp', 50 | port => 22, 51 | cidr => '0.0.0.0/0', 52 | }, 53 | { 54 | description => 'Ping access from world', 55 | protocol => 'icmp', 56 | cidr => '0.0.0.0/0', 57 | }, 58 | ], 59 | } 60 | 61 | ec2_instance { 'pbg-vpc-demo': 62 | ensure => present, 63 | region => $region, 64 | subnet => 'pbg-vpc-subnet', 65 | security_groups => 'pbg-vpc-sg', 66 | image_id => $ami, 67 | instance_type => 't1.micro', 68 | associate_public_ip_address => true, 69 | key_name => 'pbg', 70 | } 71 | -------------------------------------------------------------------------------- /examples/case.pp: -------------------------------------------------------------------------------- 1 | $webserver = 'nginx' 2 | case $webserver { 3 | 'nginx': { 4 | notice("Looks like you're using Nginx! Good choice!") 5 | } 6 | 'apache': { 7 | notice("Ah, you're an Apache fan, eh?") 8 | } 9 | 'IIS': { 10 | notice('Well, somebody has to.') 11 | } 12 | default: { 13 | notice("I'm not sure which webserver you're using!") 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/cron.pp: -------------------------------------------------------------------------------- 1 | cron { 'cron example': 2 | command => '/bin/date +%F', 3 | user => 'vagrant', 4 | environment => ['MAILTO=john@bitfieldconsulting.com', 'PATH=/bin'], 5 | hour => '0', 6 | minute => '0', 7 | weekday => ['Saturday', 'Sunday'], 8 | } 9 | -------------------------------------------------------------------------------- /examples/date.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "date=`date +%F`" 3 | -------------------------------------------------------------------------------- /examples/defined_resource_type.pp: -------------------------------------------------------------------------------- 1 | # Manage user and SSH key together 2 | define user_with_key( 3 | Enum[ 4 | 'ssh-dss', 5 | 'dsa', 6 | 'ssh-rsa', 7 | 'rsa', 8 | 'ecdsa-sha2-nistp256', 9 | 'ecdsa-sha2-nistp384', 10 | 'ecdsa-sha2-nistp521', 11 | 'ssh-ed25519', 12 | 'ed25519' 13 | ] $key_type, 14 | String[1] $key, 15 | ) { 16 | user { $title: 17 | ensure => present, 18 | home => "/home/${title}", 19 | managehome => true, 20 | } 21 | 22 | file { "/home/${title}/.ssh": 23 | ensure => directory, 24 | owner => $title, 25 | group => $title, 26 | mode => '0700', 27 | } 28 | 29 | ssh_authorized_key { $title: 30 | user => $title, 31 | type => $key_type, 32 | key => $key, 33 | } 34 | } 35 | 36 | user_with_key { 'john': 37 | key_type => 'ssh-rsa', 38 | key => 'AAAAB3NzaC1yc2EAAAABIwAAAIEA3ATqENg+GWACa2BzeqTdGnJhNoBer8x6pfWkzNzeM8Zx7/2Tf2pl7kHdbsiTXEUawqzXZQtZzt/j3Oya+PZjcRpWNRzprSmd2UxEEPTqDw9LqY5S2B8og/NyzWaIYPsKoatcgC7VgYHplcTbzEhGu8BsoEVBGYu3IRy5RkAcZik=', 39 | } 40 | -------------------------------------------------------------------------------- /examples/dirname.pp: -------------------------------------------------------------------------------- 1 | $file = '/var/www/vhosts/mysite' 2 | notice(dirname($file)) 3 | 4 | # Result: '/var/www/vhosts' 5 | -------------------------------------------------------------------------------- /examples/docker_absent.pp: -------------------------------------------------------------------------------- 1 | docker::run { 'hello': 2 | ensure => absent, 3 | image => 'bitfield/hello', 4 | } 5 | -------------------------------------------------------------------------------- /examples/docker_build_hello.pp: -------------------------------------------------------------------------------- 1 | docker::image { 'pbg-hello': 2 | docker_file => '/vagrant/examples/Dockerfile.hello', 3 | ensure => latest, 4 | } 5 | -------------------------------------------------------------------------------- /examples/docker_build_nginx.pp: -------------------------------------------------------------------------------- 1 | file { '/tmp/Dockerfile.nginx': 2 | source => '/vagrant/examples/Dockerfile.nginx', 3 | notify => Docker::Image['pbg-nginx'], 4 | } 5 | 6 | docker::image { 'pbg-nginx': 7 | docker_file => '/tmp/Dockerfile.nginx', 8 | ensure => latest, 9 | } 10 | -------------------------------------------------------------------------------- /examples/docker_image.pp: -------------------------------------------------------------------------------- 1 | docker::image { 'bitfield/hello': 2 | ensure => latest, 3 | } 4 | -------------------------------------------------------------------------------- /examples/docker_install.pp: -------------------------------------------------------------------------------- 1 | include docker 2 | -------------------------------------------------------------------------------- /examples/docker_mount.pp: -------------------------------------------------------------------------------- 1 | docker::run { 'mount_test': 2 | image => 'library/alpine', 3 | volumes => ['/tmp/container_data:/mnt/data'], 4 | command => '/bin/sh -c "echo Hello, world >/mnt/data/hello.txt"', 5 | } 6 | -------------------------------------------------------------------------------- /examples/docker_network.pp: -------------------------------------------------------------------------------- 1 | docker_network { 'pbg-net': 2 | ensure => present, 3 | } 4 | 5 | docker::run { 'pbg-redis': 6 | image => 'redis:alpine', 7 | net => 'pbg-net', 8 | } 9 | 10 | docker::image { 'pbg-demo': 11 | docker_file => '/vagrant/examples/Dockerfile.pbg-demo', 12 | ensure => latest, 13 | } 14 | 15 | docker::run { 'pbg-demo': 16 | image => 'pbg-demo:latest', 17 | net => 'pbg-net', 18 | command => '/bin/sh -c "redis-cli -h pbg-redis set message \"Hello, world\""', 19 | } 20 | -------------------------------------------------------------------------------- /examples/docker_non_service.pp: -------------------------------------------------------------------------------- 1 | docker::run { 'hello': 2 | image => 'bitfield/hello', 3 | command => '/bin/sh -c "while true; do echo Hello, world; sleep 1; done"', 4 | manage_service => false, 5 | } 6 | -------------------------------------------------------------------------------- /examples/docker_run.pp: -------------------------------------------------------------------------------- 1 | docker::run { 'hello': 2 | image => 'bitfield/hello', 3 | command => '/bin/sh -c "while true; do echo Hello, world; sleep 1; done"', 4 | } 5 | -------------------------------------------------------------------------------- /examples/docker_run_hello.pp: -------------------------------------------------------------------------------- 1 | docker::run { 'pbg-hello': 2 | image => 'pbg-hello', 3 | } 4 | -------------------------------------------------------------------------------- /examples/docker_run_many.pp: -------------------------------------------------------------------------------- 1 | range(1,20).each | $instance | { 2 | docker::run { "hello-${instance}": 3 | image => 'bitfield/hello', 4 | command => '/bin/sh -c "while true; do echo Hello, world; sleep 1; done"', 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/docker_run_nginx.pp: -------------------------------------------------------------------------------- 1 | docker::run { 'pbg-nginx': 2 | image => 'pbg-nginx:latest', 3 | ports => ['80:80'], 4 | pull_on_start => true, 5 | } 6 | -------------------------------------------------------------------------------- /examples/docker_template.pp: -------------------------------------------------------------------------------- 1 | file { '/tmp/Dockerfile.nginx': 2 | content => epp('/vagrant/examples/Dockerfile.nginx.epp', 3 | { 4 | 'message' => 'Containers rule!' 5 | } 6 | ), 7 | notify => Docker::Image['pbg-nginx'], 8 | } 9 | 10 | docker::image { 'pbg-nginx': 11 | docker_file => '/tmp/Dockerfile.nginx', 12 | ensure => latest, 13 | } 14 | -------------------------------------------------------------------------------- /examples/docker_volume.pp: -------------------------------------------------------------------------------- 1 | docker::run { 'volume_test': 2 | image => 'library/alpine', 3 | volumes => ['pbg-volume:/mnt/volume'], 4 | command => '/bin/sh -c "echo Hello from inside a Docker volume >/mnt/volume/index.html"', 5 | } 6 | -------------------------------------------------------------------------------- /examples/docker_volume2.pp: -------------------------------------------------------------------------------- 1 | docker::run { 'volume_test2': 2 | image => 'nginx:alpine', 3 | volumes => ['pbg-volume:/usr/share/nginx/html'], 4 | ports => ['80:80'], 5 | } 6 | -------------------------------------------------------------------------------- /examples/docker_website.pp: -------------------------------------------------------------------------------- 1 | file { '/tmp/Dockerfile.nginx': 2 | content => epp('/vagrant/examples/Dockerfile.website.epp', 3 | { 4 | 'git_url' => 'https://github.com/bitfield/pbg-website.git' 5 | } 6 | ), 7 | notify => Docker::Image['pbg-nginx'], 8 | } 9 | 10 | docker::image { 'pbg-nginx': 11 | docker_file => '/tmp/Dockerfile.nginx', 12 | ensure => latest, 13 | } 14 | -------------------------------------------------------------------------------- /examples/empty.pp: -------------------------------------------------------------------------------- 1 | notice(empty('')) 2 | 3 | # Result: true 4 | 5 | notice(empty([])) 6 | 7 | # Result: true 8 | 9 | notice(empty({})) 10 | 11 | # Result: true 12 | -------------------------------------------------------------------------------- /examples/epp_hiera.pp: -------------------------------------------------------------------------------- 1 | file { '/tmp/sshd_config_example': 2 | content => epp('/vagrant/examples/template_hiera_params.epp', 3 | { 4 | 'users' => lookup('users'), 5 | } 6 | ), 7 | } 8 | -------------------------------------------------------------------------------- /examples/epp_params.pp: -------------------------------------------------------------------------------- 1 | file { '/root/aws_credentials': 2 | content => epp('/vagrant/examples/template_params.epp', 3 | { 4 | 'aws_access_key' => 'AKIAIAF7V6N2PTOIZVA2', 5 | 'aws_secret_key' => '7IBpXjoYRVbJ/rCTVLaAMyud+i4co11lVt1Df1vt', 6 | } 7 | ), 8 | } 9 | -------------------------------------------------------------------------------- /examples/exec.pp: -------------------------------------------------------------------------------- 1 | exec { 'install-cat-picture-generator': 2 | cwd => '/tmp/cat-picture-generator', 3 | command => '/tmp/cat-picture/generator/configure && /usr/bin/make install', 4 | creates => '/usr/local/bin/cat-picture-generator', 5 | } 6 | -------------------------------------------------------------------------------- /examples/exec_onlyif.pp: -------------------------------------------------------------------------------- 1 | exec { 'process-incoming-cat-pictures': 2 | command => '/usr/local/bin/cat-picture-generator --import /tmp/incoming/*', 3 | onlyif => '/bin/ls /tmp/incoming/*', 4 | } 5 | -------------------------------------------------------------------------------- /examples/exec_refreshonly.pp: -------------------------------------------------------------------------------- 1 | package { 'postfix': 2 | ensure => installed, 3 | } 4 | 5 | file { '/etc/aliases': 6 | content => 'root: john@bitfieldconsulting.com', 7 | notify => Exec['newaliases'], 8 | } 9 | 10 | exec { 'newaliases': 11 | command => '/usr/bin/newaliases', 12 | refreshonly => true, 13 | } 14 | -------------------------------------------------------------------------------- /examples/exec_user.pp: -------------------------------------------------------------------------------- 1 | exec { 'say-hello': 2 | command => '/bin/echo Hello, this is `whoami` >/tmp/hello-vagrant.txt', 3 | user => 'vagrant', 4 | creates => '/tmp/hello-vagrant.txt', 5 | } 6 | -------------------------------------------------------------------------------- /examples/expression_boolean.pp: -------------------------------------------------------------------------------- 1 | notice(9 < 10) 2 | notice(11 > 10) 3 | notice(10 >= 10) 4 | notice(10 <= 10) 5 | notice('foo' == 'foo') 6 | notice('foo' in 'foobar') 7 | notice('foo' in ['foo', 'bar']) 8 | notice('foo' in { 'foo' => 'bar' }) 9 | notice('foo' =~ /oo/) 10 | notice('foo' =~ String) 11 | notice(1 != 2) 12 | -------------------------------------------------------------------------------- /examples/expression_numeric.pp: -------------------------------------------------------------------------------- 1 | $value = (17 * 8) + (12 / 4) - 1 2 | notice($value) 3 | -------------------------------------------------------------------------------- /examples/eyaml_edit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | /opt/puppetlabs/puppet/bin/eyaml edit --gpg-always-trust --gpg-recipients=puppet@cat-pictures.com /etc/puppetlabs/code/environments/production/hieradata/secret.eyaml 3 | -------------------------------------------------------------------------------- /examples/fact_cloud.pp: -------------------------------------------------------------------------------- 1 | case $facts['cloud'] { 2 | 'aws': { 3 | notice('This is an AWS cloud server ') 4 | } 5 | 'gcp': { 6 | notice('This is a Google cloud server') 7 | } 8 | default: { 9 | notice("I'm not sure which cloud I'm in!") 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/fact_external.txt: -------------------------------------------------------------------------------- 1 | cloud=aws 2 | -------------------------------------------------------------------------------- /examples/fact_if.pp: -------------------------------------------------------------------------------- 1 | if $facts['os']['selinux']['enabled'] { 2 | notice('SELinux is enabled') 3 | } else { 4 | notice('SELinux is disabled') 5 | } 6 | -------------------------------------------------------------------------------- /examples/fact_memory.pp: -------------------------------------------------------------------------------- 1 | $buffer_pool = $facts['memory']['system']['total_bytes'] * 3/4 2 | notice("innodb_buffer_pool_size=${buffer_pool}") 3 | -------------------------------------------------------------------------------- /examples/fact_networking.pp: -------------------------------------------------------------------------------- 1 | notice("My hostname is ${facts['hostname']}") 2 | notice("My FQDN is ${facts['fqdn']}") 3 | notice("My IP is ${facts['networking']['ip']}") 4 | -------------------------------------------------------------------------------- /examples/facts_architecture.pp: -------------------------------------------------------------------------------- 1 | notice($facts['os']['architecture']) 2 | -------------------------------------------------------------------------------- /examples/facts_distro_codename.pp: -------------------------------------------------------------------------------- 1 | notice($facts['os']['distro']['codename']) 2 | -------------------------------------------------------------------------------- /examples/facts_hash.pp: -------------------------------------------------------------------------------- 1 | notice($facts['kernel']) 2 | -------------------------------------------------------------------------------- /examples/file_directory.pp: -------------------------------------------------------------------------------- 1 | file { '/etc/config_dir': 2 | ensure => directory, 3 | } 4 | -------------------------------------------------------------------------------- /examples/file_epp.pp: -------------------------------------------------------------------------------- 1 | file { '/usr/local/bin/backup': 2 | content => epp('backup.sh.epp'), 3 | mode => '0755', 4 | } 5 | -------------------------------------------------------------------------------- /examples/file_group.pp: -------------------------------------------------------------------------------- 1 | file { '/etc/owned_by_vagrant': 2 | ensure => present, 3 | owner => 'vagrant', 4 | group => 'vagrant', 5 | } 6 | -------------------------------------------------------------------------------- /examples/file_hello.pp: -------------------------------------------------------------------------------- 1 | file { '/tmp/hello.txt': 2 | ensure => file, 3 | content => "hello, world\n", 4 | } 5 | -------------------------------------------------------------------------------- /examples/file_http.pp: -------------------------------------------------------------------------------- 1 | file { '/tmp/README.md': 2 | source => 'https://raw.githubusercontent.com/puppetlabs/puppet/master/README.md', 3 | } 4 | -------------------------------------------------------------------------------- /examples/file_inline_epp.pp: -------------------------------------------------------------------------------- 1 | $web_root = '/var/www/vhosts' 2 | $backup_dir = '/backups' 3 | 4 | file { '/usr/local/bin/backup': 5 | content => inline_epp('rsync -a <%= $web_root %>/ <%= $backup_dir %>/'), 6 | mode => '0755', 7 | } 8 | -------------------------------------------------------------------------------- /examples/file_line.pp: -------------------------------------------------------------------------------- 1 | file_line { 'set ulimits': 2 | path => '/etc/security/limits.conf', 3 | line => 'www-data - nofile 32768', 4 | } 5 | -------------------------------------------------------------------------------- /examples/file_line_absent.pp: -------------------------------------------------------------------------------- 1 | file_line { 'remove csh from valid shells': 2 | ensure => absent, 3 | path => '/etc/shells', 4 | match => '^/bin/csh', 5 | match_for_absence => true, 6 | } 7 | -------------------------------------------------------------------------------- /examples/file_line_match.pp: -------------------------------------------------------------------------------- 1 | file_line { 'set root email alias': 2 | path => '/etc/aliases', 3 | line => 'root: john@bitfieldconsulting.com', 4 | match => '^root: ', 5 | } 6 | -------------------------------------------------------------------------------- /examples/file_mode.pp: -------------------------------------------------------------------------------- 1 | file { '/etc/owned_by_vagrant': 2 | ensure => present, 3 | owner => 'vagrant', 4 | mode => '0644', 5 | } 6 | -------------------------------------------------------------------------------- /examples/file_owner.pp: -------------------------------------------------------------------------------- 1 | file { '/etc/owned_by_vagrant': 2 | ensure => present, 3 | owner => 'vagrant', 4 | } 5 | -------------------------------------------------------------------------------- /examples/file_source.pp: -------------------------------------------------------------------------------- 1 | file { '/etc/motd': 2 | source => '/vagrant/examples/files/motd.txt', 3 | } 4 | -------------------------------------------------------------------------------- /examples/file_symlink.pp: -------------------------------------------------------------------------------- 1 | file { '/etc/this_is_a_link': 2 | ensure => link, 3 | target => '/etc/motd', 4 | } 5 | -------------------------------------------------------------------------------- /examples/file_tree.pp: -------------------------------------------------------------------------------- 1 | file { '/etc/config_dir': 2 | source => '/vagrant/examples/files/config_dir', 3 | recurse => true, 4 | } 5 | -------------------------------------------------------------------------------- /examples/files/config_dir/1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitfield/puppet-beginners-guide/99430dead5dc2f616987dac22def03847384f90a/examples/files/config_dir/1 -------------------------------------------------------------------------------- /examples/files/config_dir/2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitfield/puppet-beginners-guide/99430dead5dc2f616987dac22def03847384f90a/examples/files/config_dir/2 -------------------------------------------------------------------------------- /examples/files/config_dir/3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitfield/puppet-beginners-guide/99430dead5dc2f616987dac22def03847384f90a/examples/files/config_dir/3 -------------------------------------------------------------------------------- /examples/files/database.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: mysql 3 | database: dev_db 4 | username: root 5 | password: 6 | socket: /tmp/mysql.sock 7 | -------------------------------------------------------------------------------- /examples/files/motd.txt: -------------------------------------------------------------------------------- 1 | The best software in the world only sucks. The worst software is significantly worse than that. 2 | -Luke Kanies 3 | -------------------------------------------------------------------------------- /examples/files/mysql.cnf: -------------------------------------------------------------------------------- 1 | !includedir /etc/mysql/conf.d/ 2 | !includedir /etc/mysql/mysql.conf.d/ 3 | -------------------------------------------------------------------------------- /examples/files/run-puppet.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd /etc/puppetlabs/code/environments/production && git pull 3 | /opt/puppetlabs/bin/puppet apply manifests/ 4 | -------------------------------------------------------------------------------- /examples/fqdn_rand.pp: -------------------------------------------------------------------------------- 1 | cron { 'run daily backup': 2 | command => '/usr/local/bin/backup', 3 | minute => '0', 4 | hour => fqdn_rand(24, 'run daily backup'), 5 | } 6 | 7 | cron { 'run daily backup sync': 8 | command => '/usr/local/bin/backup_sync', 9 | minute => '0', 10 | hour => fqdn_rand(24, 'run daily backup sync'), 11 | } 12 | -------------------------------------------------------------------------------- /examples/grep.pp: -------------------------------------------------------------------------------- 1 | $values = ['foo', 'bar', 'baz'] 2 | notice(grep($values, 'ba.*')) 3 | 4 | # Result: ['bar', 'baz'] 5 | -------------------------------------------------------------------------------- /examples/hash_attributes.pp: -------------------------------------------------------------------------------- 1 | $attributes = { 2 | 'owner' => 'vagrant', 3 | 'group' => 'vagrant', 4 | 'mode' => '0644', 5 | } 6 | 7 | file { '/tmp/test': 8 | ensure => present, 9 | * => $attributes, 10 | } 11 | -------------------------------------------------------------------------------- /examples/hiera_aws.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | ami: 'YOUR_AMI_ID' 3 | region: 'us-east-1' 4 | aws_resources: 5 | 'ec2_vpc': 6 | 'pbg-vpc': 7 | ensure: present 8 | region: "%{lookup('region')}" 9 | cidr_block: '10.99.0.0/16' 10 | 'ec2_vpc_internet_gateway': 11 | 'pbg-igw': 12 | ensure: present 13 | region: "%{lookup('region')}" 14 | vpc: 'pbg-vpc' 15 | 'ec2_vpc_routetable': 16 | 'pbg-rt': 17 | ensure: present 18 | region: "%{lookup('region')}" 19 | vpc : 'pbg-vpc' 20 | routes: 21 | - destination_cidr_block: '10.99.0.0/16' 22 | gateway: 'local' 23 | - destination_cidr_block: '0.0.0.0/0' 24 | gateway: 'pbg-igw' 25 | 'ec2_vpc_subnet': 26 | 'pbg-vpc-subnet': 27 | ensure: present 28 | region: "%{lookup('region')}" 29 | vpc: 'pbg-vpc' 30 | cidr_block: '10.99.0.0/24' 31 | availability_zone: "%{lookup('region')}a" 32 | route_table: 'pbg-rt' 33 | 'ec2_securitygroup': 34 | 'pbg-vpc-sg': 35 | ensure: present 36 | description: 'PBG security group' 37 | region: "%{lookup('region')}" 38 | vpc: 'pbg-vpc' 39 | ingress: 40 | - description: 'SSH access from world' 41 | protocol: 'tcp' 42 | port: 22 43 | cidr: '0.0.0.0/0' 44 | - description: 'Ping access from world' 45 | protocol: 'icmp' 46 | cidr: '0.0.0.0/0' 47 | 'ec2_instance': 48 | 'pbg-vpc-demo': 49 | ensure: present 50 | region: "%{lookup('region')}" 51 | subnet: 'pbg-vpc-subnet' 52 | security_groups: 'pbg-vpc-sg' 53 | image_id: "%{lookup('ami')}" 54 | instance_type: 't1.micro' 55 | associate_public_ip_address: true 56 | key_name: 'pbg' 57 | -------------------------------------------------------------------------------- /examples/hiera_eyaml.config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 5 3 | 4 | defaults: 5 | datadir: data 6 | data_hash: yaml_data 7 | 8 | hierarchy: 9 | - name: "Common defaults" 10 | path: "common.yaml" 11 | - name: "Per-datacenter secret data (encrypted)" 12 | lookup_key: eyaml_lookup_key 13 | path: "secret.eyaml" 14 | options: 15 | gpg_gnupghome: '/home/vagrant/.gnupg' 16 | -------------------------------------------------------------------------------- /examples/hiera_fact.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | backup_path: "/backup/%{facts.hostname}" 3 | -------------------------------------------------------------------------------- /examples/hiera_gpg_sample.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | :backends: 3 | - yaml 4 | - eyaml 5 | :yaml: 6 | :datadir: "/etc/puppetlabs/code/environments/%{environment}/data" 7 | :eyaml: 8 | :datadir: "/etc/puppetlabs/code/environments/%{environment}/data" 9 | :gpg_gnupghome: '/home/vagrant/.gnupg' 10 | :hierarchy: 11 | - secret 12 | - common 13 | -------------------------------------------------------------------------------- /examples/hiera_hash.pp: -------------------------------------------------------------------------------- 1 | $cobbler_config = lookup('cobbler_config') 2 | 3 | $manage_dhcp = $cobbler_config['manage_dhcp'] 4 | $pxe_just_once = $cobbler_config['pxe_just_once'] 5 | -------------------------------------------------------------------------------- /examples/hiera_hostname.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 5 3 | 4 | defaults: 5 | datadir: data 6 | data_hash: yaml_data 7 | 8 | hierarchy: 9 | - name: "Host-specific data" 10 | path: "nodes/%{facts.hostname}.yaml" 11 | - name: "Common defaults" 12 | path: "common.yaml" 13 | -------------------------------------------------------------------------------- /examples/hiera_minimal.config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 5 3 | 4 | defaults: 5 | datadir: data 6 | data_hash: yaml_data 7 | 8 | hierarchy: 9 | - name: "Common defaults" 10 | path: "common.yaml" 11 | -------------------------------------------------------------------------------- /examples/hiera_os_codename.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 5 3 | 4 | defaults: 5 | datadir: data 6 | data_hash: yaml_data 7 | 8 | hierarchy: 9 | - name: "OS-specific data" 10 | path: "os/%{facts.os.distro.codename}.yaml" 11 | - name: "Common defaults" 12 | path: "common.yaml" 13 | -------------------------------------------------------------------------------- /examples/hiera_os_release.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 5 3 | 4 | defaults: 5 | datadir: data 6 | data_hash: yaml_data 7 | 8 | hierarchy: 9 | - name: "OS-specific data" 10 | path: "os/%{facts.os.release.major}.yaml" 11 | - name: "Common defaults" 12 | path: "common.yaml" 13 | -------------------------------------------------------------------------------- /examples/hiera_sample.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | test: 'This is a test' 3 | consul_node: true 4 | apache_pkg: 'apache2' 5 | apache_worker_factor: 100 6 | apparmor_enabled: true 7 | syslog_server: '10.170.81.32' 8 | monitor_ips: 9 | - '10.179.203.46' 10 | - '212.100.235.160' 11 | - '10.181.120.77' 12 | - '94.236.56.148' 13 | cobbler_config: 14 | manage_dhcp: 1 15 | pxe_just_once: 1 16 | domain: 'bitfieldconsulting.com' 17 | servername: 'www.bitfieldconsulting.com' 18 | port: 80 19 | docroot: '/var/www/bitfieldconsulting.com' 20 | dns_allow_query: true 21 | backup_retention_days: 10 22 | backup_path: "/backup/%{facts.hostname}" 23 | ips: 24 | home: '130.190.0.1' 25 | office1: '74.12.203.14' 26 | office2: '95.170.0.75' 27 | firewall_allow_list: 28 | - "%{lookup('ips.home')}" 29 | - "%{lookup('ips.office1')}" 30 | - "%{lookup('ips.office2')}" 31 | -------------------------------------------------------------------------------- /examples/hiera_users.pp: -------------------------------------------------------------------------------- 1 | lookup('users').each | String $username | { 2 | user { $username: 3 | ensure => present, 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /examples/hiera_users.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | users: 3 | - 'katy' 4 | - 'lark' 5 | - 'bridget' 6 | - 'hsing-hui' 7 | - 'charles' 8 | -------------------------------------------------------------------------------- /examples/hiera_users2.pp: -------------------------------------------------------------------------------- 1 | lookup('users').each | String $username, Hash $attrs | { 2 | user { $username: 3 | * => $attrs, 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /examples/hiera_users2.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | users: 3 | 'katy': 4 | ensure: present 5 | uid: 1900 6 | shell: '/bin/bash' 7 | 'lark': 8 | ensure: present 9 | uid: 1901 10 | shell: '/bin/sh' 11 | 'bridget': 12 | ensure: present 13 | uid: 1902 14 | shell: '/bin/bash' 15 | 'hsing-hui': 16 | ensure: present 17 | uid: 1903 18 | shell: '/bin/sh' 19 | 'charles': 20 | ensure: present 21 | uid: 1904 22 | shell: '/bin/bash' 23 | -------------------------------------------------------------------------------- /examples/iam_policy.json: -------------------------------------------------------------------------------- 1 | { 2 | "Version": "2012-10-17", 3 | "Statement": [ 4 | { 5 | "Action": [ 6 | "ec2:DescribeAccountAttributes", 7 | "ec2:DescribeRegions", 8 | "ec2:DescribeInstances", 9 | "ec2:RunInstances", 10 | "ec2:StartInstances", 11 | "ec2:StopInstances", 12 | "ec2:DeleteTags", 13 | "ec2:CreateTags", 14 | "ec2:TerminateInstances", 15 | "elasticloadbalancing:DescribeLoadBalancers", 16 | "elasticloadbalancing:CreateLoadBalancer", 17 | "elasticloadbalancing:DescribeTags", 18 | "elasticloadbalancing:RegisterInstancesWithLoadBalancer", 19 | "elasticloadbalancing:DeleteLoadBalancer", 20 | "ec2:DescribeSecurityGroups", 21 | "ec2:CreateSecurityGroup", 22 | "ec2:AuthorizeSecurityGroupIngress", 23 | "ec2:RevokeSecurityGroupIngress", 24 | "ec2:DeleteSecurityGroup", 25 | "ec2:DescribeVpcs", 26 | "ec2:*Vpc*", 27 | "ec2:CreateVpc", 28 | "ec2:DeleteVpc", 29 | "ec2:AssociateDhcpOptions", 30 | "ec2:DescribeDhcpOptions", 31 | "ec2:CreateDhcpOptions", 32 | "ec2:DeleteDhcpOptions", 33 | "ec2:DescribeCustomerGateways", 34 | "ec2:CreateCustomerGateway", 35 | "ec2:DeleteCustomerGateway", 36 | "ec2:DescribeInternetGateways", 37 | "ec2:CreateInternetGateway", 38 | "ec2:AttachInternetGateway", 39 | "ec2:DeleteInternetGateway", 40 | "ec2:DetachInternetGateway", 41 | "ec2:DescribeRouteTables", 42 | "ec2:CreateRouteTable", 43 | "ec2:DeleteRouteTable", 44 | "ec2:CreateRoute", 45 | "ec2:DescribeSubnets", 46 | "ec2:CreateSubnet", 47 | "ec2:DeleteSubnet", 48 | "ec2:AssociateRouteTable", 49 | "ec2:DescribeVpnConnections", 50 | "ec2:CreateVpnConnection", 51 | "ec2:DeleteVpnConnection", 52 | "ec2:CreateVpnConnectionRoute", 53 | "ec2:DescribeVpnGateways", 54 | "ec2:CreateVpnGateway", 55 | "ec2:AttachVpnGateway", 56 | "ec2:DetachVpnGateway", 57 | "ec2:DeleteVpnGateway", 58 | "ec2:CreateTags", 59 | "autoscaling:DescribeAutoScalingGroups", 60 | "autoscaling:CreateAutoScalingGroup", 61 | "autoscaling:UpdateAutoScalingGroup", 62 | "autoscaling:DeleteAutoScalingGroup", 63 | "autoscaling:DescribeLaunchConfigurations", 64 | "autoscaling:CreateLaunchConfiguration", 65 | "autoscaling:DeleteLaunchConfiguration", 66 | "autoscaling:DescribePolicies", 67 | "autoscaling:PutScalingPolicy", 68 | "autoscaling:DeletePolicy", 69 | "cloudwatch:DescribeAlarms", 70 | "cloudwatch:PutMetricAlarm", 71 | "cloudwatch:DeleteAlarms", 72 | "route53:ListResourceRecordSets", 73 | "route53:ListHostedZones", 74 | "route53:ChangeResourceRecordSets", 75 | "route53:CreateHostedZone", 76 | "route53:DeleteHostedZone", 77 | "rds:CreateDBInstance", 78 | "rds:ModifyDBInstance", 79 | "rds:DeleteDBInstance", 80 | "rds:DescribeDBInstances", 81 | "rds:AuthorizeDBSecurityGroupIngress", 82 | "rds:DescribeDBSecurityGroups", 83 | "rds:CreateDBSecurityGroup", 84 | "rds:DeleteDBSecurityGroup", 85 | "rds:DescribeDBParameterGroups", 86 | "sqs:*" 87 | ], 88 | "Effect": "Allow", 89 | "Resource": "*" 90 | } 91 | ] 92 | } 93 | -------------------------------------------------------------------------------- /examples/if.pp: -------------------------------------------------------------------------------- 1 | $install_perl = true 2 | if $install_perl { 3 | package { 'perl': 4 | ensure => installed, 5 | } 6 | } else { 7 | package { 'perl': 8 | ensure => absent, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/iteration_each.pp: -------------------------------------------------------------------------------- 1 | $tasks = ['task1', 'task2', 'task3'] 2 | $tasks.each | $task | { 3 | file { "/usr/local/bin/${task}": 4 | content => "echo I am ${task}\n", 5 | mode => '0755', 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/iteration_hash.pp: -------------------------------------------------------------------------------- 1 | $nics = $facts['networking']['interfaces'] 2 | $nics.each | String $interface, Hash $attributes | { 3 | notice("Interface ${interface} has IP ${attributes['ip']}") 4 | } 5 | -------------------------------------------------------------------------------- /examples/iteration_simple.pp: -------------------------------------------------------------------------------- 1 | file { '/usr/local/bin/task1': 2 | content => "echo I am task1\n", 3 | mode => '0755', 4 | } 5 | 6 | file { '/usr/local/bin/task2': 7 | content => "echo I am task2\n", 8 | mode => '0755', 9 | } 10 | 11 | file { '/usr/local/bin/task3': 12 | content => "echo I am task3\n", 13 | mode => '0755', 14 | } 15 | -------------------------------------------------------------------------------- /examples/join.pp: -------------------------------------------------------------------------------- 1 | $values = ['1', '2', '3'] 2 | notice(join($values, '... ')) 3 | 4 | # Result: '1... 2... 3' 5 | -------------------------------------------------------------------------------- /examples/lint_test.pp: -------------------------------------------------------------------------------- 1 | file { '/tmp/lint.txt': 2 | ensure => file, 3 | content => "puppet-lint is your friend\n", 4 | } 5 | -------------------------------------------------------------------------------- /examples/loadyaml.pp: -------------------------------------------------------------------------------- 1 | $db_config = loadyaml('/vagrant/examples/files/database.yml') 2 | notice($db_config['development']['database']) 3 | 4 | # Result: 'dev_db' 5 | -------------------------------------------------------------------------------- /examples/lookup.pp: -------------------------------------------------------------------------------- 1 | file { lookup('backup_path'): 2 | ensure => directory, 3 | } 4 | -------------------------------------------------------------------------------- /examples/lookup2.pp: -------------------------------------------------------------------------------- 1 | $apache_pkg = lookup('apache_pkg') 2 | 3 | unless lookup('apparmor_enabled') { 4 | exec { 'apt-get -y remove apparmor': } 5 | } 6 | 7 | notice('dns_allow_query enabled: ', lookup('dns_allow_query')) 8 | -------------------------------------------------------------------------------- /examples/lookup3.pp: -------------------------------------------------------------------------------- 1 | $cobbler_config = lookup('cobbler_config') 2 | $manage_dhcp = $cobbler_config['manage_dhcp'] 3 | $pxe_just_once = $cobbler_config['pxe_just_once'] 4 | if $pxe_just_once { 5 | notice('pxe_just_once is enabled') 6 | } else { 7 | notice('pxe_just_once is disabled') 8 | } 9 | -------------------------------------------------------------------------------- /examples/lookup_merge.pp: -------------------------------------------------------------------------------- 1 | notice(lookup('firewall_allow_list', Array, 'unique')) 2 | -------------------------------------------------------------------------------- /examples/lookup_type.pp: -------------------------------------------------------------------------------- 1 | notice(lookup('apparmor_enabled', Boolean)) 2 | -------------------------------------------------------------------------------- /examples/member_has_key.pp: -------------------------------------------------------------------------------- 1 | $values = [ 2 | 'foo', 3 | 'bar', 4 | 'baz', 5 | ] 6 | notice(member($values, 'foo')) 7 | 8 | # Result: true 9 | 10 | $valuehash = { 11 | 'a' => 1, 12 | 'b' => 2, 13 | 'c' => 3, 14 | } 15 | notice(has_key($valuehash, 'b')) 16 | 17 | # Result: true 18 | -------------------------------------------------------------------------------- /examples/module_apache.pp: -------------------------------------------------------------------------------- 1 | class { 'apache': 2 | default_vhost => false, 3 | } 4 | 5 | apache::vhost { 'cat-pictures.com': 6 | port => '80', 7 | docroot => '/var/www/cat-pictures', 8 | docroot_owner => 'www-data', 9 | docroot_group => 'www-data', 10 | } 11 | 12 | file { '/var/www/cat-pictures/index.html': 13 | content => "", 14 | owner => 'www-data', 15 | group => 'www-data', 16 | } 17 | -------------------------------------------------------------------------------- /examples/module_archive.pp: -------------------------------------------------------------------------------- 1 | file { '/var/www': 2 | ensure => directory, 3 | } 4 | 5 | archive { '/tmp/wordpress.tar.gz': 6 | ensure => present, 7 | extract => true, 8 | extract_path => '/var/www', 9 | source => 'https://wordpress.org/latest.tar.gz', 10 | creates => '/var/www/wordpress', 11 | cleanup => true, 12 | } 13 | -------------------------------------------------------------------------------- /examples/module_mysql.pp: -------------------------------------------------------------------------------- 1 | # Install MySQL and set up an example database 2 | class { 'mysql::server': 3 | root_password => 'correct horse battery staple', 4 | remove_default_accounts => true, 5 | } 6 | 7 | mysql::db { 'cat_pictures': 8 | user => 'greebo', 9 | password => 'tabby', 10 | host => 'localhost', 11 | grant => ['SELECT', 'UPDATE'], 12 | } 13 | -------------------------------------------------------------------------------- /examples/node_app1.pp: -------------------------------------------------------------------------------- 1 | node 'app1' { 2 | file { '/tmp/only_on_app1': 3 | content => "I'm only needed on the server named 'app1'!", 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /examples/node_modules.pp: -------------------------------------------------------------------------------- 1 | node 'app1' { 2 | include postgresql 3 | include apache 4 | include java 5 | include tomcat 6 | include my_app 7 | } 8 | -------------------------------------------------------------------------------- /examples/node_regex.pp: -------------------------------------------------------------------------------- 1 | node /^app[\d+]$/ { 2 | include my_app 3 | } 4 | -------------------------------------------------------------------------------- /examples/ntp.pp: -------------------------------------------------------------------------------- 1 | # Manage NTP 2 | class ntp ( 3 | String $version = 'installed', 4 | ) { 5 | ensure_packages(['ntp'], 6 | { 7 | 'ensure' => $version, 8 | } 9 | ) 10 | } 11 | 12 | class { 'ntp': 13 | version => 'latest', 14 | } 15 | -------------------------------------------------------------------------------- /examples/ntp2.pp: -------------------------------------------------------------------------------- 1 | # Manage NTP 2 | class ntp2 ( 3 | Boolean $start_at_boot, 4 | String[1] $version = 'installed', 5 | Enum['running', 'stopped'] $service_state = 'running', 6 | ) { 7 | ensure_packages(['ntp'], 8 | { 9 | 'ensure' => $version, 10 | } 11 | ) 12 | 13 | service { 'ntp': 14 | ensure => $service_state, 15 | enable => $start_at_boot, 16 | } 17 | } 18 | 19 | class { 'ntp2': 20 | start_at_boot => true, 21 | version => latest, 22 | service_state => running, 23 | } 24 | -------------------------------------------------------------------------------- /examples/package.pp: -------------------------------------------------------------------------------- 1 | package { 'cowsay': 2 | ensure => installed, 3 | } 4 | -------------------------------------------------------------------------------- /examples/package_ensure.pp: -------------------------------------------------------------------------------- 1 | ensure_packages(['cowsay']) 2 | -------------------------------------------------------------------------------- /examples/package_ensure_params.pp: -------------------------------------------------------------------------------- 1 | ensure_packages(['rake'], 2 | { 3 | 'provider' => 'gem', 4 | } 5 | ) 6 | -------------------------------------------------------------------------------- /examples/package_file_service.pp: -------------------------------------------------------------------------------- 1 | package { 'mysql-server': 2 | ensure => installed, 3 | notify => Service['mysql'], 4 | } 5 | 6 | file { '/etc/mysql/mysql.cnf': 7 | source => '/vagrant/examples/files/mysql.cnf', 8 | notify => Service['mysql'], 9 | } 10 | 11 | service { 'mysql': 12 | ensure => running, 13 | enable => true, 14 | } 15 | -------------------------------------------------------------------------------- /examples/package_file_service_require.pp: -------------------------------------------------------------------------------- 1 | package { 'mysql-server': 2 | ensure => installed, 3 | } 4 | 5 | file { '/etc/mysql/mysql.cnf': 6 | source => '/vagrant/examples/files/mysql.cnf', 7 | notify => Service['mysql'], 8 | require => Package['mysql-server'], 9 | } 10 | 11 | service { 'mysql': 12 | ensure => running, 13 | enable => true, 14 | require => [Package['mysql-server'], File['/etc/mysql/mysql.cnf']], 15 | } 16 | -------------------------------------------------------------------------------- /examples/package_gem.pp: -------------------------------------------------------------------------------- 1 | package { 'ruby': 2 | ensure => installed, 3 | } 4 | 5 | package { 'bundler': 6 | ensure => installed, 7 | provider => gem, 8 | } 9 | -------------------------------------------------------------------------------- /examples/package_puppet_gem.pp: -------------------------------------------------------------------------------- 1 | package { 'puppet-lint': 2 | ensure => installed, 3 | provider => puppet_gem, 4 | } 5 | -------------------------------------------------------------------------------- /examples/package_remove.pp: -------------------------------------------------------------------------------- 1 | package { 'apparmor': 2 | ensure => absent, 3 | } 4 | -------------------------------------------------------------------------------- /examples/package_url.pp: -------------------------------------------------------------------------------- 1 | package { 'docker-engine': 2 | provider => dpkg, 3 | source => 'http://apt.dockerproject.org/repo/pool/main/d/docker-engine/docker-engine_1.11.0-0~xenial_amd64.deb', 4 | } 5 | -------------------------------------------------------------------------------- /examples/package_version.pp: -------------------------------------------------------------------------------- 1 | package { 'openssl': 2 | ensure => '1.0.2g-1ubuntu4.1', 3 | } 4 | -------------------------------------------------------------------------------- /examples/pick.pp: -------------------------------------------------------------------------------- 1 | $remote_host = '' 2 | notice(pick($remote_host, 'localhost')) 3 | 4 | # Result: 'localhost' 5 | -------------------------------------------------------------------------------- /examples/profile_nginx.pp: -------------------------------------------------------------------------------- 1 | # Install Nginx from mainline repo 2 | class profile::nginx { 3 | class { 'nginx': 4 | manage_repo => true, 5 | package_source => 'nginx-mainline', 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /examples/profile_tomcat.pp: -------------------------------------------------------------------------------- 1 | # Site-specific Tomcat configuration 2 | class profile::tomcat { 3 | tomcat::install { '/usr/share/tomcat7': 4 | install_from_source => false, 5 | package_ensure => present, 6 | package_name => ['libtomcat7-java','tomcat7-common','tomcat7'], 7 | } 8 | 9 | exec { 'reload-tomcat': 10 | command => '/usr/sbin/service tomcat7 restart', 11 | refreshonly => true, 12 | } 13 | 14 | lookup('tomcat_allowed_ips', Array[String[7]]).each |String $source_ip| { 15 | firewall { "100 Tomcat access from ${source_ip}": 16 | proto => 'tcp', 17 | dport => '8080', 18 | source => $source_ip, 19 | action => 'accept', 20 | } 21 | } 22 | 23 | file { '/usr/share/tomcat7/logs': 24 | ensure => directory, 25 | owner => 'tomcat7', 26 | require => Tomcat::Install['/usr/share/tomcat7'], 27 | } 28 | 29 | file { '/etc/logrotate.d/tomcat7': 30 | source => 'puppet:///site-modules/profile/tomcat/tomcat7.logrotate', 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /examples/pry.pp: -------------------------------------------------------------------------------- 1 | pry() 2 | -------------------------------------------------------------------------------- /examples/pry_install.pp: -------------------------------------------------------------------------------- 1 | ensure_packages(['pry'], 2 | { 3 | 'provider' => 'puppet_gem', 4 | } 5 | ) 6 | -------------------------------------------------------------------------------- /examples/regex.pp: -------------------------------------------------------------------------------- 1 | $candidate = 'foo' 2 | notice($candidate =~ /foo/) # literal 3 | notice($candidate =~ /f/) # substring 4 | notice($candidate =~ /f.*/) # f followed by zero or more characters 5 | notice($candidate =~ /f.o/) # f, any character, o 6 | notice($candidate =~ /fo+/) # f followed by one or more 'o's 7 | notice($candidate =~ /[fgh]oo/) # f, g, or h followed by 'oo' 8 | -------------------------------------------------------------------------------- /examples/resource_array.pp: -------------------------------------------------------------------------------- 1 | $dependencies = [ 2 | 'php7.0-cgi', 3 | 'php7.0-cli', 4 | 'php7.0-common', 5 | 'php7.0-gd', 6 | 'php7.0-json', 7 | 'php7.0-mcrypt', 8 | 'php7.0-mysql', 9 | 'php7.0-soap', 10 | ] 11 | 12 | package { $dependencies: 13 | ensure => installed, 14 | } 15 | -------------------------------------------------------------------------------- /examples/role_app_server.pp: -------------------------------------------------------------------------------- 1 | # Be an app server 2 | class role::app_server { 3 | include postgresql 4 | include apache 5 | include java 6 | include tomcat 7 | include my_app 8 | } 9 | 10 | node 'app1' { 11 | include role::app_server 12 | } 13 | -------------------------------------------------------------------------------- /examples/role_app_server_profiles.pp: -------------------------------------------------------------------------------- 1 | # Be an app server 2 | class role::app_server { 3 | include profile::postgresql 4 | include profile::apache 5 | include profile::java 6 | include profile::tomcat 7 | include profile::my_app 8 | } 9 | -------------------------------------------------------------------------------- /examples/run-puppet.pp: -------------------------------------------------------------------------------- 1 | # Set up regular Puppet runs 2 | file { '/usr/local/bin/run-puppet': 3 | source => '/etc/puppetlabs/code/environments/production/files/run-puppet.sh', 4 | mode => '0755', 5 | } 6 | 7 | cron { 'run-puppet': 8 | command => '/usr/local/bin/run-puppet', 9 | hour => '*', 10 | minute => '*/15', 11 | } 12 | -------------------------------------------------------------------------------- /examples/service.pp: -------------------------------------------------------------------------------- 1 | service { 'sshd': 2 | ensure => running, 3 | enable => true, 4 | } 5 | -------------------------------------------------------------------------------- /examples/service_custom_restart.pp: -------------------------------------------------------------------------------- 1 | service { 'ntp': 2 | ensure => running, 3 | enable => true, 4 | restart => '/bin/echo Restarting >>/tmp/debug.log && systemctl restart ntp', 5 | } 6 | -------------------------------------------------------------------------------- /examples/service_hasrestart.pp: -------------------------------------------------------------------------------- 1 | service { 'ntp': 2 | ensure => running, 3 | enable => true, 4 | hasrestart => true, 5 | } 6 | -------------------------------------------------------------------------------- /examples/service_hasstatus.pp: -------------------------------------------------------------------------------- 1 | service { 'ntp': 2 | ensure => running, 3 | enable => true, 4 | hasstatus => false, 5 | } 6 | -------------------------------------------------------------------------------- /examples/service_pattern.pp: -------------------------------------------------------------------------------- 1 | service { 'ntp': 2 | ensure => running, 3 | enable => true, 4 | hasstatus => false, 5 | pattern => 'ntpd', 6 | } 7 | -------------------------------------------------------------------------------- /examples/ssh_authorized_key.pp: -------------------------------------------------------------------------------- 1 | ssh_authorized_key { 'john@bitfieldconsulting.com': 2 | user => 'vagrant', 3 | type => 'ssh-rsa', 4 | key => 'AAAAB3NzaC1yc2EAAAABIwAAAIEA3ATqENg+GWACa2BzeqTdGnJhNoBer8x6pfWkzNzeM8Zx7/2Tf2pl7kHdbsiTXEUawqzXZQtZzt/j3Oya+PZjcRpWNRzprSmd2UxEEPTqDw9LqY5S2B8og/NyzWaIYPsKoatcgC7VgYHplcTbzEhGu8BsoEVBGYu3IRy5RkAcZik=', 5 | } 6 | -------------------------------------------------------------------------------- /examples/string_interpolation.pp: -------------------------------------------------------------------------------- 1 | $my_name = 'John' 2 | notice("Hello, ${my_name}! It's great to meet you!") 3 | -------------------------------------------------------------------------------- /examples/template_compute.epp: -------------------------------------------------------------------------------- 1 | innodb_buffer_pool_size=<%= $facts['memory']['system']['total_bytes'] * 3/4 %> 2 | -------------------------------------------------------------------------------- /examples/template_hiera.epp: -------------------------------------------------------------------------------- 1 | AllowUsers<% lookup('users').each | $user | { -%> 2 | <%= $user -%> 3 | <% } %> 4 | -------------------------------------------------------------------------------- /examples/template_hiera_params.epp: -------------------------------------------------------------------------------- 1 | <% | Array[String] $users | -%> 2 | AllowUsers<% $users.each | $user | { -%> 3 | <%= $user -%> 4 | <% } %> 5 | -------------------------------------------------------------------------------- /examples/template_if.epp: -------------------------------------------------------------------------------- 1 | <% if $ssl_enabled { -%> 2 | ## SSL directives 3 | SSLEngine on 4 | SSLCertificateFile "<%= $ssl_cert %>" 5 | SSLCertificateKeyFile "<%= $ssl_key %>" 6 | ... 7 | <% } -%> 8 | -------------------------------------------------------------------------------- /examples/template_iterate.epp: -------------------------------------------------------------------------------- 1 | <% $facts['networking']['interfaces'].each |String $interface, Hash $attrs| { -%> 2 | interface <%= $interface %>; 3 | <% } -%> 4 | -------------------------------------------------------------------------------- /examples/template_iterate2.epp: -------------------------------------------------------------------------------- 1 | <% $facts['networking']['interfaces'].each |String $interface, Hash $attrs| { -%> 2 | local_address <%= $attrs['bindings'][0]['address'] %>; 3 | <% } -%> 4 | -------------------------------------------------------------------------------- /examples/template_params.epp: -------------------------------------------------------------------------------- 1 | <% | String[1] $aws_access_key, 2 | String[1] $aws_secret_key, 3 | | -%> 4 | aws_access_key_id = <%= $aws_access_key %> 5 | aws_secret_access_key = <%= $aws_secret_key %> 6 | -------------------------------------------------------------------------------- /examples/user.pp: -------------------------------------------------------------------------------- 1 | group { 'devs': 2 | ensure => present, 3 | gid => 3000, 4 | } 5 | 6 | user { 'hsing-hui': 7 | ensure => present, 8 | uid => '3001', 9 | home => '/home/hsing-hui', 10 | shell => '/bin/bash', 11 | groups => ['devs'], 12 | } 13 | -------------------------------------------------------------------------------- /examples/user_remove.pp: -------------------------------------------------------------------------------- 1 | user { 'godot': 2 | ensure => absent, 3 | } 4 | -------------------------------------------------------------------------------- /examples/variable_array.pp: -------------------------------------------------------------------------------- 1 | $heights = [193, 120, 181, 164, 172] 2 | 3 | $first_height = $heights[0] 4 | -------------------------------------------------------------------------------- /examples/variable_hash.pp: -------------------------------------------------------------------------------- 1 | $heights = { 2 | 'john' => 193, 3 | 'rabiah' => 120, 4 | 'abigail' => 181, 5 | 'melina' => 164, 6 | 'sumiko' => 172, 7 | } 8 | 9 | notice("John's height is ${heights['john']}cm.") 10 | -------------------------------------------------------------------------------- /examples/variable_simple.pp: -------------------------------------------------------------------------------- 1 | $my_name = 'Zaphod Beeblebrox' 2 | $answer = 42 3 | $scheduled_for_demolition = true 4 | -------------------------------------------------------------------------------- /examples/variable_string.pp: -------------------------------------------------------------------------------- 1 | $php_package = 'php7.0-cli' 2 | 3 | package { $php_package: 4 | ensure => installed, 5 | } 6 | --------------------------------------------------------------------------------