FAQ
Hello,
I'm configuring my linux server with puppet open and is ok. My question is
the next; I've a declared in mi nodes.pp the next:

[.............]
node 'basenode' {
         include 'baseos'
         include 'motd'
         import 'useradd.pp'
}

#All nodes for my domain
node /.*\.example\.com/ inherits basenode {
}

[.............]

All nodes inherit basenode, Inside the class "baseos" i've declared the
archive host table and various other parameters

[.............]

     file { "/etc/hosts":
                         ensure => present,
                         owner => root,
                         group => root,
                         mode => '664',
                         source => "puppet:///modules/baseos/hosts",
                 }

[.............]


But I need add other node in nodes.pp and this need apply the class baseos
but without /etc/hots because this use other hosts table that I declared as
follows:

[.............]

node 'newnode.example.com' inherits basenode {
         file { "/etc/hosts":
                 ensure => "file",
                 source => "puppet:///modules/baseos/newnode/hosts",
                 mode => "644",
         }
}
[.............]

But when I go newnode and run puppet give error for duplicate "/etc/hosts"
declaration

[.............]
Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
Duplicate declaration: File[/etc/hosts] is already declared in file
/etc/puppet/modules/baseos/manifests/config.pp:21; cannot redeclare at
/etc/puppet/manifests/nodes.pp:55 on node newnode.example.com
[.............]

