1

Folks

We have a custom deployment tool at the moment at work and we're evaluating replacing it with something non-proprietary like puppet.

One of the main things that it does for us at the moment is tokenization. For example in a a server.xml file in a tomcat deployment, we might deploy a file called server.xml.tokenzenized with a line like the below

<Ajp12Connector port="@@TOMCAT.AJP.PORT@@" ajpidFile="conf/ajp12_2.id" />

and then have a tokens.xml file that would have a line like

<TOKEN NAME='TOMCAT.AJP.PORT' value = '8080/>

our deployment process then scans server.xml.tokenized, and replaces the tokens, writing the file out to server.xml.

Can puppet do this for an arbitrary file - or for something like tomcat, would I have to download a plugin that understood how tomcat worked?

Secondly, from the reading I've done to-date, it seems like most people use the puppet agent to retrieve files from the master - does this have to be the case - can you have a script that uses the puppet modelling and infrastructure and then log into hosts to deploy software? - the rationale is that for various reasons, we have a bias against agents in our environment.

Cheers

1 Answer 1

2

To the first question: yes, puppet can do that using templates coupled with hiera and/or facter. This process is absolutely abstracted from the software using the templated file.

For example, you can have a template for server.xml with a section like this:

<Connector address="<%= @ipaddress_eth0 %>"
           executor="tomcatThreadPool"
           port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />

The <%= @ipaddress_eth0 %> part is what you currently call a 'token', and puppet knows how to replace it for any given host using facter:

# facter ipaddress_eth0
10.0.0.2

You can have custom facts if you need them, too.

The hierarchical data topic is a little more complex and would require you to read some documentation to see how can it help you with your deployments. This is a very nice presentation of its possibilities. Basically, its purpose is to provide the means to separate code and data (your 'tokens'), and store that data in a familiar, easy to maintain format (YAML or JSON). The use case you describe above (defining a custom port for tomcat), is the classic use pattern of hiera:

In the tomcat module you'd have something like:

class tomcat (
    $port
    ){
    #rest of the module
}

In a template (say, server.xml.erb):

<Ajp12Connector port="<%= port %>" ajpidFile="conf/ajp12_2.id" />

And the portion of your hierarchical data matching that code would look something like:

tomcat::port = 8080

To the second question, the answer is also yes, to some extent. You can use marionette collective (in fact, a part of the puppetlabs offer), to push changes to an agentless farm of servers. You'd need to install the clients, though (not exactly the same, as these clients are passive, unlike the puppet agents, which are proactive in requesting their catalogs to the puppetmaster). Again, it is required that you read the documentation to better understand the details of its functionality.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.