In my previous post about learning Puppet, I left a few open questions that I will attempt to answer as I continue learning.
To apply a class, I created a module, created its
Let us consider the module name to be
Moving on to create a class of interest, let us add one to install Openjdk. The file would be
To apply the manifest, the command would be as follows:
- How can I apply Puppet classes?
- How can I install modules?
- How can I define functions in Puppet?
To apply a class, I created a module, created its
init.pp
file and added a class in it.Let us consider the module name to be
mod
. The init.pp
will be located at mod/manifests/init.pp
. I just keep it empty to begin with. The name of the class in that file has to match the module name though.class mod{
}
Moving on to create a class of interest, let us add one to install Openjdk. The file would be
mod/manifests/jdk.pp
.class mod::jdk () {
notice("Installing openJDK")
# Install java
package { 'openjdk':
ensure => installed,
name => 'java-1.8.0-openjdk-headless',
alias => 'openjdk',
}
}
To apply the manifest, the command would be as follows:
puppet apply --modulepath=/path/to/parent/of/module -e "include mod::jdk"
No comments:
Post a Comment