### Example: Enable Enterprise Linux 8 Repository Source: https://help.puppet.com/core/current/Content/PuppetCore/enable_the_puppet_platform_yum.htm Example command to enable the Enterprise Linux 8 repository by installing its release package. ```bash sudo rpm -Uvh https://yum-puppetcore.puppet.com/public/puppet8-release-el-8.noarch.rpm ``` -------------------------------- ### Example: Enable Ubuntu Focal Repository Source: https://help.puppet.com/core/current/Content/PuppetCore/enable_the_puppet_platform_apt.htm This example demonstrates enabling the Ubuntu focal repository by downloading and installing the specific release package for that distribution. ```bash wget --content-disposition https://apt-puppetcore.puppet.com/public/puppet8-release-focal.deb sudo dpkg -i puppet8-release-focal.deb ``` -------------------------------- ### Example Resource List for get() Method Source: https://help.puppet.com/core/current/Content/PuppetCore/writing_the_type_and_provider.htm Provides an example of the data structure returned by the `get(context)` method in a Puppet provider. This list of hashes describes the current state of resources on the target system. ```ruby [ { name: 'a', ensure: 'present', }, { name: 'b', ensure: 'present', }, ] ``` -------------------------------- ### Install MSI and EXE Packages on Windows Source: https://help.puppet.com/core/current/Content/PuppetCore/resources_package_windows.htm Example of installing an MSI package and an EXE package using the 'package' resource. Ensure the 'source' attribute points to the correct package file and 'install_options' are correctly formatted for each package type. ```puppet package { 'mysql': ensure => '5.5.16', source => 'N:\packages\mysql-5.5.16-winx64.msi', install_options => ['INSTALLDIR=C:\mysql-5.5'], } package { "Git version 1.8.4-preview20130916": ensure => present, source => 'C:\code\puppetlabs\temp\windowsexample\Git-1.8.4-preview20130916.exe', install_options => ['/VERYSILENT'] } ``` -------------------------------- ### Example get method with simple_get_filter Source: https://help.puppet.com/core/current/Content/PuppetCore/provider_features.htm Provides a basic implementation of the get method for the apt_key provider. This method can be optimized when the 'simple_get_filter' feature is enabled. ```ruby class Puppet::Provider::AptKey::AptKey def get(context, names = nil) [ { name: 'name', # ... }, ] end end ``` -------------------------------- ### Example Apt Repository URL for Puppet 8 on Ubuntu Jammy Source: https://help.puppet.com/core/current/Content/PuppetCore/enable_the_puppet_platform_repository.htm A concrete example of an Apt repository URL for installing Puppet 8 on Ubuntu Jammy. ```bash https://apt-puppetcore.puppet.com/public/puppet8-release-jammy.deb ``` -------------------------------- ### Install Pry using lein gem Source: https://help.puppet.com/core/current/Content/PuppetCore/server/gems.htm This example shows how to install the `pry` gem for development using `lein gem`. The `--` argument passes subsequent options to the `gem install` command. ```bash $ lein gem --config ~/.puppetserver/puppetserver.conf -- install pry \ --no-document Fetching: coderay-1.1.0.gem (100%) Successfully installed coderay-1.1.0 Fetching: slop-3.6.0.gem (100%) Successfully installed slop-3.6.0 Fetching: method_source-0.8.2.gem (100%) Successfully installed method_source-0.8.2 Fetching: spoon-0.0.4.gem (100%) Successfully installed spoon-0.0.4 Fetching: pry-0.10.1-java.gem (100%) Successfully installed pry-0.10.1-java 5 gems installed ``` -------------------------------- ### Install MySQL with specific options Source: https://help.puppet.com/core/current/Content/PuppetCore/Markdown/package.htm Demonstrates how to install a Windows package with custom installation options, including silent installation and specifying an installation directory. Note that file paths in install options must use backslashes, and backslashes in double-quoted strings must be escaped. ```Puppet package { 'mysql': ensure => installed, source => 'N:/packages/mysql-5.5.16-winx64.msi', install_options => [ '/S', { 'INSTALLDIR' => 'C:\\mysql-5.5' } ], } ``` -------------------------------- ### Install Executable with Complex Install Options Source: https://help.puppet.com/core/current/Content/PuppetCore/resources_package_windows.htm Demonstrates how to pass complex installation options, including quoted arguments and log file paths, to an executable installer. Options must be split into individual strings, and paths with spaces should be handled carefully. ```puppet install_options => [ '/s', "/v\"MANAGEMENT_SERVER=${management_server}", '/l*v!', "${install_log}", '/qn', '"' ], ``` -------------------------------- ### Example: Retrieving a file Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/http_file_bucket_file.htm This example shows how to retrieve a file from the filebucket using a GET request, specifying the accept header and expecting the file content in the response. ```http > GET /puppet/v3/file_bucket_file/md5/4949e56d376cc80ce5387e8e89a75396//home/user/myfile.txt?environment=production HTTP/1.1 > Accept: application/octet-stream < HTTP/1.1 200 OK < Content-Length: 24 < This is the file content ``` -------------------------------- ### Install with Hash-Based Install Options Source: https://help.puppet.com/core/current/Content/PuppetCore/resources_package_windows.htm Shows how to use hash notation for install options, which is recommended for file path arguments that might contain spaces. This ensures proper handling of paths like INSTALLDIR. ```puppet install_options => [ { 'INSTALLDIR' => ${packagedir} } ] ``` -------------------------------- ### Example Yum Repository URL for Puppet 8 on EL 8 Source: https://help.puppet.com/core/current/Content/PuppetCore/enable_the_puppet_platform_repository.htm A concrete example of a Yum repository URL for installing Puppet 8 on an EL 8 system. ```bash https://yum-puppetcore.puppet.com/public/puppet8-release-el-8.noarch.rpm ``` -------------------------------- ### Example GET Request and Response for Simple Endpoint Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/status-api/v1/simple.htm Demonstrates a successful GET request to the /status/v1/simple endpoint, showing the expected 200 OK status and 'running' response body. ```http GET /status/v1/simple HTTP/1.1 200 OK Content-Type: application/json running ``` -------------------------------- ### Include Main Cat Class Source: https://help.puppet.com/core/current/Content/PuppetCore/modules_readme.htm Use this snippet to install a basic cat with default options. This is the minimum required to get the module up and running. ```puppet include '::cat' ``` -------------------------------- ### Example Module Path Structure Source: https://help.puppet.com/core/current/Content/PuppetCore/style_guide_modules.htm Shows the directory structure for placing example manifests within a module. These examples demonstrate major use cases. ```puppet modulepath/apache/examples/{usecase}.pp ``` -------------------------------- ### Example Node GET Request and Response Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/http_node.htm Demonstrates a typical GET request to the node endpoint with parameters and a sample JSON response containing node details and parameters. ```http > GET /puppet/v3/node/mycertname?environment=production&transaction_uuid=aff261a2-1a34-4647-8c20-ff662ec11c4c&configured_environment=production HTTP/1.1 > Accept: application/json, text/pson < HTTP/1.1 200 OK < Content-Type: application/json < Content-Length: 4630 { "name":"thinky.corp.puppetlabs.net", "parameters":{ "architecture":"amd64", "kernel":"Linux", "blockdevices":"sda,sr0", "clientversion":"3.3.1", "clientnoop":"false", "environment":"production", ... }, "environment":"production" } ``` -------------------------------- ### Documenting a Puppet Plan Source: https://help.puppet.com/core/current/Content/PuppetCore/puppet_strings_style.htm This example demonstrates how to document a Puppet plan using standard Puppet documentation tags and code examples. It includes a summary, parameter descriptions, and a usage example. ```puppet # @summary A simple plan. # # @param param1 # First parameter description. # @param param2 # Second parameter description. # @param param3 # Third parameter description. plan mymodule::my_plan(String $param1, $param2, Integer $param3 = 1) { run_task('mymodule::lb_remove', $param1, target => $param2) } ``` -------------------------------- ### Install Gems with Bundle Client Source: https://help.puppet.com/core/current/Content/PuppetCore/install_gems.htm Run the `bundle install` command to download and install gems, including the Puppet gem, from the configured protected repository. ```bash bundle install ``` -------------------------------- ### Hiera v3 Configuration Example Source: https://help.puppet.com/core/current/Content/PuppetCore/legacy_hiera_3_backends.htm This is an example of a Hiera v3 configuration file using legacy backends. ```yaml --- :backends: - mongodb - xml :mongodb: :connections: :dbname: hdata :collection: config :host: localhost :xml: :datadir: /some/other/dir :hierarchy: - "% {trusted.certname}" - "common" ``` -------------------------------- ### Example Error Message for PE-only Module Installation Source: https://help.puppet.com/core/current/Content/PuppetCore/modules_pe_troubleshooting.htm This is an example of the error message received when attempting to install a PE-only module without a valid PE license or proper node configuration. ```text Error: Request to Puppet Forge failed. The server being queried was https://forgeapi.puppetlabs.com/v3/releases?module=puppetlabs-f5&module_groups=base+pe_only The HTTP response we received was '403 Forbidden' The message we received said 'You must have a valid Puppet Enterprise license on this node in order to download puppetlabs-f5. If you have a Puppet Enterprise license, please see https://docs.puppetlabs.com/pe/latest/modules_installing.html#puppet-enterprise-modules for more information.' ``` -------------------------------- ### Start Puppet Server Service Source: https://help.puppet.com/core/current/Content/PuppetCore/server/install_from_packages.htm This command starts the Puppet Server service after installation. It is a systemd-based command. ```bash sudo systemctl start puppetserver ``` -------------------------------- ### Serve Documentation with Custom Modulepath Source: https://help.puppet.com/core/current/Content/PuppetCore/puppet_strings_reference.htm Example of serving documentation locally with a specified modulepath. ```bash puppet strings server --modulepath path/to/modules ``` -------------------------------- ### File Not Found Example Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/http_file_content.htm Example of a GET request for a file that does not exist. The server responds with a 404 Not Found status. ```http GET /puppet/v3/file_content/modules/example/not_found?environment=env Accept: application/octet-stream HTTP/1.1 404 Not Found Content-Type: text/plain Not Found: Could not find file_content modules/example/not_found ``` -------------------------------- ### Pattern Starts with Lowercase Letter or 'None' Example Source: https://help.puppet.com/core/current/Content/PuppetCore/lang_data_abstract_flexible.htm Matches strings starting with a lowercase letter or the exact string 'None'. ```puppet Pattern[/\A[a-z].*/, /\ANone\Z/] ``` -------------------------------- ### Serve Documentation for a Specific Module Source: https://help.puppet.com/core/current/Content/PuppetCore/puppet_strings_reference.htm Example of serving documentation locally for a single named module. ```bash puppet strings server concat ``` -------------------------------- ### Path List Setting Example (*nix) Source: https://help.puppet.com/core/current/Content/PuppetCore/config_file_main.htm Provides an example of a setting like 'environmentpath' that accepts a list of directories, using the colon separator for *nix systems. ```ini # *nix version: environmentpath = $codedir/special_environments:$codedir/environments ``` -------------------------------- ### No File Name Provided Example Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/http_file_content.htm Example of a GET request where the file name is missing. The server responds with a 400 Bad Request status. ```http GET /puppet/v3/file_content?environment=env HTTP/1.1 400 Bad Request Content-Type: text/plain No request key specified in /puppet/v3/file_content/ ``` -------------------------------- ### Initialize Development Environment Source: https://help.puppet.com/core/current/Content/PuppetCore/server/dev_running_from_source.htm Remove any old configuration and run the dev-setup script to initialize all required configuration files and directories for development. ```bash # Remove any old config if you want to make sure you're using the latest # defaults $ rm -rf ~/.puppetserver # Run the `dev-setup` script to initialize all required configuration $ ./dev-setup ``` -------------------------------- ### Manage Package Installation with a Parameter Source: https://help.puppet.com/core/current/Content/PuppetCore/bgtm.htm This snippet demonstrates how to conditionally manage package installation using a boolean parameter. It's useful for controlling whether a package should be installed as part of a module's setup. ```puppet class ntp::install { if $ntp::package_manage { package { $ntp::package_name: ensure => $ntp::package_ensure, } } } ``` -------------------------------- ### Apt Package Installation Options Source: https://help.puppet.com/core/current/Content/PuppetCore/Markdown/type.htm Shows how to use the 'install_options' attribute with the apt provider to pass flags to apt-get. Options can be strings or hashes. ```puppet package { 'mypackage': ensure => installed, install_options => [ '-o', 'Dpkg::Options::=--force-confold', '-o', 'Dpkg::Options::=--force-confnew' ], } ``` -------------------------------- ### Sample Module Structure Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/http_file_metadata.htm Illustrates the directory and file structure of the 'example' module used in the API examples. This includes a regular file, a symbolic link pointing to that file, and a subdirectory with another file. ```text /etc/puppetlabs/code/modules/example/ files/ just_a_file.txt link_to_file.txt -> /etc/puppetlabs/code/modules/example/files/just_a_file.txt subdirectory/ another_file.txt ``` -------------------------------- ### Example: Wrong file name retrieval attempt Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/http_file_bucket_file.htm This example illustrates a scenario where a GET request for a file with an incorrect name results in a 404 Not Found response. ```http > GET /puppet/v3/file_bucket_file/md5/4949e56d376cc80ce5387e8e89a75396//home/user/wrong_name?environment=production HTTP/1.1 > Accept: application/octet-stream < HTTP/1.1 404 Not Found < < Not Found: Could not find file_bucket_file md5/4949e56d376cc80ce5387e8e89a75396/home/user/wrong_name ``` -------------------------------- ### Example Apt Repository URL Source: https://help.puppet.com/core/current/Content/PuppetCore/enable_the_puppet_platform_repository.htm This is an example URL for enabling a Puppet Core repository on Debian or Ubuntu systems using Apt. Replace placeholders with your specific platform version and code name. ```bash https://apt-puppetcore.puppet.com/public/-release-.deb ``` -------------------------------- ### Module Operating System Support Example Source: https://help.puppet.com/core/current/Content/PuppetCore/modules_metadata.htm Lists compatible operating systems and their versions for the module. ```json { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] } ``` -------------------------------- ### Example Repository Configuration File Source: https://help.puppet.com/core/current/Content/PuppetCore/enable_the_puppet_platform_yum.htm Example content of a Puppet Core repository configuration file, including authentication details. ```ini [puppet8] name=Puppet 8 Repository el 8 - $basearch baseurl=https://yum-puppetcore.puppet.com/puppet8/el/8/$basearch gpgkey=file:///etc/pki/rpm-gpg/ enabled=1 gpgcheck=1 ## Add authentication here by uncommenting and filling in values username=forge-key password= ``` -------------------------------- ### Retrieve File Content Example Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/http_file_content.htm Example of a successful GET request to retrieve the content of a file within a module. Ensure the Accept header is set to application/octet-stream. ```http GET /puppet/v3/file_content/modules/example/my_file?environment=env Accept: application/octet-stream HTTP/1.1 200 OK Content-Type: application/octet-stream Content-Length: 16 this is my file ``` -------------------------------- ### Example *nix Modulepath Source: https://help.puppet.com/core/current/Content/PuppetCore/dirs_modulepath.htm Illustrates the directory structure for the modulepath on *nix systems, with directories separated by colons. ```text /etc/puppetlabs/code/environments/production/modules:/etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules ``` -------------------------------- ### Launch Clojure REPL and Run Server Source: https://help.puppet.com/core/current/Content/PuppetCore/server/dev_running_from_source.htm Launch the Clojure REPL and start the Puppet Server using the `go` command. The `help` command can be used to see available commands. ```clojure $ lein repl # Run dev-tools=> (go) dev-tools=> (help) ``` -------------------------------- ### GET /status/v1/services?level=debug Request and Response Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/status-api/v1/services.htm This example demonstrates a debug-level GET request to the services endpoint and its corresponding JSON response, showing detailed status and JVM metrics. ```http GET /status/v1/services?level=debug HTTP/1.1 200 OK Content-Type: application/json { "status-service": { "detail_level": "debug", "service_status_version": 1, "service_version": "0.3.5", "state": "running", "status": { "experimental": { "jvm-metrics": { "heap-memory": { "committed": 1049100288, "init": 268435456, "max": 1908932608, "used": 216512656 }, "non-heap-memory": { "committed": 256466944, "init": 2555904, "max": -1, "used": 173201432 }, "start-time-ms": 1472496731281, "up-time-ms": 538974 } } } } } ``` -------------------------------- ### Generate Documentation for Specific Files Source: https://help.puppet.com/core/current/Content/PuppetCore/puppet_strings_reference.htm Example of generating documentation for specific manifest files. ```bash puppet strings generate manifest1.pp manifest2.pp ``` -------------------------------- ### Pattern Starts with Lowercase Letter Example Source: https://help.puppet.com/core/current/Content/PuppetCore/lang_data_abstract_flexible.htm Matches any string that begins with a lowercase letter. ```puppet Pattern[/\A[a-z].*/] ``` -------------------------------- ### List of Words Setting Example Source: https://help.puppet.com/core/current/Content/PuppetCore/config_file_main.htm Shows how to specify multiple values for a setting like 'reports' using a comma-separated list. ```ini report = http,puppetdb ``` -------------------------------- ### Example: CSR not found Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/http_certificate_request.htm Illustrates a GET request for a non-existent CSR, resulting in a 404 Not Found response. ```http GET /puppet-ca/v1/certificate_request/does_not_exist HTTP/1.1 404 Not Found Content-Type: text/plain Not Found: Could not find certificate_request does_not_exist ``` -------------------------------- ### Handle Slice Errors with Lambda using get Source: https://help.puppet.com/core/current/Content/PuppetCore/Markdown/function.htm Provides a lambda for error handling in the 'get' function. This example catches a 'SLICE_ERROR' when trying to access a non-existent key in a nested structure and logs the walked path. ```puppet $x = [1, 2, ['blue']] $x.get('2.color') |$error| { notice("Walked path is ${error.details['walked_path']}") } ``` -------------------------------- ### Comment Line Example Source: https://help.puppet.com/core/current/Content/PuppetCore/config_file_main.htm Demonstrates the correct syntax for a comment line in puppet.conf, which must start with a hash symbol. ```ini # This is a comment. ``` -------------------------------- ### Parameter Documentation Example Source: https://help.puppet.com/core/current/Content/PuppetCore/puppet_strings_style.htm Illustrates how to document a parameter, including its name, description, and additional usage notes. This format is used for classes, defined types, and functions. ```puppet # @param noselect_servers # Specifies one or more peers to not sync with. Puppet appends 'noselect' to each matching item in the `servers` array. ``` -------------------------------- ### Example: No node name provided Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/http_certificate_request.htm Shows a GET request without a node name, which leads to a 400 Bad Request error. ```http GET /puppet-ca/v1/certificate_request HTTP/1.1 400 Bad Request Content-Type: text/plain No request key specified in /puppet-ca/v1/certificate_request ``` -------------------------------- ### Example: CSR found Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/http_certificate_request.htm Demonstrates a successful GET request for a CSR, returning a 200 OK status and the CSR in PEM format. ```http GET /puppet-ca/v1/certificate_request/agency HTTP/1.1 200 OK Content-Type: text/plain -----BEGIN CERTIFICATE REQUEST----- MIIBnzCCAQwCAQAwYzELMAkGA1UEBhMCVUsxDzANBgNVBAgTBkxvbmRvbjEPMA0G A1UEBxMGTG9uZG9uMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQx DzANBgNVBAMTBmFnZW5jeTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAxSCr FKUKjVGFPuQ0iGM9mZKw94sOIgGohqrHH743kPvjsId3d38Qk+H+1DbVf42bQY0W kAVcwNDqmBnx0lOtQ0oeGnbbwlJFjhqXr8jFEljPrc9S2/IIILDf/FeYWw9lRiOV LoU6ZfCIBfq6v4D4KX3utRbOoELNyBeT6VA1ufMCAwEAAaAAMAkGBSsOAwIPBQAD gYEAno7O1jkR56TNMe1Cw/eyQUIaniG22+0kmoftjlcMYZ/IKCOz+HRgnDtBPf8j O5nt0PQN8YClW7Xx2U8ZTvBXn/UEKMtCBkbF+SULiayxPgfyKy/axinfutEChnHS ZtUMUBLlh+gGFqOuH69979SJ2QmQC6FNomTkYI7FOHD/TG0= -----END CERTIFICATE REQUEST----- ``` -------------------------------- ### Complete Hiera Configuration Example Source: https://help.puppet.com/core/current/Content/PuppetCore/config_syntax.htm A comprehensive example of a `hiera.yaml` file demonstrating various hierarchy levels, including node-specific data, datacenter-specific data, global data, encrypted secrets, OS defaults, and common data. It shows how to configure different backends and paths. ```yaml version: 5 defaults: datadir: data data_hash: yaml_data hierarchy: - name: "Per-node data" path: "nodes/%{trusted.certname}.yaml" - name: "Per-datacenter business group data" path: "location/%{facts.whereami}/%{facts.group}.yaml" - name: "Global business group data" path: "groups/%{facts.group}.yaml" - name: "Per-datacenter secret data (encrypted)" lookup_key: eyaml_lookup_key path: "secrets/nodes/%{trusted.certname}.eyaml" options: pkcs7_private_key: /etc/puppetlabs/puppet/eyaml/private_key.pkcs7.pem pkcs7_public_key: /etc/puppetlabs/puppet/eyaml/public_key.pkcs7.pem - name: "Per-OS defaults" path: "os/%{facts.os.family}.yaml" - name: "Common data" path: "common.yaml" ``` -------------------------------- ### Download and Store Catalog API Example Source: https://help.puppet.com/core/current/Content/PuppetCore/Markdown/catalog.htm An example demonstrating the download action for plugins, facts, and catalogs within the Puppet API. ```ruby Puppet::Face[:plugin, '0.0.1'].download Puppet::Face[:facts, '0.0.1'].upload Puppet::Face[:catalog, '0.0.1'].download ## ... ``` -------------------------------- ### Class-Based Ordering Dependency Source: https://help.puppet.com/core/current/Content/PuppetCore/bgtm.htm This example shows how to establish a dependency on an entire class rather than individual resources. This approach simplifies dependency management by allowing changes within the 'module::install' class without affecting other manifests. ```puppet file { 'configuration': ensure => present, require => Class['module::install'], } ``` -------------------------------- ### Example: Retrieve all CSRs Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/http_certificate_request.htm Shows a GET request to retrieve all submitted CSRs. The response contains multiple PEM-formatted CSRs separated by '\n---\n'. ```http GET /puppet-ca/v1/certificate_requests/ignored Accept: text/plain HTTP/1.1 200 OK Content-Type: text/plain -----BEGIN CERTIFICATE REQUEST----- MIIBnzCCAQwCAQAwYzELMAkGA1UEBhMCVUsxDzANBgNVBAgTBkxvbmRvbjEPMA0G A1UEBxMGTG9uZG9uMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQx DzANBgNVBAMTBmFnZW5jeTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAxSCr FKUKjVGFPuQ0iGM9mZKw94sOIgGohqrHH743kPvjsId3d38Qk+H+1DbVf42bQY0W kAVcwNDqmBnx0lOtQ0oeGnbbwlJFjhqXr8jFEljPrc9S2/IIILDf/FeYWw9lRiOV LoU6ZfCIBfq6v4D4KX3utRbOoELNyBeT6VA1ufMCAwEAAaAAMAkGBSsOAwIPBQAD gYEAno7O1jkR56TNMe1Cw/eyQUIaniG22+0kmoftjlcMYZ/IKCOz+HRgnDtBPf8j O5nt0PQN8YClW7Xx2U8ZTvBXn/UEKMtCBkbF+SULiayxPgfyKy/axinfutEChnHS ZtUMUBLlh+gGFqOuH69979SJ2QmQC6FNomTkYI7FOHD/TG0= -----END CERTIFICATE REQUEST----- --- -----BEGIN CERTIFICATE REQUEST----- MIIBnjCCAQsCAQAwYjELMAkGA1UEBhMCVUsxDzANBgNVBAgTBkxvbmRvbjEPMA0G A1UEBxMGTG9uZG9uMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQx DjAMBgNVBAMTBWFnZW50MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC1tucK enT1CkDPgsCU/0e2cbzRsiKF8yHH7+ntF6Q3d9ZCaZWJ00mj0+YmiYrnum+KAikE 45Iaf9vaUV3CPsDVrUPOI8kYehiv868ZhP3nxblE6iuNBK+Fdv9GN/vKQrmL5iRE bIrOM3/lxpS7SpidGdA6EIVlS3604bwLY4xHNQIDAQABoAAwCQYFKw4DAg8FAAOB gQAXH0YFuidPqB6P2MyPEEGZ3rzozINBx/oXvGptXI60Zy5mgH6iAkrZfi57pEzP jFoO2JRaFxTJC1FVpc4zR1K6sq4h3fIMwqppJRX+5wJNKyhU61eY2gR2O/rAJzw4 wcUKf9JhoE7/p1cUulIIIq7t/ibCvf0LYSFwGqTwGqN2TQ== -----END CERTIFICATE REQUEST----- ``` -------------------------------- ### Example webserver.conf Configuration Source: https://help.puppet.com/core/current/Content/PuppetCore/config_general_notes.htm This snippet shows an example webserver.conf file for configuring the Puppet Server's web server settings, including SSL host, port, certificate paths, and client authentication. ```ini webserver: {  client-auth : want   ssl-host    : 0.0.0.0   ssl-port    : 8140   ssl-cert    : /path/to/server.pem   ssl-key     : /path/to/server.key   ssl-ca-cert : /path/to/ca_bundle.pem   ssl-cert-chain : /path/to/ca_bundle.pem   ssl-crl-path : /etc/puppetlabs/puppet/ssl/crl.pem } ``` -------------------------------- ### Puppet Octal Integer Examples Source: https://help.puppet.com/core/current/Content/PuppetCore/lang_data_number_octal_hex_integers.htm Demonstrates the correct and incorrect usage of octal integers in Puppet. Octal numbers must start with '0' and contain only digits 0-7. ```puppet $value = 0777 # evaluates to decimal 511 $value = 0789 # Error, invalid octal $value = 0777.3 # Error, invalid octal ``` -------------------------------- ### Get Variable with Default Value Source: https://help.puppet.com/core/current/Content/PuppetCore/Markdown/function.htm Retrieves a variable's value, providing a default if the variable does not exist. This example demonstrates accessing a nested value that is not present, triggering the default. ```puppet $x = [1,2,[{'name' =>'waldo'}]] getvar('x.2.1.name', 'not waldo') ``` -------------------------------- ### Create Custom Fact to Get Hardware Platform Source: https://help.puppet.com/core/current/Content/PuppetCore/executing_shell_commands_in_facts.htm This example demonstrates creating a custom fact named `hardware_platform` that executes a shell command to retrieve the hardware platform information. ```ruby # hardware_platform.rb Facter.add('hardware_platform') do setcode do Facter::Core::Execution.execute('/bin/uname --hardware-platform') end end ``` -------------------------------- ### Catalog Endpoint Request Examples Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/http_catalog.htm Demonstrates how to request a catalog using both POST and GET methods. The POST method is recommended for longer fact data to avoid URI length limits. ```http POST /puppet/v3/catalog/:nodename GET /puppet/v3/catalog/:nodename?environment=:environment ``` -------------------------------- ### Example environment.conf Source: https://help.puppet.com/core/current/Content/PuppetCore/config_file_environment.htm This snippet shows a typical environment.conf file, setting the module path and a custom config version script. It includes notes on Puppet Enterprise requirements and the use of $basemodulepath. ```puppet # /etc/puppetlabs/code/environments/test/environment.conf # Puppet Enterprise requires $basemodulepath; see note below under "modulepath". modulepath = site:dist:modules:$basemodulepath # Use our custom script to get a git commit for the current state of the code: config_version = get_environment_commit.sh ``` -------------------------------- ### DNF Package Installation Options Source: https://help.puppet.com/core/current/Content/PuppetCore/Markdown/type.htm Illustrates using the 'install_options' attribute with the dnf provider for passing command-line flags to dnf. Options can be strings or hashes. ```puppet package { 'mypackage': ensure => installed, install_options => [ '--best', '--allowerasing' ], } ``` -------------------------------- ### Upgrade Package by Specifying Version Source: https://help.puppet.com/core/current/Content/PuppetCore/resources_package_windows.htm Example of upgrading a package on Windows by replacing the source file and setting the 'ensure' attribute to the new version string. Puppet will detect the version mismatch and install the new package. ```puppet package { 'mysql': ensure => '5.5.16', source => 'N:\packages\mysql-5.5.16-winx64.msi', install_options => ['INSTALLDIR=C:\mysql-5.5'], } ``` -------------------------------- ### Define a Schedule Spanning Midnight Source: https://help.puppet.com/core/current/Content/PuppetCore/Markdown/schedule.htm This example demonstrates how to define a schedule that spans across midnight, allowing resources to be applied from late evening into the early morning. The 'weekday' attribute matches the day the range starts on. ```puppet schedule { 'maintenance_window': range => '22:00 - 04:00', weekday => 'Saturday', } ``` -------------------------------- ### Search File Metadata with links=manage Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/http_file_metadata.htm Retrieves file metadata for a module, recursively searching and ignoring entries starting with 'sub*', with links set to 'manage'. This example shows the metadata for files and directories, including symbolic links. ```bash GET /puppet/v3/file_metadatas/modules/example?environment=env&recurse=true&ignore=sub*&links=manage HTTP 200 OK Content-Type: text/pson [ { "checksum": { "type": "ctime", "value": "{ctime}2013-10-01 13:15:59 -0700" }, "destination": null, "group": 20, "links": "manage", "mode": 493, "owner": 501, "path": "/etc/puppetlabs/code/modules/example/files", "relative_path": ".", "type": "directory" }, { "checksum": { "type": "md5", "value": "{md5}d0a10f45491acc8743bc5a82b228f89e" }, "destination": null, "group": 20, "links": "manage", "mode": 420, "owner": 501, "path": "/etc/puppetlabs/code/modules/example/files", "relative_path": "just_a_file.txt", "type": "file" }, { "checksum": { "type": "md5", "value": "{md5}d0a10f45491acc8743bc5a82b228f89e" }, "destination": "/etc/puppetlabs/code/modules/example/files/just_a_file.txt", "group": 20, "links": "manage", "mode": 493, "owner": 501, "path": "/etc/puppetlabs/code/modules/example/files", "relative_path": "link_to_file.txt", "type": "link" } ] ``` -------------------------------- ### Basic String Conversion Examples Source: https://help.puppet.com/core/current/Content/PuppetCore/Markdown/function.htm Demonstrates basic string conversion of an integer and an array to their default string representations. ```Puppet $str = String(10) # produces '10' $str = String([10]) # produces '["10"]' ``` -------------------------------- ### Search File Metadata with links=follow Source: https://help.puppet.com/core/current/Content/PuppetCore/server/http_api/http_file_metadata.htm Retrieves file metadata for a module, recursively searching and ignoring entries starting with 'sub*', with links set to 'follow'. This example demonstrates how the 'destination' and 'type' fields differ for symbolic links when 'links' is set to 'follow'. ```bash GET /puppet/v3/file_metadatas/modules/example?environment=env&recurse=true&ignore=sub*&links=follow HTTP 200 OK Content-Type: text/pson [ { "checksum": { "type": "ctime", "value": "{ctime}2013-10-01 13:15:59 -0700" }, "destination": null, "group": 20, "links": "follow", "mode": 493, "owner": 501, "path": "/etc/puppetlabs/code/modules/example/files", "relative_path": ".", "type": "directory" }, { "checksum": { "type": "md5", "value": "{md5}d0a10f45491acc8743bc5a82b228f89e" }, "destination": null, "group": 20, "links": "follow", "mode": 420, "owner": 501, "path": "/etc/puppetlabs/code/modules/example/files", "relative_path": "just_a_file.txt", "type": "file" }, { "checksum": { "type": "md5", "value": "{md5}d0a10f45491acc8743bc5a82b228f89e" }, "destination": null, "group": 20, "links": "follow", "mode": 420, "owner": 501, "path": "/etc/puppetlabs/code/modules/example/files", "relative_path": "link_to_file.txt", "type": "file" } ] ``` -------------------------------- ### Run Setup Script Source: https://help.puppet.com/core/current/Content/PuppetCore/server/dev_running_from_source.htm Execute the ./dev-setup script to configure necessary files and directories within your ~/.puppetlabs directory. This simplifies the setup process. ```bash $ ./dev-setup ``` -------------------------------- ### Puppet Module Build Example Source: https://help.puppet.com/core/current/Content/PuppetCore/modules_command_reference.htm Use this command to prepare a local module for release by building an archive file. This action is deprecated; use the Puppet Development Kit instead. ```bash puppet module build modules/apache ``` -------------------------------- ### Install pry Gem for Puppet Server Source: https://help.puppet.com/core/current/Content/PuppetCore/server/dev_debugging.htm Install the JRuby-compatible `pry` gem for Ruby code introspection. Use `sudo` for packaged installations or `lein gem` for source installations. The `--no-ri --no-rdoc` flags are used to speed up installation. ```bash $ sudo puppetserver gem install pry --no-ri --no-rdoc ``` ```bash $ lein gem -c ~/puppetserver/puppetserver.conf -- install pry \ --no-ri --no-rdoc ```