On 24/08/11 11:13, Martin Alfke wrote:
On 08/24/2011 11:54 AM, Jonathan Gazeley wrote:
Hi,

Sorry if this is a basic question, but I can't find the answer in the
docs. I know about fully-qualified variables, but how can I reference a
type that is defined in a different class, so I can require/subscribe it?

In this simple example, what's the right syntax for making goodbye.txt
require hello.txt?

class class1 {
   file { "hello.txt" }
}

class class2 {
   file { "goodbye.txt":
     require =>  File['hello.txt'],
   }
}


Thanks,
Jonathan


class class1 {
    file { hello:
      path =>  'hello.txt',
    }
}

class class2 {
    file { goodbye:
      path =>  'goodbye.txt',
      require =>  File[class1::hello],
    }
}

(untested!)



Hmm, this is what I tried before mailing the list, and I still can't get it to work.

If it makes any difference, my classes are nested.

mysql::mmm::common
mysql::mmm::agent



class mysql::mmm::agent {
        include mysql::mmm::common

        package { "mysql-mmm-agent":
                ensure => installed,
        }

        file {"mmm_agent.conf":
                name => "/etc/mysql-mmm/mmm_agent.conf",
                mode => 640, owner => "root", group => "root",
content => template("/etc/puppet/modules/mysql/files/mmm_agent.conf.erb"),
                require => Package["mysql-mmm-agent"],
                notify => Service["mysql-mmm-agent"],
        }

        service {"mysql-mmm-agent":
require => [ Package['mysql-mmm-agent'], File['mmm_agent.conf', 'mmm_common.conf'], ],
                ensure => running,
                enable => true,
                hasstatus => true,
                hasrestart => true,
subscribe => File["common::mmm_common.conf", 'mmm_agent.conf'],
        }
}


class mysql::mmm::common {
        package { "mysql-mmm":
                ensure => installed,
        }

        file { "mmm_common.conf":
                name => "/etc/mysql-mmm/mmm_common.conf",
                mode => 640, owner => "root", group => "root",
                source => "puppet:///modules/mysql/mmm_common.conf",
                require => Package["mysql-mmm"],
        }
}


Using this manifest throws this error:

err: Could not run Puppet configuration client: Could not find dependency File[mysql::mmm::common::mmm-common.conf] for Service[mysql-mmm-agent] at /etc/puppet/modules/mysql/manifests/init.pp:159

Any ideas?

Thanks,
Jonathan

--
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