1

I want to push some config file to my all servers by puppet. File is almost the same for all servers, but there is one change - hostname.

I've created module in puppet with manifest and temp-conf-file. I include to all node. All is fine.

My question is: how can i push that file to all server with change one/two lines in that file. But i don't want to set config file in modules for all. I want to use one file and during the push change in side two lines.

Thank you for help.

Best,

Rafal

Rafał Kamiński
  • 187
  • 2
  • 5
  • 15

1 Answers1

5

I would use a template. Set your file resource to use content instead of source:

content => template("mymodule/temp-conf-file.erb"),

Then have the template substitute the hostname. The template would be located in the templates subdirectory of your module:

# This file is managed by puppet
... random config stuff ...
hostname = <%= hostname %>

You can also use fqdn or something else.

Official documentation: https://puppet.com/docs/puppet/latest/lang_template.html

рüффп
  • 620
  • 1
  • 11
  • 25
lsd
  • 1,673
  • 10
  • 10
  • Thank you i will check it. But i need change two lines, one with hostname, one with ip address. – Rafał Kamiński May 08 '13 at 12:16
  • 1
    You want to look at facter's [ipaddress][http://docs.puppetlabs.com/facter/latest/core_facts.html#ipaddress] fact. Facter returns a ton of facts about the environment. In your config file template, you can reference any facter fact freely, just like hostname above. – François Beausoleil May 08 '13 at 17:41