Hi Ben, I understand what you mean but I guess there must be any way to check if I file exists on the client and act in consecuence.
I mean, if I want to identify a MySQL server by the existance of /etc/my.cnf and execute a systemctl enable mysql && systemctl start mysql that should work, right? Thanks for the help & regards, Joaquín El sábado, 18 de enero de 2020, 1:12:57 (UTC+1), Ben Ford escribió: > > But when I execute this from a server-client infrastructure it seems like >> the conditionals don't work They are not even processed: > > > Oh, they're processed just the same. But the key part that you've missed > is that the catalog is compiled on the *master*. That's where all > functions run. The catalog that the agents get is just a json file that > describes what state the system should be in. The reason it appeared to > work when you ran puppet apply was that apply operates like both master and > agent in that it compiles the catalog and then enforces it. > > What's the use case you're trying to solve? Writing code that does > different things based on some arbitrary condition that might have > completely different results at different times is generally a brittle > anti-pattern. We generally want a catalog to manage a system with a known > end state. > > On Fri, Jan 17, 2020 at 8:15 AM Joaquin Veira <[email protected] > <javascript:>> wrote: > >> Hi, >> >> I'm trying to use a condition based on the existance of a file. Something >> like this: >> >> if find_file('/etc/if_this_file_exists') { >> file { '/etc/create_this_file': >> ensure => present, >> owner => 'root', >> group => 'root', >> mode => '0755', >> source => >> "puppet:///modules/${module_name}/etc/create_this_file", >> } >> } >> >> This is working correctly in a laboratory environment launched with: >> >> [root@labserver ~]# puppet apply --modulepath=/home/user/git/ -e "include >> my_module" --verbose --noop >> Info: Loading facts >> Notice: Compiled catalog for labserver in environment lab in 0.04 seconds >> Info: Applying configuration version '1579255663' >> Notice: /Stage[main]/my_module::Files/File[/...]/mode: current_value >> '0777', should be '0755' (noop) >> Notice: /Stage[main]/my_module::Files/File[/....]/mode: current_value >> '0777', should be '0755' (noop) >> Notice: /Stage[main]/my_module::Files/File[/...]/mode: current_value >> '0777', should be '0644' (noop) >> Notice: /Stage[main]/my_module::Files/File[/...]/mode: current_value >> '0777', should be '0770' (noop) >> Notice: /Stage[main]/my_module::Files/File[/...]/ensure: current_value >> 'absent', should be 'file' (noop) >> Notice: Class[my_module::Files]: Would have triggered 'refresh' from 5 >> events >> Notice: Stage[main]: Would have triggered 'refresh' from 1 event >> Notice: Applied catalog in 0.12 second >> >> But when I execute this from a server-client infrastructure it seems like >> the conditionals don't work They are not even processed: >> >> [root@devserver ~]# puppet agent -tv --debug --noop >> ... >> Debug: /Stage[main]/previous_module::Install/File[/...]: Adding >> autorequire relationship with User[root] >> Debug: /Stage[main]/my_module::Files/File[/...]: Adding autorequire >> relationship with File[/etc/cron.daily] >> Debug: /Stage[main]/my_module::Files/File[/...]: Adding autorequire >> relationship with User[root] >> Debug: /Stage[main]/next_module::Config/App::Conf[00-syslog]/File[/...]: >> Adding autorequire relationship with User[root] >> ... >> >> Sorry I have to modify the output so I don't show the real paths & files. >> >> Can anyone explain to me why is this not working, please? >> >> Thanks & regards, >> >> Joaquí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 [email protected] <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/puppet-users/a13df78f-e816-47e8-92d7-3cc46c316276%40googlegroups.com >> >> <https://groups.google.com/d/msgid/puppet-users/a13df78f-e816-47e8-92d7-3cc46c316276%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/cfcc9d8e-86a2-43bf-8c38-866a77b72cd8%40googlegroups.com.
