简体   繁体   中英

Handling Two Puppet Classes with the Same Name

I want to use the elasticsearch/elasticsearch module in my own module called rehan . The elasticsearch/elasticsearch module provides a class called elasticsearch . If I also want to create a class in my module that makes use of the one in elasticsearch/elasticsearch, how can I achieve this? I have tried:

class rehan::elasticsearch {

    class { 'elasticsearch':
        manage_repo  => true,
        repo_version => '2.2',
        require      => Class['java']
    }

    elasticsearch::instance { 'es-01':
        require => Package['elasticsearch'],
    }

}

The above code errors with:

Error: Duplicate declaration: Class[Rehan::Elasticsearch] is already declared; cannot redeclare at..

In Puppet 3 (even with the future parser!), you need to use:

class { '::elasticsearch':
    manage_repo  => true,
    repo_version => '2.2',
    require      => Class['java']
}

In Puppet 4, the resolution rules for types, classes and variables changed (it doens't try to resolve them contextually), so your code is valid.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM