Ian M.
Ian M.

Reputation: 31

Puppet script that runs on a local machine without need for hostname specification

I want to write a puppet script that can be installed on a machine and automatically check a git repo for changes and apply them to the hostfile.

In reading puppet documentation I commonly see the following explicit reference to a machine's hostname:

node 'node1'{ }

Is there a way for me to deploy this to a number of developer machines and have it update the hosts file without explicitly listing the hostname for each of those machines in the script? Or perhaps there is an even better approach I'm missing?

DNS server is out of the question so please don't suggest that :)

Upvotes: 1

Views: 433

Answers (2)

Felix Frank
Felix Frank

Reputation: 8223

The node block is meaningful only in a master/agent style Puppet setup.

While this is prevalent, there is a strong case for masterless operation.

In your special case, you should definitely solve your problem without a master. Just write either

  1. a complete mytask.pp file that just declares all resources you care about
    • and use it by calling puppet apply /path/to/mytask.pp on each machine or
  2. a simple Puppet module that does what you need, deploy it to each machine
    • and call puppet apply -e 'include mymodule'

The apply subcommand is the counterpart to puppet agent if you want to put Puppet to work without involving the puppet master.

Upvotes: 2

jasonldx
jasonldx

Reputation: 11

If you want to apply to all machines, you can use the following:

node default { }

And you also can use regular expression to include a group of machines, like:

node /^workstation*/ { }

or

node /^workstation[1-8]/ { }

Upvotes: 1

Related Questions