Ask Your Question
0

How to use template files from folder of child class?

asked 2016-02-23 16:52:50 -0600

Sastha gravatar image

We have a set up like this.

mainclass is the parent class:

mainclass/
    manifests/
       init.pp
       install.pp
    files/
    templates/

childclass is the inherited class:

childclass/
    manifests/
       init.pp
       install.pp
    files/
    templates/
        file1.txt.erb

In my childclass/install.pp, I have written the code to copy "file1.txt" from childclass templates folder to "/opt/appsrv" directory.

class { 'mainclass': }

file { '/opt/appsrv/file1.txt':
    ensure  => 'present',
    path    => '/opt/appsrv/file1.txt',
    content => template('file1.txt.erb'),
  }

But when above code is executed, it fails with the message "No such file or directory". When I move file1.txt.erb from childclass templates folder to mainclass templates folder, it works.

Can you please help me to resolve this issue?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-02-23 17:52:34 -0600

UBPClaw gravatar image

Your mainclass doesnt call or reference the childclass in any way. Add an include statement and that should take care of it.

edit flag offensive delete link more
0

answered 2016-02-23 18:27:56 -0600

lavaman gravatar image

You must specify the module name when referencing a template file. Try childclass/file1.txt.erb.

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

1 follower

Stats

Asked: 2016-02-23 16:52:50 -0600

Seen: 50 times

Last updated: Feb 23 '16