Puppet: process local template - puppet

I am new to puppet, I am facing one issue with the same.
How can I use the erb template on the clients node and process them through puppet class, I know the templates need to be on the puppet master but my erb templates are on client node. Is there any way to accomplish this?
One more issue, can I execute any commmand on client node(again not on puppet master) through puppet??

Templates are evaluated during catalog compilation. The master sends this catalog to the node. I suspect you want to have node-specific settings applied, which you can use with facter and custom facts.

Related

How To allow unexperienced users to use my Puppet module

I am developing opensouce project with a huge pile of dependencies, and I find Puppet a perfect tool for my requirements.
However, my target audience is not necessarily experienced with Puppet. To the point they may not be even know how web servers work. So I would like to ask the user to “run this in terminal” for the simplest case, but if the user also wants to configure some parts of my software, he would have to learn puppet. And educating them Puppet defeats the “servers for dummies” purpose of my project.
Basically, dare I say, I need Unity from the deployment world.
The thing I came up with, is to use ‘json’ as a backend for Puppet, and then write some GUI tool that would generate/modify that json using JSON Schema. Of couse, this thing will be optional and experient Puppet usets could still just use my module as is.
The questiond is, am I doing it right? Is there a solution for my problem?
Thanks in advance.
You can use Hieradata to give the ability to users to configure some parts for your "Software". you can put your hiera configuration in a git repository or build a tool to edit & update this hiera configuration.
There is some tools that you can use in order to make more easier for your users like Foreman and Puppetboard
But I think it's mandatory for your users to have a basic knowledge of Puppet so they can debug or manipulate the software.
These are some things that you can use.
Have a look at these:-
https://puphpet.com/
https://github.com/voxpupuli/puppetboard

What is the best way to use puppet to update files within a WAR file?

We have several web projects that we deliver as .war files and deploy to jboss. We have a situation where the exact same "war"/code base is delivered to multiple environments with each environment requiring different auth-constraints to be defined in the web.xml. What is the best way/best practice on delivering these different configurations.
You can either
supply specific builds for each environment
deploy the same build everywhere and use Puppet or similar tools to manage specific web.xml content per environment
Which is cleaner and/or more easy to implement depends on your existing work flows. There may be other alternatives as well.

How to test for dependencies on the compiling puppet node

Is it possible to test, in a puppet manifest, for a dependency on the compiling node (the master or the applying node in case of a masterless setup)?
I've written a profile manifest for base nodes in my network. All nodes should include this profile, including the puppet masters. In this profile, some parts use puppetdb. This gets installed via a puppetmaster profile manifest. I need a way to conditionally skip the parts of the base profile manifest that uses puppetdb, until it is installed.
Yes We Can :-)
I think your question alludes to the fact that Facter only gathers information about the agent node, rather than the master.
To retrieve state from the master, you can use the generate function like this:
if generate('/usr/local/bin/is-puppetdb-installed') =~ /^yes/ {
$puppetdb_installed = true
}
You will need to write a generator script that produces appropriate output.

Node classifications made via hiera do not show up in PE Console

I have been experimenting with using hiera for node classification. I followed this example: http://docs.puppetlabs.com/hiera/1/complete_example.html
I was able to assign a node of mine two classes as per this json file:
{
"classes" : [ "ntp",
"base" ],
...
I can see the effects of these class assignments in the puppet runs for my node, but when I look at the node with the Puppet Enterprise 3 Console I only see that the class pe_mcollective has been assigned to the node. Why isn't the Puppet Enterprise Console not aware that my node has been assigned the classes ntp and base?
Thanks
See the Puppet documentation related to data sources: http://docs.puppetlabs.com/pe/latest/puppet_assign_configurations.html. The Puppet Enterprise Console does not ingest site.pp, node.pp or Hiera data and therefore such configuration data is not visible in the PE Console interface.

Run arbitrary ruby code during puppet execution?

I'm working on extending the puppetlabs-mongodb module to allow for user authentication. The challenge is that mongo changed its mechanism for enabling user authentication between version 2.2 and version 2.4 and so distinct code must be run in order to give a user authentication credentials to a database.
My initial thought was to create a custom facter fact that basically captured the output of mongod --version, but it appears that facter facts are loaded before the puppet manifest is executed. Is there a way to execute arbitrary code at run time during puppet execution so that I can access mongod --version and decide which method to use to enable user authentication?
Note: One approach would be to have puppet run a single script to create user credentials and have the script detect the mongod --version at runtime. This doesn't seem like a very puppet-y way of doing things, but perhaps I am off base on that. What is the best way to handle the need for accessing variables dynamically in puppet/facter?
The word from #puppetlabs is that you can not run ruby code (or any other code) dynamically during a puppet run. The "right" way to do this is in the note above with an exec statement that dynamically checks for the mongodb version. For details on the implementation, see manifests/add_user.pp and the associated templates/add_user*.erb.
If anyone has a more "puppety" method for accomplishing this, I'd love to learn about it!
Just put your Ruby code in a ERB template and use template("${module_name}/templ.erb") to return your version string.

Resources