Ask Your Question
0

Use Facts in puppet manifest

asked 2016-12-15 02:20:02 -0500

shimm gravatar image

Hi,

I want to install a service on e.g. 10 Nodes. In each Config of this service all other nodes have to be configured. So I need a possibillity to get an array of nodes with this Class in a manifest.

How can I achieve this?

Thanks in advance

edit retag flag offensive close merge delete

Comments

Can you show some sort of sample of what you want to achieve?

lupin gravatar imagelupin ( 2016-12-15 03:28:20 -0500 )edit

For exmaple: service X is configured on node1,node2 and node3. In the Config of ther service on each host, there has to be "Nodes = [node1,node2,node3]". If a new node joins the cluster, the config on all hosts should be updated with the new node automatically

shimm gravatar imageshimm ( 2016-12-15 04:03:50 -0500 )edit

If you want to do this, you need to use puppetDB and a query it's information (based on a role fact or something similar), or have some other way of knowing what nodes are in your system. In our case, we can do something like that but we get our information from the aws API and tags

DarylW gravatar imageDarylW ( 2016-12-15 06:50:55 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-12-15 07:11:15 -0500

DarylW gravatar image

One example to achieve what you are looking for (if you have puppetdb configured in your setup) is to use the puppetdbquery module. You can use the query_nodes method to query a set of nodes based on some fact, which it will return as an array.

query_nodes Accepts two arguments, a query used to discover nodes, and a optional fact that should be returned.

Returns an array of certnames or fact values if a fact is specified.

Examples
 $hosts = query_nodes('manufacturer~"Dell.*" and processorcount=24 and Class[Apache]')

$hostips = query_nodes('manufacturer~"Dell.*" and processorcount=24 and Class[Apache]', 'ipaddress')
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-12-15 02:20:02 -0500

Seen: 87 times

Last updated: Dec 15 '16