Ask Your Question
0

How do I fix this ordering?

asked 2013-03-04 10:57:51 -0500

illsci gravatar image

updated 2013-03-04 11:59:29 -0500

domcleal gravatar image

In my site.pp I have:

node default {

    stage {'pre': before => Stage['main']}

    case $operatingsystem {
        /(Ubuntu|Debian)/: {
            class { 'apt': stage => 'pre', }
        }
        /(RedHat|CentOS|Fedora)/: {
            class { 'yum': stage => 'pre', }
        }
    }

    $role_array = split($role_list, ',')
    include base, $role_array
    Class['base'] -> Class[$role_array]
}

In my base class I have:

class base {

    include stdlib, users, sudo, snmp, ssh, motd, timezone, selinux

    if $is_ec2 == 'true' {
        include aws
        Class['aws'] -> Class['sudo']
    }
    anchor { 'base::begin': }
    ->
    Class['stdlib']
    ->
    Class['users']
    ->
    Class['sudo']
    ->
    Class['snmp']
    ->
    Class['motd']
    ->
    Class['ssh']
    ->
    Class['timezone']
    ->
    Class['selinux']
    ->
    anchor { 'base::end': }
}

And one of the "roles" thats loaded into the role list includes nginx and ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-03-04 12:33:30 -0500

Ancillas gravatar image

updated 2013-03-04 12:39:08 -0500

I think I understand that you want Class['aws'] to run before anything else in your base class when the node is an EC2 node. It's hard to figure out all of the dependencies without seeing the code, but here's something you could try.

What you have is a role::ec2 role.

class role::default {
  case $operatingsystem {
    /(Ubuntu|Debian)/: {
      include apt
    }
    /(RedHat|CentOS|Fedora)/: {
      include yum
    }
  }
}

class role::ec2 inherits role::default {
  Class['apt'] ->
  class {'aws': } ->
  class {'stdlib': } ->
  class {'users': } ->
  class {'sudo': } ->
  class {'snmp': } ->
  class {'motd': } ->
  class {'ssh': } ->
  class {'timezone': } ->
  class {'selinux': } ->
  Class['role::ec2']
}

I don't ... (more)

edit flag offensive delete link more
0

answered 2013-03-06 02:34:09 -0500

updated 2013-03-06 02:34:48 -0500

If I'm not wrong your Class['aws'] -> Class['sudo'] line should be Anchor['base::begin'] -> Class['aws'] -> Class['sudo'] to ensure a full containment.

You could shall try to analyse the dependency graph using Omnigraffle or any other graph-analysis tool to figure out where your aws class is attached.

The problem is that the aws class itself may not be contained (and you got dependencies not firing correctly)...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-03-04 10:57:51 -0500

Seen: 80 times

Last updated: Mar 06 '13