puppet
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| puppet [2014/02/20 21:03] – [checking syntax on template] k2patel | puppet [2020/08/10 02:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Puppet (data center automation and configuration management framework) ====== | ====== Puppet (data center automation and configuration management framework) ====== | ||
| + | |||
| + | [[Puppet Upgrade 4.x to 5.x]] | ||
| ==== Puppet YUM Repository ==== | ==== Puppet YUM Repository ==== | ||
| Line 39: | Line 41: | ||
| </ | </ | ||
| + | ==== Puppet Dynamic values playground ==== | ||
| + | |||
| + | === EPP and passing values === | ||
| + | <code ruby> | ||
| + | $template_parameters = { | ||
| + | | ||
| + | test2 => $test:: | ||
| + | | ||
| + | } | ||
| + | |||
| + | content => epp(' | ||
| + | </ | ||
| + | ==== trimming values ==== | ||
| + | Following can grab the last character from the hostname and convert to integer to avoid warning. | ||
| + | <code ruby> | ||
| + | $esnumber = inline_epp('< | ||
| + | </ | ||
| + | ==== Checking Hiera Value ==== | ||
| + | **Trying to lookup vhostip value** | ||
| + | Using puppet command | ||
| + | |||
| + | <code bash> | ||
| + | puppet apply --environment=test -e " | ||
| + | </ | ||
| + | |||
| + | Using hiera command | ||
| + | <code bash> | ||
| + | hiera -c / | ||
| + | </ | ||
| ==== checking syntax on template ==== | ==== checking syntax on template ==== | ||
| Line 45: | Line 76: | ||
| </ | </ | ||
| - | [[ http:// | + | ==== Puppet hiera literal % ==== |
| + | Only supported in hiera 2+ | ||
| + | <code bash> | ||
| + | rewrites: | ||
| + | - | ||
| + | comment: ' | ||
| + | rewrite_cond: | ||
| + | - " | ||
| + | rewrite_rule: | ||
| + | - "(.*) https://%{literal(' | ||
| + | </ | ||
| - | [[ http://docs.puppetlabs.com/references/2.7.3/ | + | ==== Puppet - Hiera - Apache - create resource example ==== |
| + | === Value in Hiera with yaml backend === | ||
| + | <code yaml> | ||
| + | vhosts: | ||
| + | test.k2patel.in: | ||
| + | servername: ' | ||
| + | serveraliases: | ||
| + | - ' | ||
| + | docroot: '/ | ||
| + | manage_docroot: | ||
| + | port: 80 | ||
| + | priority: 0 | ||
| + | docroot_owner: | ||
| + | docroot_group: | ||
| + | access_log_file: | ||
| + | default_vhost: | ||
| + | ensure: ' | ||
| + | error_log_file: | ||
| + | log_level: ' | ||
| + | aliases: | ||
| + | - | ||
| + | scriptalias: | ||
| + | path: '/ | ||
| + | rewrites: | ||
| + | - | ||
| + | comment: ' | ||
| + | rewrite_cond: | ||
| + | - " | ||
| + | rewrite_rule: | ||
| + | - "(.*) https:// | ||
| + | test.k2patel.in_ssl: | ||
| + | servername: ' | ||
| + | serveraliases: | ||
| + | - ' | ||
| + | docroot: '/ | ||
| + | manage_docroot: | ||
| + | port: 443 | ||
| + | priority: 0 | ||
| + | docroot_owner: | ||
| + | docroot_group: | ||
| + | access_log_file: | ||
| + | default_vhost: | ||
| + | ensure: ' | ||
| + | error_log_file: | ||
| + | log_level: ' | ||
| + | aliases: | ||
| + | - | ||
| + | alias: '/ | ||
| + | path: '/ | ||
| + | - | ||
| + | alias: '/ | ||
| + | path: '/ | ||
| + | - | ||
| + | alias: '/ | ||
| + | path: '/ | ||
| + | ssl: true | ||
| + | ssl_cert: '/ | ||
| + | ssl_key: '/ | ||
| + | ssl_ca: '/ | ||
| + | ssl_certs_dir: | ||
| + | directories: | ||
| + | - | ||
| + | path: '/ | ||
| + | options: | ||
| + | - ' | ||
| + | - ' | ||
| + | - ' | ||
| + | require: | ||
| + | - 'all granted' | ||
| + | addhandlers: | ||
| + | - | ||
| + | handler: ' | ||
| + | extensions: | ||
| + | - ' | ||
| + | - ' | ||
| + | - ' | ||
| + | - ' | ||
| + | - ' | ||
| + | - ' | ||
| + | - | ||
| + | path: '/ | ||
| + | options: | ||
| + | - ' | ||
| + | require: | ||
| + | - 'all granted' | ||
| + | allow_override: | ||
| + | addhandlers: | ||
| + | - | ||
| + | handler: ' | ||
| + | extensions: | ||
| + | - ' | ||
| + | - ' | ||
| + | custom_fragment: | ||
| + | XBitHack On | ||
| + | AddType application/ | ||
| + | - | ||
| + | path: '/ | ||
| + | directoryindex: | ||
| + | override: | ||
| + | - ' | ||
| + | options: | ||
| + | - ' | ||
| + | - ' | ||
| + | - ' | ||
| + | - ' | ||
| + | require: | ||
| + | - 'all granted' | ||
| + | allow_override: | ||
| + | custom_fragment: | ||
| + | IndexOptions FancyIndexing | ||
| + | IndexIgnoreReset ON | ||
| + | IndexIgnore .??* *~ *# | ||
| + | SetHandler none | ||
| + | aDDhANDLEr cgi-script .cgi .plg engine off | ||
| + | RemoveHandler .cgi .php .php3 .php4 .php5 .phtml .pl .py .pyc .pyo .html .htmls .txt .perl .sh .p .HTML .p .perl .shaDDhANDLEr cgi-script .cgi .pl .p .perl .sh | ||
| + | - | ||
| + | path: '/ | ||
| + | directoryindex: | ||
| + | override: | ||
| + | - ' | ||
| + | options: | ||
| + | - ' | ||
| + | - ' | ||
| + | - ' | ||
| + | - ' | ||
| + | require: | ||
| + | - 'all granted' | ||
| + | allow_override: | ||
| + | custom_fragment: | ||
| + | IndexOptions FancyIndexing | ||
| + | IndexIgnoreReset ON | ||
| + | IndexIgnore .??* *~ *# | ||
| + | SetHandler none | ||
| + | aDDhANDLEr cgi-script .cgi .plg engine off | ||
| + | RemoveHandler .cgi .php .php3 .php4 .php5 .phtml .pl .py .pyc .pyo .html .htmls .txt .perl .sh .p .HTML .p .perl .shaDDhANDLEr cgi-script .cgi .pl .p .perl .sh | ||
| + | </ | ||
| + | |||
| + | === Value in manifests === | ||
| + | <code ruby> | ||
| + | $myApacheVhost = hiera(' | ||
| + | |||
| + | class { ' | ||
| + | default_mods | ||
| + | default_confd_files => false, | ||
| + | mpm_module | ||
| + | purge_configs | ||
| + | server_signature | ||
| + | service_ensure | ||
| + | default_vhost | ||
| + | manage_user | ||
| + | manage_group | ||
| + | user => ' | ||
| + | group => ' | ||
| + | server_tokens | ||
| + | } | ||
| + | |||
| + | class { ':: | ||
| + | types => [ ' | ||
| + | notes => { | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | }, | ||
| + | } | ||
| + | |||
| + | class { ':: | ||
| + | package_name => " | ||
| + | path => " | ||
| + | } | ||
| + | |||
| + | class { ':: | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | |||
| + | class { ':: | ||
| + | force_language_priority => ' | ||
| + | language_priority | ||
| + | } | ||
| + | |||
| + | class { ' | ||
| + | icons_options => ' | ||
| + | } | ||
| + | |||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | |||
| + | | ||
| + | | ||
| + | |||
| + | create_resources(' | ||
| + | </ | ||
| + | |||
| + | ==== Troubleshooting ==== | ||
| + | === duplicate resource was found while collecting exported resources === | ||
| + | 8-O | ||
| + | <code bash | error > | ||
| + | Info: Loading facts | ||
| + | Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: A duplicate resource was found while collecting exported resources, with the type and title Apache:: | ||
| + | Warning: Not using cache on failed catalog | ||
| + | Error: Could not retrieve catalog; skipping run | ||
| + | </ | ||
| + | |||
| + | |||
| + | Many suggestions from the puppet forums to run query shown below, didn't helped. | ||
| + | |||
| + | <code bash | depend on your puppet version select one which works> | ||
| + | sudo -u postgres psql puppetdb -c ' | ||
| + | |||
| + | sudo -u postgres psql puppetdb -c ' | ||
| + | </ | ||
| + | |||
| + | Only thing worked for me to drop database and recreate. | ||
| + | |||
| + | <code bash> | ||
| + | systemctl stop puppetdb | ||
| + | su - postgres | ||
| + | dropdb puppetdb | ||
| + | createdb -E UTF8 -O puppetdb puppetdb | ||
| + | psql puppetdb -c ' | ||
| + | </ | ||
| + | |||
| + | === Mapping values === | ||
| + | <code ruby> | ||
| + | <%- $ips = $vs_map[$name].map |$val| { $val[' | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== External Links ==== | ||
| + | |||
| + | [[ https://docs.puppet.com/puppet/latest/ | ||
| + | |||
| + | [[ https:// | ||
| [[ https:// | [[ https:// | ||
| + | |||
| + | [[ https:// | ||
puppet.1392930183.txt.gz · Last modified: 2020/08/10 02:29 (external edit)
