FAQ
Hi all,
I am writing two modules abc and xyz. In both the modules i have to
change common "test.txt" file,here i use template (.erb) file to changing
the contents.
In both abc and xyz the contents of "test.txt" file is different, if i
declare file resource for "test.txt" file in two different modules it gives
duplicate declaration of resource error.
For the correct working of modules abc and xyz, i have to change the
test.txt file twice.
How i overcome this situation ?
I am new to community, so i am not very familiar to format of query
posting,sorry about that.
Thanks in advance for answers.

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Llowder at Apr 11, 2013 at 7:00 pm

    On Thursday, April 11, 2013 1:11:16 PM UTC-5, Rahul Khengare wrote:
    Hi all,
    I am writing two modules abc and xyz. In both the modules i have to
    change common "test.txt" file,here i use template (.erb) file to changing
    the contents.
    In both abc and xyz the contents of "test.txt" file is different, if i
    declare file resource for "test.txt" file in two different modules it gives
    duplicate declaration of resource error.
    For the correct working of modules abc and xyz, i have to change the
    test.txt file twice.
    How i overcome this situation ?
    I am new to community, so i am not very familiar to format of query
    posting,sorry about that.
    Thanks in advance for answers.
    You can't do that. The only way you can have two modules edit the same
    file is if you use file_line or augeas, and even then, you need to make
    sure they don't step on each other's toes.

    You would probably be better off pulling that file either into it's own
    module or into a wrapper class that combined the chagnes both of the others
    need to make.


    --
    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?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jcbollinger at Apr 12, 2013 at 1:15 pm

    On Thursday, April 11, 2013 1:11:16 PM UTC-5, Rahul Khengare wrote:
    Hi all,
    I am writing two modules abc and xyz. In both the modules i have to
    change common "test.txt" file,here i use template (.erb) file to changing
    the contents.
    In both abc and xyz the contents of "test.txt" file is different, if i
    declare file resource for "test.txt" file in two different modules it gives
    duplicate declaration of resource error.
    For the correct working of modules abc and xyz, i have to change the
    test.txt file twice.
    How i overcome this situation ?

    You need to frame the problem correctly. A File resource represents a
    whole, specific file. What is it even supposed to mean if you specify the
    same target file's content differently in different places? Your two
    declarations cannot both be satisfied. This sort of internal inconsistency
    is one of the reasons for Puppet's prohibition against multiple
    declarations of the same resource (though that prohibition applies even
    when two or more declarations all specify exactly the same parameters).

    There are at least two different things you could reasonably mean:


    1. Most likely, you mean that you want to separately describe two or
    more different parts of the same file. In that case you are incorrect to
    model the parts as File resources, because they are not whole files. There
    are multiple ways to handle this, but a good one would be via the Concat
    module, which you can find on the module forge. It will allow you to model
    individual pieces of a file, and to specify how they are to be assembled to
    form the whole.
    2. You could mean that you want to declare separate files whose contents
    are based on the same template. In that case it is correct to use separate
    File resources, but you must be declaring them wrongly. Each one must have
    a unique title and a unique absolute filename (path property); if not
    specified explicitly, the absolute filename is the same as the title.
    There is no inherent need for the resource title or target file name to
    have any particular relationship with the template file name (though you
    will make it easier on yourself if you choose something that helps you
    associate them).


    Good luck,

    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?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rahul Khengare at Apr 16, 2013 at 3:39 pm
    thanks for reply,

    first let me again describe my problem in detail.
    I have two database server db01 and db02, on the database server (db01) i
    have to install and configure postgresql and pg_statinfo module and on
    database server(db02) i have to install and configure only postgresql.

    I created postgresql module to install and configure postgresql and
    pg_statsinfo module for pg_statsinfo.
    Here, "postgresql.conf" file contains the configuration for both postgresql
    and pg_statsinfo.(This is the common file which is to be edited, i use
    template to make changes),
    for the pg_statsinfo module i have to add the addition contents to file
    plus change some in between contents.

    I am not able to change postgresql.conf file twice in postgresql module and
    then pg_statsinfo module in case of db01, it give duplication declaration
    of file resources.
    If i change the contents of postgresql.conf file in postgresql module then
    in case of db02 the postgresql not working because some addition parameters
    of pg_statsinfo in postgresql.conf.

    i hope this help you to understand the scenario,
    how i maintain the modularity between to modules and change the same file
    twice for correct working.

    Thanks in advance.
    Rahul








    On Friday, April 12, 2013 6:45:37 PM UTC+5:30, jcbollinger wrote:


    On Thursday, April 11, 2013 1:11:16 PM UTC-5, Rahul Khengare wrote:

    Hi all,
    I am writing two modules abc and xyz. In both the modules i have to
    change common "test.txt" file,here i use template (.erb) file to changing
    the contents.
    In both abc and xyz the contents of "test.txt" file is different, if i
    declare file resource for "test.txt" file in two different modules it gives
    duplicate declaration of resource error.
    For the correct working of modules abc and xyz, i have to change the
    test.txt file twice.
    How i overcome this situation ?

    You need to frame the problem correctly. A File resource represents a
    whole, specific file. What is it even supposed to mean if you specify the
    same target file's content differently in different places? Your two
    declarations cannot both be satisfied. This sort of internal inconsistency
    is one of the reasons for Puppet's prohibition against multiple
    declarations of the same resource (though that prohibition applies even
    when two or more declarations all specify exactly the same parameters).

    There are at least two different things you could reasonably mean:


    1. Most likely, you mean that you want to separately describe two or
    more different parts of the same file. In that case you are incorrect to
    model the parts as File resources, because they are not whole files. There
    are multiple ways to handle this, but a good one would be via the Concat
    module, which you can find on the module forge. It will allow you to model
    individual pieces of a file, and to specify how they are to be assembled to
    form the whole.
    2. You could mean that you want to declare separate files whose
    contents are based on the same template. In that case it is correct to use
    separate File resources, but you must be declaring them wrongly. Each one
    must have a unique title and a unique absolute filename (path property); if
    not specified explicitly, the absolute filename is the same as the title.
    There is no inherent need for the resource title or target file name to
    have any particular relationship with the template file name (though you
    will make it easier on yourself if you choose something that helps you
    associate them).


    Good luck,

    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?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Felix Frank at Apr 17, 2013 at 11:06 am

    On 04/16/2013 05:39 PM, Rahul Khengare wrote:
    I am not able to change postgresql.conf file twice in postgresql module
    and then pg_statsinfo module in case of db01, it give duplication
    declaration of file resources.
    This is important: Puppet does not "change" your files. Puppet rewrites
    the file to have the exact content you specify in your
    manifest/template. The content must be rendered exactly once.

    You need to build a template that can serve both your use cases. See to
    it that db01 sets an appropriate variable. The template should add the
    additional content only if this variable is set.

    See http://docs.puppetlabs.com/guides/templating.html#conditionals

    HTH,
    Felix

    --
    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?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedApr 11, '13 at 6:19p
activeApr 17, '13 at 11:06a
posts5
users4
websitepuppetlabs.com

People

Translate

site design / logo © 2021 Grokbase