FAQ
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 puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/4562f58e-d88d-4d84-bab3-9337c6a081f9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Luis León at Jan 31, 2014 at 11:23 am
    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 puppet-users+unsubscribe@googlegroups.com.
    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.
  • Luis León at Jan 31, 2014 at 11:25 am
    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

    --
    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 view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/58f3073e-74a5-46bb-a757-a7429186ea72%40googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Stack Kororā at Jan 31, 2014 at 12:40 pm
    Greetings,

    Huh. I don't know why, but for some silly reason I thought I had to use
    subclasses with arrows. I will re-work my script with them and see how it
    goes.

    Thanks! I appreciate the suggestion.

    --
    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 view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/d916ca64-a5da-45f6-b73b-94b53446e600%40googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Zerozerounouno at Jan 31, 2014 at 1:21 pm

    On Friday, January 31, 2014 1:40:38 PM UTC+1, Stack Kororā wrote:
    Huh. I don't know why, but for some silly reason I thought I had to use
    subclasses with arrows. I will re-work my script with them and see how it
    goes.
    Hi,
    I'll add that chaining arrows between single resources can quickly become
    cumbersome when the number of resources starts increasing (more files, more
    packages…).
    I worked around this by using tags and resource collectors.

    You can set tags as default attributes for the resource types you are
    using, e.g.:

    Package {
         tag => "my-packages",
       }

    File {
         tag => "my-files",
    }

    Service {
         tag => "my-services",
    }

    And then you can use resource collectors to define dependencies between
    your tagged types:

    Package <| tag == "my-packages" |>
    ->
    File <| tag == "my-files" |>
    ~>
    Service <| tag == "my-services" |>

    (Writing dependencies on separate lines makes them easier to read and
    understand IMHO)

    --
    Marco

    --
    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 view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/10314e76-7ffa-4e59-9b4c-9ca4167230ce%40googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedJan 30, '14 at 10:00p
activeJan 31, '14 at 1:21p
posts5
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase