PuppetTool - henk52/knowledgesharing GitHub Wiki
summary Puppet module cookbook
-
https://groups.google.com/forum/#!topic/puppet-users/ld-6aQ9ZbCA Troubleshooting:
-
https://blog.openshift.com/how-to-avoid-puppet-dependency-nightmares-with-defines/
-
https://tobrunet.ch/2013/01/iterate-over-datastructures-in-puppet-manifests/
See:
-
http://puppetlabs.com/blog/writing-great-modules-an-introduction
-
http://docs.puppetlabs.com/puppet/3/reference/modules_publishing.html
-
http://docs.puppetlabs.com/puppet/latest/reference/modules_fundamentals.html
-
http://www.chriscowley.me.uk/blog/2014/01/24/nfs-with-puppet-and-an-enc/
-
http://docs.bcfg2.org/server/plugins/connectors/puppetenc.html
I couldn't find a way to make a module server multiple "masters", I need to have a "parent" module to rule the whole thing.
So if I want to install multiple modules that all uses e.g. a web server, then the parent module needs to know what each of the modules needs of alias directories.
-
http://www.puppetcookbook.com/posts/install-multiple-packages.html
-
Getting Help: https://ask.puppetlabs.com/questions/
-
mcollective
-
Razor
- http://www.virtuallyghetto.com/2012/05/how-to-deploy-esxi-5-using-razor-puppet.html
- http://nickapedia.com/2012/05/21/lex-parsimoniae-cloud-provisioning-with-a-razor/
- https://github.com/puppetlabs/razor-server/wiki/Installation#wiki-server-install-from-release
- https://github.com/puppetlabs/razor-server/wiki/Installation
- https://groups.google.com/forum/#!forum/puppet-razor
- http://nickapedia.com/2012/05/21/lex-parsimoniae-cloud-provisioning-with-a-razor/
- http://purevirtual.eu/2012/07/02/how-to-get-started-with-razor-and-puppet-part-2/
-
Pulp
-
switch and router configuration
-
BIOS
-
Developing modules
-
Vagrant modules
-
http://projects.puppetlabs.com/projects/1/wiki/Puppet_Solaris
-
Distributed Puppet
- https://www.braintreepayments.com/braintrust/decentralize-your-devops-with-masterless-puppet-and-supply-drop
- http://bitfieldconsulting.com/scaling-puppet-with-distributed-version-control
- http://comments.gmane.org/gmane.comp.sysutils.puppet.user/6236
- http://server.dzone.com/articles/decentralized-devops-master
- http://serverfault.com/questions/408261/pros-and-cons-of-a-decentralized-puppet-architecture
- https://groups.google.com/forum/#!topic/puppet-users/OilxMytnD_k
- http://soimasysadmin.com/2012/02/15/puppet-inheritance-the-insane-mine-field/
- http://swift.siphos.be/aglara/centralcmdb.html
- Autoloading - means that your modules will be loaded by Puppet at compile time.
- Puppet runs -> compiles catalog -> load modules.
- Catalog
- Class - Collection of resources.
- You can also think of them as named blocks of Puppet code, which are created in one place and invoked elsewhere.
- ENC - external node classifier.
- Facter - cross platform system profiler on HW and OS.
- Forge - a repository of modules written by our community of Puppet users for both Puppet Open Source and Puppet Enterprise IT automation software.
- Hiera - key/value look-up too for configuration data.
- Helps keep site specific data out of the manifest.
- Supported back-ends:
- yaml
- json
- PostgreSQL.
- Inheritance -
- Manifest -
- metaparamers - can be used with every resource type, like e.g: before.
- They do not map to system state.
- Instead specify how puppet should act toward the resource.
- Module - directory on disk that contains the files for a given configuration.
- Providers - The interface between the underlying OS and the resource types.
- PuppetDB
- Stores:
- Most resent fact for each node.
- Most resent catalog for each node.
- Optionally last 7 days of events for each node.
- Stores:
- RAL - Resource Abstraction Layer: OS agnostic.
- Resource types -
- Package
- file
- service
- Role
== Open issues ==
-
How do I write a manifest that will work on both unix and Windows.
- Perhaps look at the ntp manifest.
-
Can we have a custom/local forge, internal modules?
-
TODO Find a way to make it configurable whether to use one or two NICs.
-
puppet parser validate manifest/init.pp
- http://forums.fedoraforum.org/showpost.php?p=1578216&postcount=4
- http://magazine.redhat.com/2007/05/31/remixing-fedora-7/
- https://fedorahosted.org/pungi/
- https://fedorahosted.org/pungi/wiki/PungiDocs/RunningPungi
- http://www2.fedoraforum.org/showthread.php?t=284255
- http://fedoraproject.org/wiki/Infrastructure/CustomSpins
- https://spins.fedoraproject.org/
- https://spins.fedoraproject.org/support
- http://wiki.sugarlabs.org/go/Tutorials/Installation/Build_Your_Own_Remix_with_Fedora
- http://knowledgefrontier.blogspot.com/2009/04/how-to-create-modify-fedora-iso-images.html
- http://rajeeshknambiar.wordpress.com/2013/01/21/fedora-18-install-from-iso-file/
- http://wiki.sugarlabs.org/go/Build_Your_Own_Remix_with_Fedora
- sudo apt-get install puppet-master
See:
- sudo rpm -Uvh https://yum.puppet.com/puppet5/puppet5-release-el-7.noarch.rpm
- yum install -y puppet
- Download the two DVDs DVD1 and DVD2
- CentOS-6.5-x86_64-bin-DVD1.iso and CentOS-6.5-x86_64-bin-DVD2.iso
- Install the DVDs on the Kickstart server.
- Get the Puppet packages
- See 'populate.sh' below.
- Get the
rubygems-1.3.7-5.el6.noarch.rpm
and copy it to the DVD1 extraction directory.- For some reason this seems to be missing from the DVD.
- You don't have to re-run
repocreate
- e.g.
cp rubygems-1.3.7-5.el6.noarch.rpm /var/ks/images/centos_65_x86_64/Packages
==== populate.sh for getting the Puppet RPMs for CentOS 6.5 ====
#!/usr/bin/bash
wget -N https://yum.puppetlabs.com/README.txt
wget -N https://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm
wget -N https://yum.puppetlabs.com/RPM-GPG-KEY-puppetlabs
wget -N https://yum.puppetlabs.com/RPM-GPG-KEY-reductive
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/activemq-5.8.0-3.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/activemq-info-provider-5.8.0-3.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/leiningen-2.0.0-0.2preview10.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rlwrap-0.37-3.el6.x86_64.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/ruby-augeas-0.4.1-3.el6.x86_64.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/ruby-json-1.5.5-3.el6.x86_64.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/ruby-mysql-2.8.2-1.el6.x86_64.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/ruby-rgen-0.6.5-2.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/ruby-shadow-2.2.0-2.el6.x86_64.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-activerecord-2.3.16-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-activesupport-2.3.16-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-deep_merge-1.0.0-2.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-ffi-1.0.9-11.el6.x86_64.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-hpricot-0.8.6-1.el6.x86_64.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-json-1.5.5-3.el6.x86_64.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-json-doc-1.5.5-3.el6.x86_64.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-mustache-0.99.4-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-net-ldap-0.2.2-4.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-net-ping-1.5.3-4.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-net-ping-doc-1.5.3-4.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-puppet-lint-0.3.2-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-rack-1.0.1-2.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-rake-compiler-0.7.0-2.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-rake-compiler-doc-0.7.0-2.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-rdiscount-1.6.8-1.el6.x86_64.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-ronn-0.7.3-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-stomp-1.3.2-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/rubygem-stomp-doc-1.3.2-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/dependencies/x86_64/tanukiwrapper-3.5.9-1.el6.x86_64.rpm
# Production
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/facter-2.2.0-1.el6.x86_64.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/hiera-1.3.4-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/hiera-puppet-1.0.0-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-2.6.0-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-actionpolicy-auth-2.0.1-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-client-2.6.0-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-common-2.6.0-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-facter-facts-1.0.0-1.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-filemgr-agent-1.0.2-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-filemgr-client-1.0.2-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-filemgr-common-1.0.2-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-iptables-agent-3.0.2-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-iptables-client-3.0.2-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-iptables-common-3.0.2-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-logstash-audit-2.0.0-1.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-nettest-agent-3.0.4-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-nettest-client-3.0.4-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-nettest-common-3.0.4-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-nrpe-agent-3.0.3-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-nrpe-client-3.0.3-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-nrpe-common-3.0.3-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-package-agent-4.3.1-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-package-client-4.3.1-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-package-common-4.3.1-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-puppet-agent-1.8.1-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-puppet-client-1.8.1-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-puppet-common-1.8.1-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-service-agent-3.1.3-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-service-client-3.1.3-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-service-common-3.1.3-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/mcollective-sysctl-data-2.0.1-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/puppet-3.7.1-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/puppet-dashboard-1.2.23-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/puppet-server-3.7.1-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/puppetdb-2.2.0-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/puppetdb-terminus-2.2.0-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/puppetlabs-release-6-11.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/puppetserver-0.2.0-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/razor-server-0.15.0-1.el6.noarch.rpm
wget -N https://yum.puppetlabs.com/el/6.5/products/x86_64/razor-torquebox-3.0.1-1.el6.noarch.rpm
#wget -N
# This one is somehow missing from the CentOS 6.5 DVDs
wget -N http://mirror.centos.org/centos/6/os/x86_64/Packages/rubygems-1.3.7-5.el6.noarch.rpm
createrepo .
= Puppet concepts =
==== Class related information ====
- Defining - write the text.
- Declaring - Adds a resource to the catalog and tells puppet to manage that resources state.
- cannot be declared more than once.
== Modules ==
=== Module structure ===
-
modulepath = configuration setting to specify the location of your modules.
- default: $confdir/modules
- $confdir is the main puppet configuration file.
- open source: /etc/puppet
- enterprise: /etc/puppelabs/puppet
- Show it with:
puppet config print modulepath
- $confdir is the main puppet configuration file.
- default: $confdir/modules
-
module-name
- manifests/
- init.pp - must contain a class name that matches the module-name.
- Modulefil
-
[M]
name -
[M]
version
-
- files/
- templates/
- lib/
- tests/
- spec/
- manifests/
= Creating your own modules = PuppetModuleCookbook
= components =
== Facter ==
- Returns key value pairs.
- Access the data in scripts by doing: ${::factname}
- e.g.:
content => "Hello world! Welcome to ${hostname} running ${::operatingsystem}. My IP address is ${ipaddress_eth0}.",
- e.g.:
==== extending fact gathering with 'fact.add()' ==== Ruby code.
== augeas ==
- http://projects.puppetlabs.com/projects/1/wiki/puppet_augeas
- http://www.big-bubbles.fluff.org/blogs/bubbles/blog/2012/10/12/using-augeas-with-puppet/
- http://augeas.net/docs/lenses.html
=== augtool command examples ===
- augtool print /files/etc/hosts
- Should list the content of etc/hosts.
=== augeas puppet example === See: http://www.crypt.gen.nz/selinux/disable_selinux.html
augeas { 'selinux_config':
context => '/files/etc/selinux/config',
changes => [
'set SELINUX permissive',
],
}
== Installing puppet on Windows == See: http://docs.puppetlabs.com/windows/installing.html
Download from: https://downloads.puppetlabs.com/windows/
= Environment =
puppet apply --environment test tst.pp
default is: 'production'
= Hiera =
=== test retrieving data ===
puppet apply -e 'notice(hiera("motd"))'
= Puppet distribution =
== Puppet Master == I think this is commercial, but I'm not sure.
== GIT distribution ==
=== References for distribution puppet with GIT ===
- http://bitfieldconsulting.com/scaling-puppet-with-distributed-version-control
- http://www-verimag.imag.fr/~moy/?Host-a-Git-repository-over-HTTP-S
- http://current.workingdirectory.net/posts/2011/puppet-without-masters/
- http://livecipher.blogspot.com/2013/01/deploy-code-from-git-using-puppet.html
= Using modules =
== firewalld == See: https://forge.puppetlabs.com/jpopelka/firewalld
=== Adding http to the public zone ===
firewalld::zone { 'public':
services => ['ssh', 'http', 'vnc-server'],
}
Please note: the service list is absolute, so you have to list all the services there.
= Razor =
== Installing Razor ==
=== Installing Razor on Ubuntu - doesn't work ===
* Make sure it is version 2.7.14 at least(for the module subcommand to be available)
* fails
=== Installing Razor on Fedora === See:
- https://github.com/puppetlabs/razor-server/wiki/Installation
- https://forge.puppetlabs.com/puppetlabs/razor
- https://gist.github.com/lutter/6618013
* 3.1.1
* Should give you a table where razor_dev, razor_prd and razor_test is listed.
* Just so that you have it available.
* temporarily open the 8080 port.
* Make sure it is open after reboot.
# sudo puppet module install razorsedge/network
# sudo puppet apply ./fedora_second_nic.pp --verbose
* http://forge.puppetlabs.com/razorsedge/network
* NOT DONE sudo puppet module install attachmentgenie/network
* http://forge.puppetlabs.com/attachmentgenie/network (only work with debians)
# sudo puppet module install lex/dnsmasq
* http://forge.puppetlabs.com/lex/dnsmasq
Post stuff:
==== razor_stuff.pp ====
class { 'postgresql::server': }
postgresql::server::db { 'razor_prd':
user => 'razor',
password => postgresql_password('razor', 'razor_passwd'),
}
postgresql::server::db { 'razor_dev':
user => 'razor',
password => postgresql_password('razor', 'razor_passwd'),
}
postgresql::server::db { 'razor_test':
user => 'razor',
password => postgresql_password('razor', 'razor_passwd'),
}
==== precondition_packages.pp ====
# See: https://gist.github.com/lutter/6618013
# http://www.puppetcookbook.com/posts/install-package.html
package { "libarchive-devel":
ensure => "installed"
}
package { "unzip":
ensure => "installed"
}
# I'm not sure if this is needed with the new razor release.
user { "razor":
ensure => "present",
}
==== config.yaml.mystuff ====
---
# This is the configuration file for the Razor server. For each
# environment, the file contains a hash of configuration values. The
# special environment 'all' is used to set configuration values for all
# environments
#
# The *database_url* setting must be a connection URL for
# (Sequel)[http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html]
production:
database_url: 'jdbc:postgresql:razor_prd?user=razor&password=razor_passwd'
development:
database_url: 'jdbc:postgresql:razor_dev?user=razor&password=razor_passwd'
test:
database_url: 'jdbc:postgresql:razor_test?user=razor&password=razor_passwd'
all:
repo_service_uri:
'http://puppetmaster/razor/repo'
microkernel:
debug_level: debug
kernel_args:
checkin_interval: 15
# Colon-separated list of paths; each entry must be a directory in which
# we should look for installers
installer_path: installers
repo_store_root: /var/lib/razor/repo-store
# The *broker_path* is a colon separated list of directories containing
# broker types
broker_path: brokers
facts:
# Facts that we should always ignore. These are stripped out before we
# do anything else with facts coming in from a node. Each entry in this
# array can either be a string (literal name of a fact) or a regexp
# enclosed in /../ where any fact that matches the regexp will be
# dropped
blacklist:
- id
- /kernel.*/
- memorysize
- memoryfree
- operatingsystem
- operatingsystemrelease
- osfamily
- path
- ps
- rubysitedir
- rubyversion
- selinux
- sshdsakey
- sshrsakey
- swapfree
- swapsize
- timezone
- /uptime.*/
==== fedora_second_nic.pp ====
# TODO make the parms configurable.
network::if::static { 'enp0s29f7u3':
ensure => 'up',
ipaddress => '192.168.1.231',
netmask => '255.255.255.0',
}
= Getting an infrastructure up and running with Puppet =
- http://projects.puppetlabs.com/projects/1/wiki/bootstrapping_with_puppet
- http://projects.puppetlabs.com/projects/1/wiki/Puppet_Windows
= Puppet cookbook =
=== augeas - recipes ===
==== Disable fedora repos ====
augeas { 'repo_fedora_updates':
context => '/files/etc/yum.repos.d/fedora-updates.repo',
changes => [
'set updates/enabled 0',
'set updates-source/enabled 0',
],
}
=== exec - recipes ===
==== Source a file from the web ====
file { '/var/puppetextras':
ensure => directory,
}
exec { 'get_VBoxLinuxAdditions_run':
creates => '/var/puppetextras/VBoxLinuxAdditions.run',
command => '/usr/bin/wget --directory-prefix=/var/puppetextras http://10.1.233.2:/puppetextras/VBoxLinuxAdditions.run',
require => File [ '/var/puppetextras' ],
}
==== Adding a nopasswd group to sudoers ====
# Allow users belonging admin group to use sudo
# See: http://www.redbottledesign.com/blog/how-control-etcsudoers-file-puppet-and-augeas
augeas { 'sudowheel':
context => '/files/etc/sudoers', # target file is /etc/sudoers
changes => [
# allow wheel users to use sudo
'set spec[user = "%admin"]/user %admin',
'set spec[user = "%admin"]/host_group/host ALL',
'set spec[user = "%admin"]/host_group/command ALL',
'set spec[user = "%admin"]/host_group/command/tag NOPASSWD',
]
}
==== Generating id_rsa ====
package { 'openssh':
ensure => present,
require => File [ 'repo_updates' ],
}
group { 'admin':
ensure => present,
}
user { 'vagrant':
ensure => present,
groups => [ 'admin' ],
managehome => true,
home => '/home/vagrant',
require => Group [ 'admin' ],
}
file { '/home/vagrant/.ssh':
ensure => directory,
owner => 'vagrant',
group => 'vagrant',
mode => '750',
require => User [ 'vagrant' ],
}
exec { 'vagrant_rsa':
creates => '/home/vagrant/.ssh/id_rsa',
command => '/usr/bin/ssh-keygen -t rsa -b 2048 -q -f /home/vagrant/.ssh/id_rsa',
user => 'vagrant',
group => 'vagrant',
require => [
User [ 'vagrant' ],
Package [ 'openssh' ],
File [ '/home/vagrant/.ssh' ],
],
}
= Troubleshooting =
== puppet modules ==
==== Error: Evaluation Error: Unknown function: 'is_ip_address' ==== Install stdlibs and ln -s /usr/share/puppet/modules/stdlib/lib/puppet /var/lib/puppet/lib
Error: Evaluation Error: Unknown function: 'is_ip_address'. at /etc/puppet/modules/network/manifests/if/static.pp:73:8 on node localhost
==== Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class ====
Solution: run the command with sudo
since the modules are installed with sudo.
puppet apply razor_dnsmasq_configuration.pp --noop Warning: Could not retrieve fact fqdn Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class dnsmasq at /home/cadm/Source/razor_wrapper/manifests/razor_dnsmasq_configuration.pp:14 on node puppetmaster Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class dnsmasq at /home/cadm/Source/razor_wrapper/manifests/razor_dnsmasq_configuration.pp:14 on node puppetmaster
==== Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class lvm at /home/cadm/puppet/manifests/lvm_configuration.pp:1 on node trinity.localdomain ====
Solution: The module provided a 'define' not a 'class', so no include is done.
See also: http://docs.puppetlabs.com/learning/definedtypes.html
Line 1: class { 'lvm': }
cadm@trinity:~/puppet/manifests$ sudo puppet apply lvm_configuration.pp --noop [sudo] password for cadm: Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class lvm at /home/cadm/puppet/manifests/lvm_configuration.pp:1 on node trinity.localdomain Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class lvm at /home/cadm/puppet/manifests/lvm_configuration.pp:1 on node trinity.localdomain
=== firwalld issues ===
==== Error: Could not find dependency Package[firewalld] for File[/etc/firewalld/zones/] at /etc/puppet/modules/firewalld/manifests/zone.pp:36 ====
sudo puppet apply vnc_in_firewall.pp
[sudo] password for cadm:
Notice: Compiled catalog for localhost in environment production in 0.89 seconds
Error: Could not find dependency Package[firewalld] for File[/etc/firewalld/zones/] at /etc/puppet/modules/firewalld/manifests/zone.pp:36
[USER@localhost source]$ cat vnc_in_firewall.pp
firewalld::zone { 'public':
services => ['ssh', 'http', 'vnc-server'],
}
== troubleshooting PostGreSQL ==
==== Error: No preferred version defined or automatically detected. at /etc/puppet/modules/postgresql/manifests/globals.pp:81 on node localhost.localdomain ====
Fix: export LANGUAGE=en_US.UTF-8 export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8
sudo puppet apply ./razor_stuff.pp --verbose Info: Loading facts in /etc/puppet/modules/firewall/lib/facter/iptables_persistent_version.rb Info: Loading facts in /etc/puppet/modules/firewall/lib/facter/iptables_version.rb Info: Loading facts in /etc/puppet/modules/firewall/lib/facter/ip6tables_version.rb Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/pe_version.rb Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb Info: Loading facts in /etc/puppet/modules/concat/lib/facter/concat_basedir.rb Could not retrieve operatingsystemrelease: invalid byte sequence in US-ASCII Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults Error: No preferred version defined or automatically detected. at /etc/puppet/modules/postgresql/manifests/globals.pp:81 on node localhost.localdomain Error: No preferred version defined or automatically detected. at /etc/puppet/modules/postgresql/manifests/globals.pp:81 on node localhost.localdomain
== Troubleshooting razor ==
==== [ERROR] JBOSS_HOME is not set. Install torquebox-server gem (and ensure it's in your Gemfile) or manually set JBOSS_HOME ====
sudo -i [root@localhost ~]# export PATH=${PATH}:/opt/razor-torquebox/jruby/bin [root@localhost ~]# torquebox deploy --env production OpenJDK 64-Bit Server VM warning: You have loaded library /opt/razor-torquebox/jruby/lib/native/arm-Linux/libjffi-1.2.so which might have disabled stack guard. The VM will try to fix the stack guard now. It's highly recommended that you fix the library with 'execstack -c ', or link it with '-z noexecstack'. [ERROR] JBOSS_HOME is not set. Install torquebox-server gem (and ensure it's in your Gemfile) or manually set JBOSS_HOME RuntimeError: $JBOSS_HOME is not set jboss_home at /opt/razor-torquebox/jruby/lib/ruby/gems/shared/gems/torquebox-rake-support-3.0.0/lib/torquebox/deploy_utils.rb:34 server_dir at /opt/razor-torquebox/jruby/lib/ruby/gems/shared/gems/torquebox-rake-support-3.0.0/lib/torquebox/deploy_utils.rb:67 deploy_dir at /opt/razor-torquebox/jruby/lib/ruby/gems/shared/gems/torquebox-rake-support-3.0.0/lib/torquebox/deploy_utils.rb:92 deploy_yaml at /opt/razor-torquebox/jruby/lib/ruby/gems/shared/gems/torquebox-rake-support-3.0.0/lib/torquebox/deploy_utils.rb:315 deploy at /opt/razor-torquebox/jruby/lib/ruby/gems/shared/gems/torquebox-3.0.0/bin/torquebox:118 __send__ at org/jruby/RubyBasicObject.java:1703 run at /opt/razor-torquebox/jruby/lib/ruby/gems/shared/gems/thor-0.18.1/lib/thor/command.rb:27 invoke_command at /opt/razor-torquebox/jruby/lib/ruby/gems/shared/gems/thor-0.18.1/lib/thor/invocation.rb:120 dispatch at /opt/razor-torquebox/jruby/lib/ruby/gems/shared/gems/thor-0.18.1/lib/thor.rb:363 start at /opt/razor-torquebox/jruby/lib/ruby/gems/shared/gems/thor-0.18.1/lib/thor/base.rb:439 (root) at /opt/razor-torquebox/jruby/lib/ruby/gems/shared/gems/torquebox-3.0.0/bin/torquebox:213 load at org/jruby/RubyKernel.java:1073 (root) at /opt/razor-torquebox/jruby/bin/torquebox:23
==== LoadError: no such file to load -- sequel =====
Fix: cd /opt/razor
sudo /usr/local/bin/razor-admin -e production migrate-database OpenJDK 64-Bit Server VM warning: You have loaded library /opt/razor-torquebox/jruby/lib/native/arm-Linux/libjffi-1.2.so which might have disabled stack guard. The VM will try to fix the stack guard now. It's highly recommended that you fix the library with 'execstack -c ', or link it with '-z noexecstack'. LoadError: no such file to load -- sequel require at org/jruby/RubyKernel.java:1054 require at /opt/razor-torquebox/jruby/lib/ruby/shared/rubygems/custom_require.rb:36 (root) at /opt/razor/lib/razor/initialize.rb:1 require at org/jruby/RubyKernel.java:1054 (root) at /opt/razor-torquebox/jruby/lib/ruby/shared/rubygems/custom_require.rb:1 require at /opt/razor-torquebox/jruby/lib/ruby/shared/rubygems/custom_require.rb:36 (root) at /opt/razor/bin/razor-admin:57
==== Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class sudo ====
Maybe this will fix it: sudo puppet module install saz/sudo
sudo puppet apply /etc/puppet/modules/razor/tests/init.pp --verbose info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/pe_version.rb Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class sudo at /etc/puppet/modules/razor/tests/init.pp:3 on node ucobbler
==== syntax error at '{'; expected '}' at /etc/puppet/modules/razor/manifests/libarchive.pp:22 on node ucobbler ====
This seems to be a PE3 language thing, so removing the 'unless' block made this work. This is a hacl , and should probably be replaced by an 'if' statement. or better yet, figure out why I get a .pp file with PE3 syntax in it.
==== /usr/bin/env: jruby: No such file or directory ==== Try: sudo apt-get install jruby
/opt/razor/bin/razor-admin --help /usr/bin/env: jruby: No such file or directory
==== require': no such file to load -- bundler/setup (LoadError) from /opt/razor/bin/razor-admin:4 ====
-
http://stackoverflow.com/questions/19061774/cannot-load-such-file-bundler-setup-loaderror
-
Trying:
- Trying: sudo puppet module install jlbfalcao/jruby
- didn't work.
- sudo puppet module install puppetlabs/ruby
- didn't work.
- sudo gem install autotest base62 bson bson_ext colored daemons json logger macaddr mocha mongo net-ssh require_all syntax uuid
- Also didn't work.
- Trying: sudo puppet module install jlbfalcao/jruby
/opt/razor/bin/razor-admin --help /opt/razor/bin/razor-admin:4:in `require': no such file to load -- bundler/setup (LoadError) from /opt/razor/bin/razor-admin:4
== Ruby issues ==
==== Error: Non-HTTP proxy URI: ==== This seems to be a bug in ruby. Fix:
Content of proxy_unset_for_ruby.sh
unset ftp_proxy
unset FTP_PROXY
unset ALL_PROXY
unset all_proxy
unset SOCKS_PROXY
unset socks_proxy
unset https_proxy
unset HTTPS_PROXY
- Answer: http://railspro.blogspot.com/2011/05/non-http-proxy-uri-in-open-uri_6702.html
- https://github.com/mxcl/homebrew/issues/21679
- http://projects.puppetlabs.com/issues/14111
sudo puppet module install haraldsk/nfs Notice: Preparing to install into /etc/puppet/modules ... Notice: Downloading from https://forge.puppetlabs.com ... Error: Non-HTTP proxy URI: https://ADDRESS:PORT Error: Try 'puppet help module install' for usage
== Puppet issues ==
==== Error: Could not find dependency File[/etc/lighttpd/lighttpd.conf] for File_line[add_git_share] ==== See: https://github.com/boxen/our-boxen/issues/77
Turns out I have to have the 'file { '':' definition as well, it is not enough that the file is there in the environment.
sudo puppet apply git_server.pp
Error: Could not find dependency File[/etc/lighttpd/lighttpd.conf] for File_line[add_git_share]
== augeas troubleshooting ==
==== augtool print /files/etc/environment - returns nothing ====
It turns out, the terminating '"' (double-quote) was missing.
/etc/environment contains:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
==== Warning: Augeasetc_environment: Loading failed for one or more files, see debug for /augeas//error output ==== I have no idea of where the '/augeas//error' is suppose to be found.
Failed to start Hiera: Psych::SyntaxError: (/etc/hiera.yaml): found character that cannot start any token while scanning for the next token
See: https://bugzilla.redhat.com/show_bug.cgi?id=1015002
Put a " (double quote) around text wiht '%' in it:
---
:backends:
- yaml
:hierarchy:
- defaults
- "%{clientcert}"
- "%{environment}"
- global
:yaml:
:datadir: /etc/puppet/data
sudo hiera proxyserver
Failed to start Hiera: Psych::SyntaxError: (/etc/hiera.yaml): found character that cannot start any token while scanning for the next token at line 6 column 5
Turns out the 'config' dir '/usr/share/lxc/config' dir not exist.
sudo -E puppet apply lxc_install.pp
Warning: Could not retrieve fact fqdn
Notice: Compiled catalog for localhost in environment production in 0.68 seconds
Error: Could not set 'file' on ensure: No such file or directory - /usr/share/lxc/config/fedora.common.conf20140426-25598-fu22f4 at 67:/etc/puppet/modules/lxc/manifests/lxc_install.pp
Error: Could not set 'file' on ensure: No such file or directory - /usr/share/lxc/config/fedora.common.conf20140426-25598-fu22f4 at 67:/etc/puppet/modules/lxc/manifests/lxc_install.pp
Wrapped exception:
No such file or directory - /usr/share/lxc/config/fedora.common.conf20140426-25598-fu22f4
Error: /Stage[main]/Main/File[/usr/share/lxc/config/fedora.common.conf]/ensure: change from absent to file failed: Could not set 'file' on ensure: No such file or directory - /usr/share/lxc/config/fedora.common.conf20140426-25598-fu22f4 at 67:/etc/puppet/modules/lxc/manifests/lxc_install.pp
- create your project on https://github.com
- puppet module generate reidmv-motd
- mv reidmv-motd reidmv-motd.org
- git clone xxx
- cd reidmv-motd.org
- mv
*
../reidmv-motd - cd ../reidmv-motd
- git add xxx
- git commmit -m "Some great comment."
- cd ..
See: http://puppetlabs.com/blog/verifying-puppet-checking-syntax-and-writing-automated-tests
-
puppet-lint manifests/init.pp
- Get puppet-lint: https://github.com/rodjek/puppet-lint
- or: :
sudo gem install puppet-lint
puppet-lint tests/init.pp
sudo puppet parser validate manifests/init.pp
sudo puppet parser validate test/init.pp
sudo puppet apply test/init.pp --noop
- MySQL: https://forge.puppetlabs.com/puppetlabs/mysql
- Network configuration: https://github.com/razorsedge/puppet-network
- PostGreSQL: puppetlabs/postgresql
- Puppetlabs stdlib: https://forge.puppetlabs.com/puppetlabs/stdlib
- PuppetLabs concat: https://forge.puppetlabs.com/puppetlabs/concat
- http://rspec-puppet.com/tutorial/
- https://rubygems.org/gems/rspec-puppet/
- https://rubygems.org/gems/rspec
Download rspec: https://rubygems.org/gems/rspec
Download rspec-puppet: https://rubygems.org/gems/rspec-puppet/
==== Releasing your module ====
==== require multiple resources ==== http://docs.puppetlabs.com/guides/techniques.html
user { "tim":
ensure => present,
gid => "fearme",
groups => ["adm", "staff", "root", "fearmenot"],
membership => minimum,
shell => "/bin/bash",
require => [ Group["fearme"],
Group["fearmenot"]
]
}
See: https://ask.puppetlabs.com/question/3339/require-a-subclass/
It looks like you are using a defined type called apt::ppa, so you would need to capitalize all the words of the type:
require => Apt::Ppa['ppa:git-core/ppa'],
If you were declaring a class called apt::ppa, you would want to require the class:
require => Class['apt::ppa'],
lvm::volume { 'kickstart': ensure => present, vg => 'vg_images', pv => '/dev/sda5', fstype => 'ext4', size => '10G', }
file { '/var/ks': ensure => directory, }
file_line { 'kickstart_dir': path => '/etc/fstab', line => '/dev/vg_images/kickstart /var/ks ext4 defaults 1 2', require => [ File ['/var/ks' ], Lvm::Volume[ 'kickstart' ], ], }
# Manifest operations
## File
* http://perlstalker.vuser.org/blog/2012/08/28/managing-etc-hosts-with-puppet/
=== Templating ===
* http://docs.puppetlabs.com/guides/templating.html
* http://docs.puppetlabs.com/learning/templates.html
==== creating a file from a template ====
See: https://github.com/puppetlabs/puppetlabs-motd/blob/master/manifests/init.pp
file { '/etc/motd': ensure => file, backup => false, content => template('motd/motd.erb'), }
==== Making the template file related to the module ====
To make use a template delivered with your module you need to add the module name as a relative path to the template name.
I think the module is expected to be installed in '/etc/puppet/module' or another officially configured path.
content => template('motd/motd.erb'),
Would expect to find the 'motd.erb' in /etc/puppet/modules/motd/templates/motd.erb
==== Passing data to templates ====
* https://coderwall.com/p/cwxjma
* http://stackoverflow.com/questions/7079857/how-do-you-pass-an-array-to-an-erb-template-in-ruby-and-have-it-iterated-over
=== file_line ===
See: https://ask.puppetlabs.com/question/14366/file_line-resource-match-problems/
#sonar.jdbc.username=sonar file_line { 'sonar_username': path => '/opt/sonar/conf/sonar.properties', line => 'sonar.jdbc.username=sonar', match => '^.sonar.jdbc.username=', }
#sonar.jdbc.password=sonar file_line { 'sonar_password': path => '/opt/sonar/conf/sonar.properties', line => 'sonar.jdbc.password=sonarpasswd', match => '^.sonar.jdbc.password=', }
#sonar.jdbc.url=jdbc:postgresql: file_line { 'sonar_postgresql': path => '/opt/sonar/conf/sonar.properties', line => 'sonar.jdbc.url=jdbc:postgresql://localhost/sonar', match => '^.sonar.jdbc.url=jdbc:postgresql:', }
=== Augeas ===
==== change grub.cfg with augeas ====
See also: http://serverfault.com/questions/554092/how-to-update-grub-with-puppet
augeas { 'hyperthread_enable': context => '/files/etc/default/grub', changes => [ 'set GRUB_CMDLINE_LINUX '""noapic vconsole.font=latarcyrheb-sun16 selinux=0 $([ -x /usr/sbin/rhcrashkernel-param ] && /usr/sbin/rhcrashkernel-param || :) acpi=ht rhgb quiet""'', ], notify => Exec['grub-update'], }
'set GRUB_CMDLINE_LINUX ""noapic vconsole.font=latarcyrheb-sun16 selinux=0 $([ -x /usr/sbin/rhcrashkernel-param ] && /usr/sbin/rhcrashkernel-param || :) acpi=ht rhgb quiet""',
exec { 'grub-update': refreshonly => true, command => '/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg', }
== Manifest variables ==
=== Hash ===
==== Hash of Hashes created in hieara ====
See also: https://docs.puppetlabs.com/hiera/1/data_sources.html
netconfig: vnic02: nic_name: eth2 ip_addr: 10.1.2.3 netmask: 255.255.255.0 vnic03: nic_name: eth3 ip_addr: 10.1.3.3 netmask: 255.255.255.0 vnic04: nic_name: eth4 ip_addr: 10.1.4.3 netmask: 255.255.255.0
==== Hash of hashes created in manifest ====
$netconfigs = { vnic02 => { nic_name => 'eth2', ip_addr => '10.1.2.3', netmask => '255.255.255.0', }, vnic03 => { nic_name => 'eth3', ip_addr => '10.1.3.3', netmask => '255.255.255.0', }, vnic04 => { nic_name => 'eth4', ip_addr => '10.1.4.3', netmask => '255.255.255.0', }, }
==== Hash of hashes used in manifest ====
See: https://ask.puppetlabs.com/question/724/iterate-nested-hash-from-hiera-in-manifest/
define notify_netconfigs($nic_name, $ip_addr, $netmask) { notify { "currently looping NIC: $nic_name, $ip_addr, $netmask": } }
$netconfigs = hiera("netconfig") create_resources( notify_netconfigs, $netconfigs )
==== Hash of hashes used in template ====
<% @netconfigs.each do |hNetConfigSet| -%> Data ( "<%= hNetConfigSet['ip_addr'] %>" => "<%= hNetConfigSet['netmask'] %>" ) <% end %>
=== Array ===
=== facts in manifests ===
* `$operatingsystem` will give you the content from the fact of that name.
=== manifest variable handling ===
==== Convert a string to an array ====
See: https://ask.puppetlabs.com/question/3540/split-string-into-multiple-variables/
$arInterfaceList = split($interfaces, ',') $szSecondInterface = $arInterfaceList[1]
==== setting a new value if the class parameter wasn't set ====
class server-of-diskless-boot ( $szNetworkInterfaceName = hiera( 'NetworkInterfaceName', '' ), $szServiceIpAddress = hiera( 'ServiceIpAddress', '172.16.1.3' ), ){
#if $szNetworkInterfaceName not set then set it if ( $szNetworkInterfaceName == '' ) {
notify{ "Network interface name not set.": }
$arInterfaceList = split($interfaces, ',')
$szNicName = $arInterfaceList[1]
} else { $szNicName = $szNetworkInterfaceName }
notify{ "NIC: $szNicName ( $szServiceIpAddress )": }
}
== manifest network configuration ==
==== Static IP ====
See: https://forge.puppetlabs.com/razorsedge/network
network::if::static { "$szNicName": ensure => 'up', ipaddress => "$szServiceIpAddress", netmask => '255.255.255.0', }
== general module information ==
==== meta parameters ====
See also: http://docs.puppetlabs.com/guides/techniques.html
* before - applied to be applied before the target resource
* require - applied after the target resource
The above relationship can also be defined using '->'
like in:
```Package['openssh-server'] -> File['/etc/ssh/sshd_config]```
This means that: Package must be installed before the File can be ensured/created."
* notify - happens before and send a refresh i the resource is changed.
* subscribe
The above relationship can also be defined using '~>'
like in:
```File['/etc/ntp.conf'] ~> Service[ntpd]```
This means that: "Service will be notified when the File is updated."
==== inheritance ====
* Use it sparingly since it very easily can cause breakage.
* Only useful for overriding resource attributes[01-1105].
* any other use case is better accomplished with other methods.
* relationship override - Use a single class with conditional relationship declarations.
==== Variable ====
* $variables always start with a dollar sign. You assign to variables with the = operator.
* Variables can hold strings, numbers, booleans, arrays, hashes, and the special undef value.
* If youʼve never assigned a variable, you can actually still use it — its value will be undef.
* You can use variables as the value for any resource attribute, or as the title of a resource.
* Every variable has two names:
* A short local name: `$variable
* If you reference a variable with its short name and it isnʼt present in the local scope, Puppet will also check the global top scope.
* A long fully-qualified name `$scope::variable`
* Always use the fully-qualified, the $::variable notation, when referring to facts. To avoid confusion or doubt.
* You can only assign the same variable once in a given scope. In this way, theyʼre more like constants from other programming languages.
==== RPM your module ====
* https://fedoraproject.org/wiki/How_to_create_an_RPM_package?rd=PackageMaintainers/CreatingPackageHowTo
* https://fedoraproject.org/wiki/How_to_create_a_GNU_Hello_RPM_package
== Manifest ==
See the cookbook at: http://www.puppetcookbook.com/posts/run-exec-if-file-absent.html
* exec
* http://www.puppetcookbook.com/posts/run-exec-if-file-absent.html
* Installing local gem packages
* http://blog.moertel.com/posts/2007-11-15-a-couple-of-tips-for-writing-puppet-manifests.html
== Services ==
=== Enable xinet service - rsh ===
See: http://linoxide.com/how-tos/howto-enable-rshrlogin-on-linux-server/
package { 'rsh-server': ensure => present, }
augeas { 'rsh_enable': context => '/files/etc/xinetd.d/rsh', changes => [ 'set service/disable "no"', ], require => Package [ 'rsh-server' ], notify => Service['xinetd'], }
service { 'xinetd': ensure => running, enabled => true, }
== Installation ==
==== Multiple packages ====
==== Grab a file from an external source ====
exec { 'get_VBoxLinuxAdditions_run': creates => '/var/puppetextras/VBoxLinuxAdditions.run', command => '/usr/bin/wget --directory-prefix=/var/puppetextras http://10.1.233.3:/storage/puppet/VBoxLinuxAdditions.run', require => File [ '/var/puppetextras' ], }
==== Install a special application package ====
exec { 'install_VirtualBoxAdditions': creates => '/opt/VBoxGuestAdditions-4.3.18', command => '/var/puppetextras/VBoxLinuxAdditions.run', require => File [ '/var/puppetextras/VBoxLinuxAdditions.run' ], }
=== user ===
==== generate a password thingy ====
=== host ops ===
==== Change the host name and domain ====
See:
* http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-hostname.html
* http://unix.stackexchange.com/questions/145019/how-to-change-hostname-on-centos-6-5
file_line { 'hostname': path => '/etc/sysconfig/network', line => 'HOSTNAME=host.domain', match => '^HOSTNAME=*', }
# Class
See:
* puppet class parameters
* http://docs.puppetlabs.com/puppet/latest/reference/lang_classes.html
== Class parameters ==
=== Creating a Class with parameters ===
==== Class with a single parameter ====
See: http://docs.puppetlabs.com/puppet/latest/reference/lang_classes.html
class apache ($version = 'latest') { package {'httpd': ensure => $version, # Using the class parameter from above before => File['/etc/httpd.conf'], } }
==== Provide a default value to a parameter ====
==== Defaulting a parameter to a default value, in Hiera ====
class lighttpd ( $szWebProcessOwnerName = hiera( 'WebProcessOwner', 'lighttpd' ), $szWebRootDirectory = hiera( 'WebRootDirectory', '/var/www' ) ) inherits lighttpd::params { ... }
=== Transfer parameters in class instantiation ===
==== Hash, class parameters ====
The Class header:
class lighttpd ( $szWebProcessOwnerName = hiera( 'WebProcessOwner', 'lighttpd' ), $szWebRootDirectory = hiera( 'WebRootDirectory', '/var/www' ), $harAliasMappings ) inherits lighttpd::params { ... }
The Template usage:
<% @harAliasMappings.each_pair do |szAlias, szDirectory| -%>
- <%= szAlias %>: <%= szDirectory %> <% end %>
The caller definition:
$arAliases = { 'git' => '/var/git', 'test' => '/var/test', }
class { "lighttpd": harAliasMappings => $arAliases, }
==== Default parameter values ====
==== modify a line in a file ====
#sonar.jdbc.url=jdbc:postgresql: file_line { 'set_sonar_db_postgresql': path => "$SONARRUNNER_CONF", line => 'sonar.jdbc.url=jdbc:postgresql://localhost/sonar', match => '^.sonar.jdbc.url=jdbc:postgresql:', require => Exec [ 'install_sonar' ], }
## Hiera
### Configuration of Hiera - in puppet 3
From Listing 12.8 in 'Pro Puppet'
# sudo mv /etc/hiera.yaml /etc/puppet/hiera.yaml
# sudo ln -s /etc/puppet/hiera.yaml /etc/hiera.yaml
# sudo mkdir /etc/puppet/data
# sudo vi /etc/puppet/hiera.yaml
* add: :datadir: /etc/puppet/data
# sudo vi /etc/puppet/data/defaults.yaml
* `---`
* `IpAddressForSupportingKickStart: '10.1.233.3'`
# hiera IpAddressForSupportingKickStart
#### Lookup missing values in Hiera
### Configuration of Hiera - in puppe 5
See: https://puppet.com/docs/puppet/5.1/hiera_quick.html
e.g: /etc/puppetlabs/code/environments/production/hiera.yaml
Then add you values to e.g. : /etc/puppetlabs/code/environments/production/data/common.yaml
# rspec
* http://rspec-puppet.com/tutorial/
* http://stackoverflow.com/questions/201385/getting-started-with-rspec-looking-for-tutorials
== File operations ==
=== LVM ===
=== mounting ===
https://awaseroot.wordpress.com/2012/11/03/puppet-module-for-etcfstab-mounts/
mount { '/var/ks':
device => '/dev/vg_images/kickstart',
fstype => 'ext4',
ensure => mounted,
options => 'defaults',
atboot => true,
require => [
File ['/var/ks' ],
Lvm::Volume[ 'kickstart' ],
],
}
# Modules in action
== Network configuration ==
=== razorsedge/network ===
For configuring the network interfaces.
See: https://forge.puppetlabs.com/razorsedge/network
# Virtual machine preparation/installs
== files ==
sub GetFile { my $szHttpBaseSource = shift; my $szLocalDestination = shift; my $szFileName = shift;
if ( ! -f "$szLocalDestination/$szFileName" ) {
cd $szLocalDestination; wget $szHttpBaseSource/$szFileName
;
}
}
sub GetAndDeployModuleTgz { my $szPuppetPackageName = shift; my $szPuppetModuleName = shift;
GetFile($f_szHttpBaseSourcePuppet, $f_szLocalDestination, "$szPuppetPackageName.tar.gz");
if ( ! -e "/etc/puppet/modules/$szPuppetModuleName" ) {
print "III Installing the $szPuppetPackageName module.\n";
cd /etc/puppet/modules; tar -zxf $f_szLocalDestination/${szPuppetPackageName}.tar.gz
;
cd /etc/puppet/modules; ln -s $szPuppetPackageName $szPuppetModuleName
;
}
}