Robin Jonsson
2013-May-08 10:36 UTC
[Puppet Users] Node definition from file (heterogeneous hostnames)
Hi, We would like to specify nodes in site.pp from a file. Is this possible? We have a script that should only be run by x nodes which can be different from time to time. Any suggestions? Thanks in advance Regard, Robin Jonsson -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-May-08 13:24 UTC
[Puppet Users] Re: Node definition from file (heterogeneous hostnames)
On Wednesday, May 8, 2013 5:36:16 AM UTC-5, Robin Jonsson wrote:> > Hi, > > We would like to specify nodes in site.pp from a file. Is this possible? > We have a script that should only be run by x nodes which can be different > from time to time. > > Any suggestions? > >I don''t think I understand the question. I mean, you can use ''import'' statements in site.pp to bring in node declarations that are physically located in other files (and that''s a common practice), but I don''t see how that helps you solve your problem more than just putting the node declarations directly in site.pp would do. You can also use an external node classifier instead of (or in addition to) node blocks to tell Puppet what classes to apply to your nodes. As a special case, you can make hiera function as an ENC, so that the data about what classes to apply are obtained from a YAML file on the master. Again, I''m not sure whether that actually addresses your problem. The whole idea of driving this with Puppet seems a bit dubious, however. Puppet can do it, but it''s not the sort of thing Puppet is designed for, at least as you''re casting the problem. Specifically, Puppet is fundamentally a state management service, not a script runner. That it can run scripts for you is a component of its state management capabilities, but that should not be your focus. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Robin Jonsson
2013-May-08 13:38 UTC
[Puppet Users] Re: Node definition from file (heterogeneous hostnames)
Thank you for your reply. First of, we are kinda aware of that we are not using Puppet as it should be used with the "state management service". But Puppet seemed to be the a great piece of software with great capabilities. To our problem. Lets say our site.pp looks like this: #Site.pp import "nodes_script" import "monitor_script" import "run_script" node /^linuxnod\d+$/ { include nodes_script } node ''monitor.rosi.local'' { include monitor_script } All works well with our modules. But we would now like to add the module "run_script" to some nodes that can''t be "regex:ed". The nodes are present in a file named "hosts". Can I in some way include these nodes to the "node ''<nodes>'' { include run_script }" in site.pp? So that the run_script is for those nodes presented in "hosts". If not, any suggestion on how we can achieve it? Thanks in advance Den onsdagen den 8:e maj 2013 kl. 15:24:47 UTC+2 skrev jcbollinger:> > > I don''t think I understand the question. I mean, you can use ''import'' > statements in site.pp to bring in node declarations that are physically > located in other files (and that''s a common practice), but I don''t see how > that helps you solve your problem more than just putting the node > declarations directly in site.pp would do. > > You can also use an external node classifier instead of (or in addition > to) node blocks to tell Puppet what classes to apply to your nodes. As a > special case, you can make hiera function as an ENC, so that the data about > what classes to apply are obtained from a YAML file on the master. Again, > I''m not sure whether that actually addresses your problem. > > The whole idea of driving this with Puppet seems a bit dubious, however. > Puppet can do it, but it''s not the sort of thing Puppet is designed for, at > least as you''re casting the problem. Specifically, Puppet is fundamentally > a state management service, not a script runner. That it can run scripts > for you is a component of its state management capabilities, but that > should not be your focus. > > > John > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Robin Jonsson
2013-May-09 07:06 UTC
[Puppet Users] Re: Node definition from file (heterogeneous hostnames)
bump -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Simon Flash
2013-May-09 09:21 UTC
[Puppet Users] Re: Node definition from file (heterogeneous hostnames)
Greetings Robin! What about this solution? It''s a quick-fix, but it might work well as you want it to? Do a script which contains (see it as pseudocode): for each hostname in hosts do echo "node ''$hostname'' {include run_script}" >> /etc/puppet/manifests/site.pp done What do you other guys think of this solution? To risky to edit /etc/puppet/manifests/site.pp with a script? Yours, Simon Den torsdagen den 9:e maj 2013 kl. 09:06:23 UTC+2 skrev Robin Jonsson:> > bump-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-May-09 13:08 UTC
[Puppet Users] Re: Node definition from file (heterogeneous hostnames)
On Wednesday, May 8, 2013 8:38:52 AM UTC-5, Robin Jonsson wrote:> > Thank you for your reply. > > First of, we are kinda aware of that we are not using Puppet as it should > be used with the "state management service". But Puppet seemed to be the a > great piece of software with great capabilities. > > To our problem. Lets say our site.pp looks like this: > > #Site.pp > > import "nodes_script" > import "monitor_script" > import "run_script" > > node /^linuxnod\d+$/ { > include nodes_script > } > > node ''monitor.rosi.local'' { > include monitor_script > } > > All works well with our modules. But we would now like to add the module > "run_script" to some nodes that can''t be "regex:ed". The nodes are present > in a file named "hosts". Can I in some way include these nodes to the "node > ''<nodes>'' { include run_script }" in site.pp? So that the run_script is for > those nodes presented in "hosts". If not, any suggestion on how we > can achieve it? > >> >>Ah. You want just the node *names* to come from an external file, not entire node definitions. Sorry, that''s not gonna happen. You have several options. The most similar to what you asked is to in fact provide a whole node definition (only one is needed) for these exceptional hosts: import ''run_script.pp'' node ''node1.my.com'', ''node2.my.com'', ... ''node42.my.com'' { include run_script } Then ''import'' that into site.pp. You will recognize that that has the form of a list of node names, bracketed by a small amount of decoration, so it''s not too different from what you asked. As I already said, you can also use an ENC instead of a flat file to feed the information to Puppet, including (but not restricted to) pressing hiera into service in that effort. For example, to fall back to hiera for otherwise-unmatched nodes, add something like this to site.pp: node default { $classes = hiera(''classes'') # $classes could contain ''run_script'' where appropriate include $classes } John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.