How I can assign different tables hosts for different nodes in this case?


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 post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Rahul Khengare at Oct 14, 2013 at 7:24 am
    Hello Mike,
         Here the baseos file[/etc/hosts] resource get propagated to all the
    nodes because of inheritance. You again changing the same file in
    "newnode.example.com" again.
    Puppet does not allow to edit the same file twice (same resource again) in
    single run.

    Work around to that,
    Create a new folders for each node in baseos module as per node name and
    put node specific "/etc/hosts" file in that folder.

    e.g
    baseos
         node1.example.com
             - hosts
         node2.example.com
             - hosts
         node3.example.com
             - hosts
         newnode.example.com
             - hosts


    All nodes inherit basenode, Inside the class "baseos" i've declared the
    archive host table and various other parameters

    [.............]

    file { "/etc/hosts":
    ensure => present,
    owner => root,
    group => root,
    mode => '664',
    # source => "puppet:///modules/baseos/hosts",
                                source =>
    "puppet:///modules/baseos/$hostname/hosts",

    Add $hostname facter as above in source parameter.
    This will add dynamic nature to source.
    Source attribute resolve to
            - puppet:///modules/baseos/node1.example.com/hosts
            - puppet:///modules/baseos/node2.example.com/hosts
            - puppet:///modules/baseos/node3.example.com/hosts
           - puppet:///modules/baseos/newnode.example.com/hosts
    depending upon the node(host) name.

    Hope this will solve your problem.

    Thanks and Regards,
    Rahul Khengare
    NTT DATA OSS Center, Pune, India.


    --
    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 post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jcbollinger at Oct 14, 2013 at 2:36 pm

    On Friday, October 11, 2013 11:24:44 AM UTC-5, mike wrote:
    Hello,
    I'm configuring my linux server with puppet open and is ok. My question is
    the next; I've a declared in mi nodes.pp the next:

    [.............]
    node 'basenode' {
    include 'baseos'
    include 'motd'
    import 'useradd.pp'
    }

    #All nodes for my domain
    node /.*\.example\.com/ inherits basenode {
    }

    [.............]

    All nodes inherit basenode, Inside the class "baseos" i've declared the
    archive host table and various other parameters

    [.............]

    file { "/etc/hosts":
    ensure => present,
    owner => root,
    group => root,
    mode => '664',
    source => "puppet:///modules/baseos/hosts",
    }

    [.............]


    But I need add other node in nodes.pp and this need apply the class
    baseos but without /etc/hots because this use other hosts table that I
    declared as follows:

    [.............]

    node 'newnode.example.com' inherits basenode {
    file { "/etc/hosts":
    ensure => "file",
    source => "puppet:///modules/baseos/newnode/hosts",
    mode => "644",
    }
    }
    [.............]

    But when I go newnode and run puppet give error for duplicate "/etc/hosts"
    declaration

    [.............]
    Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
    Duplicate declaration: File[/etc/hosts] is already declared in file
    /etc/puppet/modules/baseos/manifests/config.pp:21; cannot redeclare at
    /etc/puppet/manifests/nodes.pp:55 on node newnode.example.com
    [.............]

    How I can assign different tables hosts for different nodes in this case?
    You need to do one of these things

        - modify your baseos class so that it does not manage /etc/hosts on
        those nodes where you want to specify a different hosts file (and perhaps
        not on *any* node), or
        - modify your baseos class so that it manages /etc/hosts correctly for
        all nodes, and stop re-declaring that file in node blocks, or
        - stop assigning class baseos to those nodes for which it declares the
        wrong /etc/hosts content (relying only on node blocks or on a different
        class in those cases).

    Implicit in all of the above is this:do not assign a class to a node if you
    don't want all the resources it declares. (There is a last-ditch
    workaround for that, but it would cause you more harm than good at your
    level of Puppet experience.)

    There are multiple ways to go about those, but I hesitate to suggest
    specifics without understanding why the new node is an exception to your
    general rule.


    John

    --
    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 post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Miguel Angel Coa M. at Oct 14, 2013 at 3:28 pm
    Hello,
    I fix "the problem" with a case statement:

    [...............]
    class baseos::rhel-hosts {
                     case $fqdn {
                             'new-node.example.com': {
                                             file { "/etc/hosts":
                                                     ensure => present,
                                                     owner => root,
                                                     group => root,
                                                     mode => '664',
                                                     source =>
    "puppet:///modules/baseos/new-node/hosts",
                                             }
                             }
                             default: {
                                             file { "/etc/hosts":
                                                     ensure => present,
                                                     owner => root,
                                                     group => root,
                                                     ensure => "file",
                                                     source =>
    "puppet:///modules/baseos/hosts",
                                                     mode => "644",
                                             }
                                     }
                 }
    }
    [...............]

    Thanks.


    2013/10/14 jcbollinger <john.bollinger@stjude.org>
    On Friday, October 11, 2013 11:24:44 AM UTC-5, mike wrote:

    Hello,
    I'm configuring my linux server with puppet open and is ok. My question
    is the next; I've a declared in mi nodes.pp the next:

    [.............]
    node 'basenode' {
    include 'baseos'
    include 'motd'
    import 'useradd.pp'
    }

    #All nodes for my domain
    node /.*\.example\.com/ inherits basenode {
    }

    [.............]

    All nodes inherit basenode, Inside the class "baseos" i've declared the
    archive host table and various other parameters

    [.............]

    file { "/etc/hosts":
    ensure => present,
    owner => root,
    group => root,
    mode => '664',
    source => "puppet:///modules/baseos/**hosts",
    }

    [.............]


    But I need add other node in nodes.pp and this need apply the class
    baseos but without /etc/hots because this use other hosts table that I
    declared as follows:

    [.............]

    node 'newnode.example.com' inherits basenode {
    file { "/etc/hosts":
    ensure => "file",
    source => "puppet:///modules/baseos/**newnode/hosts",
    mode => "644",
    }
    }
    [.............]

    But when I go newnode and run puppet give error for duplicate
    "/etc/hosts" declaration

    [.............]
    Error: Could not retrieve catalog from remote server: Error 400 on
    SERVER: Duplicate declaration: File[/etc/hosts] is already declared in file
    /etc/puppet/modules/baseos/**manifests/config.pp:21; cannot redeclare at
    /etc/puppet/manifests/nodes.**pp:55 on node newnode.example.com
    [.............]

    How I can assign different tables hosts for different nodes in this case?
    You need to do one of these things

    - modify your baseos class so that it does not manage /etc/hosts on
    those nodes where you want to specify a different hosts file (and perhaps
    not on *any* node), or
    - modify your baseos class so that it manages /etc/hosts correctly for
    all nodes, and stop re-declaring that file in node blocks, or
    - stop assigning class baseos to those nodes for which it declares the
    wrong /etc/hosts content (relying only on node blocks or on a different
    class in those cases).

    Implicit in all of the above is this:do not assign a class to a node if
    you don't want all the resources it declares. (There is a last-ditch
    workaround for that, but it would cause you more harm than good at your
    level of Puppet experience.)

    There are multiple ways to go about those, but I hesitate to suggest
    specifics without understanding why the new node is an exception to your
    general rule.


    John

    --
    You received this message because you are subscribed to a topic in the
    Google Groups "Puppet Users" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/puppet-users/Yw62zu_VhhY/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to
    puppet-users+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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 post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
  • JuanBrein at Oct 15, 2013 at 12:45 pm
    Just my 2 cents... is better if you use stdlib -> concat function for
    /etc/hosts... you can have a default section for all the hosts and a
    customized one for specific cases. You avoid conflicts as well.

    Cheers
    On Monday, October 14, 2013 4:28:39 PM UTC+1, mike wrote:

    Hello,
    I fix "the problem" with a case statement:

    [...............]
    class baseos::rhel-hosts {
    case $fqdn {
    'new-node.example.com': {
    file { "/etc/hosts":
    ensure => present,
    owner => root,
    group => root,
    mode => '664',
    source =>
    "puppet:///modules/baseos/new-node/hosts",
    }
    }
    default: {
    file { "/etc/hosts":
    ensure => present,
    owner => root,
    group => root,
    ensure => "file",
    source =>
    "puppet:///modules/baseos/hosts",
    mode => "644",
    }
    }
    }
    }
    [...............]

    Thanks.


    2013/10/14 jcbollinger <John.Bo...@stjude.org <javascript:>>
    On Friday, October 11, 2013 11:24:44 AM UTC-5, mike wrote:

    Hello,
    I'm configuring my linux server with puppet open and is ok. My question
    is the next; I've a declared in mi nodes.pp the next:

    [.............]
    node 'basenode' {
    include 'baseos'
    include 'motd'
    import 'useradd.pp'
    }

    #All nodes for my domain
    node /.*\.example\.com/ inherits basenode {
    }

    [.............]

    All nodes inherit basenode, Inside the class "baseos" i've declared the
    archive host table and various other parameters

    [.............]

    file { "/etc/hosts":
    ensure => present,
    owner => root,
    group => root,
    mode => '664',
    source => "puppet:///modules/baseos/**hosts",
    }

    [.............]


    But I need add other node in nodes.pp and this need apply the class
    baseos but without /etc/hots because this use other hosts table that I
    declared as follows:

    [.............]

    node 'newnode.example.com' inherits basenode {
    file { "/etc/hosts":
    ensure => "file",
    source => "puppet:///modules/baseos/**newnode/hosts",
    mode => "644",
    }
    }
    [.............]

    But when I go newnode and run puppet give error for duplicate
    "/etc/hosts" declaration

    [.............]
    Error: Could not retrieve catalog from remote server: Error 400 on
    SERVER: Duplicate declaration: File[/etc/hosts] is already declared in file
    /etc/puppet/modules/baseos/**manifests/config.pp:21; cannot redeclare
    at /etc/puppet/manifests/nodes.**pp:55 on node newnode.example.com
    [.............]

    How I can assign different tables hosts for different nodes in this case?
    You need to do one of these things

    - modify your baseos class so that it does not manage /etc/hosts on
    those nodes where you want to specify a different hosts file (and perhaps
    not on *any* node), or
    - modify your baseos class so that it manages /etc/hosts correctly
    for all nodes, and stop re-declaring that file in node blocks, or
    - stop assigning class baseos to those nodes for which it declares
    the wrong /etc/hosts content (relying only on node blocks or on a different
    class in those cases).

    Implicit in all of the above is this:do not assign a class to a node if
    you don't want all the resources it declares. (There is a last-ditch
    workaround for that, but it would cause you more harm than good at your
    level of Puppet experience.)

    There are multiple ways to go about those, but I hesitate to suggest
    specifics without understanding why the new node is an exception to your
    general rule.


    John

    --
    You received this message because you are subscribed to a topic in the
    Google Groups "Puppet Users" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/puppet-users/Yw62zu_VhhY/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to
    puppet-users...@googlegroups.com <javascript:>.
    To post to this group, send email to puppet...@googlegroups.com<javascript:>
    .
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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 post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedOct 11, '13 at 4:24p
activeOct 15, '13 at 12:45p
posts5
users4
websitepuppetlabs.com

People

Translate

site design / logo © 2021 Grokbase