Nevorotin Vadim
2013-Jul-09 12:01 UTC
[Puppet Users] One resource immediately after another
I need to apply three resources one immediatelly after another. It''s a ifdown/ifup commands, and command to generate /etc/network/interfaces file. I need to do ifdown, then rebuild interfaces, then ifup. I try to add simple relationship, but in this case some File resources are trying to be applied between ifdown and ifup. So they can''t connect to Puppet master to verify source and generate an error. How can I fix it? -- 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. For more options, visit https://groups.google.com/groups/opt_out.
David Schmitt
2013-Jul-09 13:34 UTC
Re: [Puppet Users] One resource immediately after another
On 09.07.2013 14:01, Nevorotin Vadim wrote:> I need to apply three resources one immediatelly after another. It''s a > ifdown/ifup commands, and command to generate /etc/network/interfaces > file. I need to do ifdown, then rebuild interfaces, then ifup. I try to > add simple relationship, but in this case some File resources are trying > to be applied between ifdown and ifup. So they can''t connect to Puppet > master to verify source and generate an error. How can I fix it?In such a case it is best to put all commands into a script and run that. That also has the upside, that you can protect the complete network restart with a single refreshonly/notify pair. Regards, David -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Erik Dalén
2013-Jul-09 13:48 UTC
Re: [Puppet Users] One resource immediately after another
Putting them in a separate stage is also a possibility. On 9 July 2013 15:34, David Schmitt <david@dasz.at> wrote:> On 09.07.2013 14:01, Nevorotin Vadim wrote: > >> I need to apply three resources one immediatelly after another. It''s a >> ifdown/ifup commands, and command to generate /etc/network/interfaces >> file. I need to do ifdown, then rebuild interfaces, then ifup. I try to >> add simple relationship, but in this case some File resources are trying >> to be applied between ifdown and ifup. So they can''t connect to Puppet >> master to verify source and generate an error. How can I fix it? >> > > In such a case it is best to put all commands into a script and run that. > That also has the upside, that you can protect the complete network restart > with a single refreshonly/notify pair. > > > Regards, David > > > -- > 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<puppet-users%2Bunsubscribe@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<http://groups.google.com/group/puppet-users> > . > For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> > . > > >-- Erik Dalén -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Nevorotin Vadim
2013-Jul-09 15:48 UTC
Re: [Puppet Users] One resource immediately after another
Unfortunatelly, stages is absolutely useless because of strict limitations (notify between stages, only classes), and I can''t use one script because of ifup|ifdown commands and interfaces file is in different modules. I have a defined type with ifup/ifdown commands for specified interface. Something like this: define iface ( $iface ) { exec {"ifdown $iface": } exec {"ifup $iface": } } And command in some class, which rewrite /etc/network/interfaces. Something like exec {''rewrite interfaces'': } I need to do ifdown for all interfaces before rewrite configuration, and ifup - after. Ok, I''ve add to the end of my iface defined type: Exec["ifdown $iface"] ~> Exec[''rewrite interfaces''] ~> Exec["ifup $iface"] And I need to tell Puppet not to put at least any File and Service resources between ifdown and ifup, because there network is unreachable. Services I can put after all ifup with <| |>, but files isn''t so simple and must be before ifdown and after ifup. So I can''t fix a problem with simple relationships and look for a solution. вторник, 9 июля 2013 г., 17:48:45 UTC+4 пользователь Erik Dalén написал:> > Putting them in a separate stage is also a possibility. > > > On 9 July 2013 15:34, David Schmitt <da...@dasz.at <javascript:>> wrote: > >> On 09.07.2013 14:01, Nevorotin Vadim wrote: >> >>> I need to apply three resources one immediatelly after another. It''s a >>> ifdown/ifup commands, and command to generate /etc/network/interfaces >>> file. I need to do ifdown, then rebuild interfaces, then ifup. I try to >>> add simple relationship, but in this case some File resources are trying >>> to be applied between ifdown and ifup. So they can''t connect to Puppet >>> master to verify source and generate an error. How can I fix it? >>> >> >> In such a case it is best to put all commands into a script and run that. >> That also has the upside, that you can protect the complete network restart >> with a single refreshonly/notify pair. >> >> >> Regards, David >> >> >> -- >> 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...@googlegroups.com <javascript:>. >> To post to this group, send email to puppet...@googlegroups.com<javascript:> >> . >> Visit this group at http://groups.google.com/group/puppet-users. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > -- > Erik Dalén >-- 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. For more options, visit https://groups.google.com/groups/opt_out.
Nevorotin Vadim
2013-Jul-09 17:22 UTC
[Puppet Users] Re: One resource immediately after another
I''ve found a hack to forbid File resources with source attribute to be applied before all ifup''s: Exec["ifup $iface"] -> File <| source != [] |> Unfortunatelly, it''s undefined undocumented behavior, so the problem is still here. -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Elias Probst
2013-Jul-10 12:33 UTC
[Puppet Users] Re: One resource immediately after another
Am Dienstag, 9. Juli 2013 19:22:01 UTC+2 schrieb Nevorotin Vadim:> I''ve found a hack to forbid File resources with source attribute to be > applied before all ifup''s: > > Exec["ifup $iface"] -> File <| source != [] |> > > Unfortunatelly, it''s undefined undocumented behavior, so the problem is > still here. >What about using https://forge.puppetlabs.com/adrien/network which does all the dirty work for you instead of re-inventing the wheel? - Elias -- 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. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-Jul-10 13:17 UTC
[Puppet Users] Re: One resource immediately after another
On Tuesday, July 9, 2013 7:01:54 AM UTC-5, Nevorotin Vadim wrote:> > I need to apply three resources one immediatelly after another. It''s a > ifdown/ifup commands, and command to generate /etc/network/interfaces file. > I need to do ifdown, then rebuild interfaces, then ifup.Do you really? Can you not update the /etc/network/interfaces file first, and then some indeterminate time later do ifdown + ifup? Not only would that reduce the constraints on your solution, but it would be more robust (failure to apply the file will not cause the interface to remain down) and less impactful (the interface is down for slightly less time). You can even use ''source'' for the interface config file if you wish. I would structure it like that, putting the down+up into a single Exec. Maybe something like this: define site::net_iface () { exec { "refresh_net_iface:${title}": command => "ifdown ${title} && ifup ${title}", path => ''/bin:/sbin:/usr/bin:/usr/sbin'', provider => ''shell'', refreshonly => true } file { "/etc/sysconfig/networking/ifcfg-title": content => template("ifcfg-${title}.template") notify => Exec["refresh_net_iface:${title}"] } } site::net_iface { ''eth0'': } I try to add simple relationship, but in this case some File resources are> trying to be applied between ifdown and ifup. So they can''t connect to > Puppet master to verify source and generate an error. How can I fix it? >Yes, Puppet relationships control the relative order of resource application, but not (directly) the exact sequence. Generally speaking, if you want a collection of physical resources to be applied atomically then you should structure it as a single Puppet resource. 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. For more options, visit https://groups.google.com/groups/opt_out.
Jérémie Sebban
2013-Jul-10 15:48 UTC
[Puppet Users] Re: One resource immediately after another
I don''t remember where I found this, but I''m now using this all over my manifests: file { ''toto1'': content => bla1, } -> exec { ''toto2'': command => bla2, } -> And so on... -> :) Hope it can work for your case, I use this rather than "require" to have lighter and more readable manifests. Jem Le mercredi 10 juillet 2013 15:17:00 UTC+2, jcbollinger a écrit :> > > > On Tuesday, July 9, 2013 7:01:54 AM UTC-5, Nevorotin Vadim wrote: >> >> I need to apply three resources one immediatelly after another. It''s a >> ifdown/ifup commands, and command to generate /etc/network/interfaces file. >> I need to do ifdown, then rebuild interfaces, then ifup. > > > > Do you really? Can you not update the /etc/network/interfaces file first, > and then some indeterminate time later do ifdown + ifup? Not only would > that reduce the constraints on your solution, but it would be more robust > (failure to apply the file will not cause the interface to remain down) and > less impactful (the interface is down for slightly less time). You can > even use ''source'' for the interface config file if you wish. I would > structure it like that, putting the down+up into a single Exec. Maybe > something like this: > > define site::net_iface () { > exec { "refresh_net_iface:${title}": > command => "ifdown ${title} && ifup ${title}", > path => ''/bin:/sbin:/usr/bin:/usr/sbin'', > provider => ''shell'', > refreshonly => true > } > > file { "/etc/sysconfig/networking/ifcfg-title": > content => template("ifcfg-${title}.template") > notify => Exec["refresh_net_iface:${title}"] > } > } > > site::net_iface { ''eth0'': } > > > I try to add simple relationship, but in this case some File resources are >> trying to be applied between ifdown and ifup. So they can''t connect to >> Puppet master to verify source and generate an error. How can I fix it? >> > > > Yes, Puppet relationships control the relative order of resource > application, but not (directly) the exact sequence. Generally speaking, if > you want a collection of physical resources to be applied atomically then > you should structure it as a single Puppet resource. > > > 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. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-Jul-10 18:50 UTC
[Puppet Users] Re: One resource immediately after another
On Wednesday, July 10, 2013 10:48:48 AM UTC-5, Jérémie Sebban wrote:> > I don''t remember where I found this, but I''m now using this all over my > manifests: > > file { ''toto1'': > content => bla1, > } -> > > exec { ''toto2'': > command => bla2, > } -> > > And so on... -> :) > > Hope it can work for your case, I use this rather than "require" to have > lighter and more readable manifests. > >No, that will not work for the OP. Whether expressed via the chain operators as shown, or via the ''require'' / ''before'' metaparameters, resource relationships affect only the relative order in which resources are applied. They do not ensure what the OP wants, which is to prevent other resources being applied between the related resources. Puppet does not have a way to express that idea, other than to manage the physical resources via the same native Puppet resource. 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. For more options, visit https://groups.google.com/groups/opt_out.
Nevorotin Vadim
2013-Jul-11 09:34 UTC
[Puppet Users] Re: One resource immediately after another
Unfortunatelly, you can''t do ifdown and ifup at the same time, because ifdown must be executed before changing interfaces file (with old interface settings), and ifup - after. If ifdown executed after changing interfaces file, then pre-down and post-down commands from old version willn''t be executed. Moreover, if interface is removed in new version of interfaces file - ifdown and even ''service networking stop'' don''t down it. So, all down commands for interfaces must be before changing interfaces file. There is some workarounds, but all of them are not a right ways. I think, puppet should implement some addition ability to control resource execution, not only before/after. -- 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. For more options, visit https://groups.google.com/groups/opt_out.