Is it possible to dynamically edit a node definition? Basically, given a node, add or remove from it''s node definition on the fly. Right now, I am doing a find on the /etc/puppet/manifests/nodes directory on all ".pp" files, grepping for "node hostname { ", and using a sed command to edit the node definition. Is there a more straightforward way to do this? Can it be done in memory? Or at least, is there a better way to return the .pp file that contains a particular node definition? Thanks! -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/8WmovK4YkQsJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 17 September 2011 16:42, Sav <savannah.durbin@gmail.com> wrote:> Is it possible to dynamically edit a node definition? Basically, given a > node, add or remove from it''s node definition on the fly. > > Right now, I am doing a find on the /etc/puppet/manifests/nodes directory > on all ".pp" files, grepping for "node hostname { ", and using a sed command > to edit the node definition. Is there a more straightforward way to do > this? Can it be done in memory? Or at least, is there a better way to > return the .pp file that contains a particular node definition? > > Thanks! >You should probably write an external node classifier (ENC) for this: http://docs.puppetlabs.com/guides/external_nodes.html -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
I looked into that, but I am not in control of all node definitions across the system: "You can optionally combine an ENC with regular node definitions in site.pp. This works on the “I hope you brought enough for everybody” rule: things will work correctly if you have an ENC and no node definitions, but if there’s at least one node definition, you need to have a default node defined or account for every node with a definition; Puppet will fail compilation with an error if a definition for a given node can’t be found." In my situation, nodes are already defined, I just need a way to dynamically edit them. I have no control over the overall puppet config... I simply just need to add to a node definition. Unless I am misinterpreting, it seems as if ENC could potentially cause conflict with pre-defined nodes. Am I mistaken on this? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/vCuxQLzuvFwJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Sav, Maybe I''m confused about what you are trying to do, but why not just do "import nodes/*" from site.pp instead of using find commands? The only catch is that if you add or remove a node, you have to do a "touch" command on site.pp to get puppet to re-read the import statement and pick up the new (or removed) files. On Sep 17, 11:42 am, Sav <savannah.dur...@gmail.com> wrote:> Is it possible to dynamically edit a node definition? Basically, given a > node, add or remove from it''s node definition on the fly. > > Right now, I am doing a find on the /etc/puppet/manifests/nodes directory on > all ".pp" files, grepping for "node hostname { ", and using a sed command to > edit the node definition. Is there a more straightforward way to do this? > Can it be done in memory? Or at least, is there a better way to return the > .pp file that contains a particular node definition? > > Thanks!-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Import nodes/* is already being done. My problem is, I am not in control of any node definitions. I am completely ignorant as to what nodes have, or have not been defined (In most situations, the nodes have already been defined). Given a hostname, I have to (programmatic-ly) find where that node is being defined, and add or remove to the node definition. If the node has not been defined, I need to create the node definition. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/VrwudaWdLbgJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
To add to my previous post, here is the big picture: I am given a system, where puppet is already set up. Lets say a new rpm is created. I need to install that rpm on a specific host by putting that rpm in a yum repository, and creating a pupmod that installs that rpm on a particular node. I am writing an application to do this, so it can not be done by hand. There are other sys-admins that have previously created node definitions for each node... that piece is out of my control. Here is the pseudo code of what I would ideally like to do: require ''puppet'' node = Puppet::Node.find_by_name("puppet.example.com") node.add_to_node_definition("include \"my yum repo & my rpm\") Or at least is there something within puppet that can *at least* return the file that defines a particular node?? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/C_EgBF6g4GsJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
To add to my previous post, here is the big picture: I am given a system, where puppet is already set up. Lets say a new rpm is created. I need to install that rpm on a specific host by putting that rpm in a yum repository, and creating a pupmod that installs that rpm on a particular node. I am writing an application to do this, so it can not be done by hand. There are other sys-admins that have previously created node definitions for each node... that piece is out of my control. Here is the pseudo code of what I would ideally like to do: require ''puppet'' node = Puppet::Node.find_by_name("puppet.example.com") node.add_to_node_definition(" include \"my yum repo & my rpm\"") Or is there something within puppet that can *at least* return the file that defines a particular node?? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/WHE90t7SlqkJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.