How can I define some resource in other *.pp and how to use in init.pp ?
I wrote a module to test define like this :
vsftpd
├── files
│ ├── test
│ │ ├── 1.txt
│ │ ├── 2.txt
│ │ ├── 3.txt
│ │ └── 4.txt
│ └── vsftpd.conf
├── manifests
│ ├── file.pp
│ ├── init.pp
│ ├── test.pp
│ └── user.pp
└── templates
I define 2 class and a define resource to test ,without any define resource ,It runs well ,I also can define a resource and use it in init.pp like vsftpd::createfile
but if I define vsftpd::test in another file test.pp it just can't run,errors: Could not find class ::vsftpd::test for agent.jayma.com on node agent.jayma.com even I include ::vsftpd::test first,I googled a lot ,but find nothing
file.pp
------------------
class vsftpd::file{
file{'test':
ensure => 'directory',
path => '/tmp/test/',
source => "puppet://puppet.jaymz.com/modules/vsftpd/test/",
recurse => true
}
}
------------------------
user.pp
------------------------
class vsftpd::user{
user{'ftp_jaymz':
ensure => present,
uid => '504',
home => '/home/ftp_jaymz',
shell => '/sbin/nologin',
password => '$1$svfAKdBu$c8MnfTtA.12Nny2131Vb/jhPTR3/',
gid => 'ftp',
}
}
-----------------------------------
test.pp
-----------------------------------
define vsftpd::test ($name=$title,$content){
file {'abc':
path => "/tmp/${name}_text.txt",
content => "this is a test ${content}"
}
}
--------------------------------------
init.pp
-------------------------------------
- class vsftpd { package {'vsftpd':
ensure => installed, }
service {'vsftpd':
ensure =>running,
subscribe =>File["vsftpd.conf"], }
file {'vsftpd.conf':
path => '/etc/vsftpd/vsftpd.conf',
require => Package["vsftpd"],
source => "puppet://broker.jaymz.com/modules/vsftpd/vsftpd.conf"
} include ::vsftpd::user
include ::vsftpd::file
define
vsftpd::createfile($name1=$title,$content1){
file{"/tmp/$name1.txt":
ensure => file,
content => $content1,
mode => 0644,
}
} vsftpd::createfile{'nick':
content1 => "hi nick", }
vsftpd::createfile{'jaymz':
content1 => "hi jaymz", }
include ::vsftpd::test
::vsftd::test{'jaymz_test':
content =>"hi jaymz_test", }
}
----------------------------------------------------
what file you need source from? 1.txt, 2.txt or others? If you need source from 1.txt, it should be changed
from
source => "puppet://puppet.jaymz.com/modules/vsftpd/test/",
to
source => "puppet://puppet.jaymz.com/modules/vsftpd/test/1.txt",