On Oct 29, 2:50 am, Jean Baptiste FAVRE
<jean.baptiste.fa...@gmail.com> wrote:
> Hello Andrew,
> Thanks for your answer.
>
> Infact, pkgrepo *is* already like you suggest:
> class pkgrepo {
>     Nginx::Vhost["website.domain.tld"] -> Class['Pkgrepo']
>     include pkgrepo::install,pkgrepo::config
>
> }
>
> Just forget about Nginx::Vhost["packages.iscoolapp.com"] and replace it
> wherever you see it with Nginx::Vhost["website.domain.tld"] (my bad for
> the typo).
>
> And, that's why I don't understand because
> "Nginx::Vhost['website.domain.tld'] -> Class['Pkgrepo']" is supposed to
> make vhost applied before pkgrepo. But in my output examples, package
> reprepro definied in pkgrepo::install got installed before vhosts is set up.
>
> About setting require for pkgrepo::repository, I will try asap.
> My first thought was to specify dependencies between classes in "root"
> class (ie, in pkgrepo and not in pkgrepo::install) for readability purpose.
> But, it that case, I could specify it pkgrepo::repository since it
> defined in node definition. Just wonder why I did not tought about it
> before :-/
>
> Will let you updated right after my tests.
>
> Regards,
> JB
>
> On 29/10/2011 09:26, Andrew Hendry wrote:
>
>
>
> > Hi Jean,
>
> > Is Nginx::Vhost["packages.iscoolapp.com"] getting set up somewhere
> > else in your code?
>
> > If not should your pkgrepo be like this?
> > class pkgrepo {
> >          Nginx::Vhost["website.domain.tld"] -> Class['Pkgrepo']
> >          include pkgrepo::install,pkgrepo::config
> > }
>
> > Or
>
> >      pkgrepo::repository { "test":
> >          docroot     => "/var/www/website.domain.tld",
> >          gpgkeyid    => "C78033BD",
> >          require => Nginx::Vhost["website.domain.tld"],
> >      }
>
> > Good luck.
>
> > On Oct 29, 12:41 am, Jean Baptiste Favre
> > <jean.baptiste.fa...@gmail.com> wrote:
> >> Hello,
> >> There's something I don't understand with classes dependency.
> >> I saw many thread about this subject, but still can not figure how it
> >> works exactly.
>
> >> I'm trying to setup a debian package repository. For that, I need:
> >> - a vhost, served by nginx
> >> - repo managment tools as well as GPG key copied into directory tree
>
> >> So, that makes 2 classes:
> >> include nginx
> >> include pkgrepo
>
> >> "nginx" class install nginx package and provide a define to deal with
> >> vhost definition:
> >>      nginx::vhost { 'website.domain.tld':
> >>          port     => 80,
> >>          docroot  => '/var/www',
> >>          priority => 00,
> >>      }
> >> This define will create directory /var/www/website.domain.tld as well as
> >> deploying vhost file in /etc/nginx/sites-enabled/00-website.domain.tld
>
> >> "pkgrepo" class will install repo managment tools and deploy repository
> >> GPG key in /var/www/website.domain.tld/key.gpg
>
> >> Therefore, it will require vhost to be created before being able to copy
> >> GPG key.
>
> >> Here's my setup:
> >> node nodetest {
> >>      include nginx
> >>      nginx::vhost { 'website.domain.tld':
> >>          port     => 80,
> >>          docroot  => '/var/www',
> >>          priority => 00,
> >>      }
> >>      include pkgrepo
> >>      pkgrepo::repository { "test":
> >>          docroot     => "/var/www/website.domain.tld",
> >>          gpgkeyid    => "C78033BD",
> >>      }}
>
> >> And for classes definition, I got:
> >> class pkgrepo {
> >>          Nginx::Vhost["packages.iscoolapp.com"] -> Class['Pkgrepo']
> >>          include pkgrepo::install,pkgrepo::config
>
> >> }
>
> >> Problem is, when I try to executed it twice, I don't alway have
> >> dependency respected. For sure, I'm doing something wrong, but can not
> >> figure what. Bellow are the execution output.
>
> >> Best regards,
> >> Jean Baptiste Favre
>
> >> Wrong behaviour:
> >> # /usr/sbin/puppetd --no-daemonize --logdest console --onetime --verbose
> >> --preferred_serialization_format marshal
> >> notice: Ignoring --listen on onetime run
> >> info: Caching catalog for nodetest
> >> info: Applying configuration version '1319805719'
> >> notice: /Stage[main]/Pkgrepo::Install/Package[reprepro]/ensure: ensure
> >> changed 'purged' to 'present'
> >> notice:
> >> /Stage[main]//Node[nodetest]/Nginx::Vhost[website.domain.tld]/File[/etc/ngi
> >>  nx/sites-enabled/00-website.domain.tld]/ensure:
> >> defined content as '{md5}bad3fd5741e335516e2e51aaefe2963c'
> >> info:
> >> /Stage[main]//Node[nodetest]/Nginx::Vhost[website.domain.tld]/File[/etc/ngi
> >>  nx/sites-enabled/00-website.domain.tld]:
> >> Scheduling refresh of Service[nginx]
> >> notice: /Stage[main]/Nginx::Service/Service[nginx]: Triggered 'refresh'
> >> from 1 events
> >> notice: Finished catalog run in 6.25 seconds
>
> >> Good behaviour:
> >> # /usr/sbin/puppetd --no-daemonize --logdest console --onetime --verbose
> >> --preferred_serialization_format marshal
> >> notice: Ignoring --listen on onetime run
> >> info: Caching catalog for nodetest
> >> info: Applying configuration version '1319805719'
> >> notice:
> >> /Stage[main]//Node[nodetest]/Nginx::Vhost[website.domain.tld]/File[/etc/ngi
> >>  nx/sites-enabled/00-website.domain.tld]/ensure:
> >> defined content as '{md5}bad3fd5741e335516e2e51aaefe2963c'
> >> info:
> >> /Stage[main]//Node[nodetest]/Nginx::Vhost[website.domain.tld]/File[/etc/ngi
> >>  nx/sites-enabled/00-website.domain.tld]:
> >> Scheduling refresh of Service[nginx]
> >> notice: /Stage[main]/Pkgrepo::Install/Package[reprepro]/ensure: ensure
> >> changed 'purged' to 'present'
> >> notice: /Stage[main]/Nginx::Service/Service[nginx]: Triggered 'refresh'
> >> from 1 events
> >> notice: Finished catalog run in 6.23 seconds- Hide quoted text -


Your setup is a bit strange in using arrow syntax within a class to
declare a dependency of that class itself, though I'm not sure that
shouldn't work.  Instead, the key problem may be capitalization: to
the best of my knowledge, when you reference a resource you must
capitalize the resource *type*, but not the resource name, thus I
think you should use

Nginx::Vhost["website.domain.tld"] -> Class['pkgrepo']

Nevertheless, it shouldn't just fail silently.  If you see nothing
relevant in either the master or the client's log about the
relationship not being honored, the resource not being found, or a
dependency cycle being detected, then you should file a ticket about
that.

Meanwhile, there are a couple of alternative, more conventional ways
to define your relationship.  For example, you might find this to work
more reliably:

node nodetest {
     include nginx
     # NOTE relocation:
     include pkgrepo

     nginx::vhost { 'website.domain.tld':
         port     => 80,
         docroot  => '/var/www',
         priority => 00,
         # NOTE:
         require => Class['pkgrepo']
     }
     pkgrepo::repository { "test":
         docroot     => "/var/www/website.domain.tld",
         gpgkeyid    => "C78033BD",
     }
}



John

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to