Ask Your Question
0

How to declare a defined type from a .pp (say module/init.pp) file which has been defined in a different .pp (say module/folder/abc.pp) file [closed]

asked 2014-04-17 05:24:51 -0600

Sajauddin gravatar image

updated 2014-04-17 08:25:23 -0600

ffrank gravatar image

Below is the exact folder structure and code I am using.

Folder structure and files:

root@build-server:/etc/puppet/modules/testabc# ls -lR *
manifests:
total 8
drwxr-xr-x 2 root root 4096 Apr 17 12:07 foox
-rw-r--r-- 1 root root  286 Apr 17 12:10 init.pp

manifests/foox:
total 4
-rw-r--r-- 1 root root 79 Apr 17 11:25 fooa.pp

Puppet Code:

root@build-server:/etc/puppet/modules/testabc#cat manifests/init.pp

    include testabc::foox

    file {"/tmp/abc.txt":
      source => 'puppet:///packages/abc.txt',
      owner  => 'root',
      group  => 'root',
      mode   => 0644,
      before  => Testabc::Foox::Fooa[$string],
    }

    class testabc {
      testabc ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Sajauddin
close date 2014-04-17 07:41:42.319907

2 Answers

Sort by ยป oldest newest most voted
0

answered 2014-04-17 07:12:34 -0600

doc75 gravatar image

updated 2014-04-17 07:13:00 -0600

I would advise you to follow the default naming convention of puppet. it will avoid you to include or require the stuff.

The class in manifests/foox/fooa.pp should be:

define testabs::foox::fooa(...) {
   ...
}

After that you also have other errors. Indeed you cannot declare twice the same resource: file {"/tmp/abc.txt": ... } it will fail.

You have to do something like that in the define:

File['/tmp/abc.txt'] {
   content => $string

}

You also have to remove the before as the file will have itself as before which is not possible. Also you cannot define source and content for ... (more)

edit flag offensive delete link more
0

answered 2014-04-17 07:41:06 -0600

Sajauddin gravatar image

Thanks for the reply and it worked for me.

edit flag offensive delete link more

Comments

to comments like thanks please use add a comment instead a new answer.

Renan Vicente gravatar imageRenan Vicente ( 2014-04-17 08:07:09 -0600 )edit

+1. Also I took the liberty to reword the question title so that it uses proper puppet nomenclature.

ffrank gravatar imageffrank ( 2014-04-17 08:27:37 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-04-17 05:24:51 -0600

Seen: 144 times

Last updated: Apr 17 '14