I use arrows to specify the order without class, you could use:
Package['a.i386']->Yumrepo ['RepoA']->Package ['a.x86_64']->File
['/etc/config_file_1] and so on...
For example now I'm working with mongo and I use a single class with the
previous dependence_
Package['mongo-10gen-server-2.2.6']->File[$paths]->File['/etc/mongo/arbiter.conf']->File['/etc/mongo/shard1_master.conf']->File['/etc/mongo/shard1_secondary.conf']->File['/etc/init.d/mongod']->Service['mongod']->File['/etc/puppet/rs.js']->Exec["mongo
$ip:$port_replica/admin /etc/puppet/rs.js"]
Regards,
Luis
Luis
El jueves, 30 de enero de 2014 23:00:49 UTC+1, Stack Kororā escribió:
>
> Greetings,
> I am trying to puppetize a process that goes like this:
> 1) remove package a.i386
> 2) create repo file
> 3) install package a.x86_64 from repo
> 4) update config_file_1
> 5) update config_file_2
> 6) update config_file_3
> 7) start service
>
> Shouldn't be too hard right? Except I have played with every combination I
> can think of using with notify, subscribe, before, and require and I can't
> seem to get this to all happen in the same run. It always does a part of it
> the first run then requires a second run to finish up (a couple of
> variations required three and even four runs!). I am struggling to find out
> where I am going wrong. The code I have right now is the "best" in that it
> always requires _just_ two runs to complete. I edited out a lot of the
> parameters that are trivial just to focus on the dependency problem. I can
> share full code if I really need to but it is a bit messy as I pass all
> kinds of stuff to the template and I don't want to confuse the issue.
>
> Here is the basis of my code:
>
> package { ['a.i386']:
> ensure => absent,
> before => Package['a.x86_64'],
> }
>
> yumrepo { "RepoA":
> # stripped out other paramters
> notify => Package['a.x86_64'],
> }
>
> package { ['a.x86_64']:
> ensure => absent,
> subscribe => Yumrepo['RepoA'],
> }
>
> file { "/etc/config_file_1":
> # stripped out other paramters
> subscribe => Package['a.x86_64'],
> }
>
> file { "/etc/config_file_2":
> # stripped out other paramters
> subscribe => Package['a.x86_64'],
> }
>
> file { "/etc/config_file_3":
> # stripped out other paramters
> subscribe => Package['a.x86_64'],
> }
>
> service { 'a':
> # stripped out other paramters
> subscribe =>
> File["/etc/config_file_1","/etc/config_file_2","/etc/config_file_3"],
> }
>
> As stated, I get a consistent run out of this. I just have to do it twice.
> First run:
> a.i386 is removed
> Yumrepo is created
> scheduling refresh of service
> All three files fail to install
> service fails
>
> Second run
> a.x86_64 is created
> scheduling refresh of service
> All three files install
> service works
>
> Why?
>
> According to this page [1] subscribe "Causes a resource to be applied
> after the target resource. The subscribing resource will refresh if the
> target resource changes." Thus the scheduling of a refresh shouldn't happen
> until /after/ the files and NONE of the files are supposed to run until
> /after/ the package is installed! But clearly, this is not the case! At
> least the service schedule happens after the files fail so that is somewhat
> in order. And the repo is created properly, so that is a plus. I have a
> feeling that it is because the yum repo isn't refreshed before trying to
> install the package, but I am not 100% sure on that. As far as I can tell
> through debug, puppet never even attempts to install a.x86_64 until the
> second run.
> [1]
> http://docs.puppetlabs.com/puppet/latest/reference/lang_relationships.html
>
> The only thing left that I can think of that I haven't tried would be to
> shove each process into a subclass then chain them together something like
> this
> {class::remove}->{class::addyum}->{class::install}->{class::configfiles}->{class::service}
>
> but that seems /really/ silly.
>
> Can someone please point out where things are going screwy for me? I would
> greatly appreciate it.
>
> Thanks!
>
>
--
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/ebf12cc7-a011-4f23-8aba-37fefdff9764%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.