1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
1
、puppet服务端
Release:RHEL6.
4
HOSTNAME: puppetserver.rsyslog.org
TCP/IP:
172.16
.
200.100
/
24
Packages:
puppet-server-
2.7
.
21
-
1
.el6.noarch
mcollective-client-
2.2
.
4
activemq-
5.5
.
0
2
、puppet节点
Release: RHEL5.
8
HOSTNAME: agent1.rsyslog.org
TCP/IP:
172.16
.
200.101
/
24
Packages:
puppet-
2.7
.
21
-
1
.el5
mcollective-
2.2
.
4
-
1
.el5
3
、puppet节点
Release: RHEL6.
4
HOSTNAME: agent3.rsyslog.org
TCP/IP:
172.16
.
200.103
/
24
Packages:
puppet-
2.7
.
21
-
1
.el6
mcollective-
2.2
.
4
-
1
.el6
|
1
2
3
4
5
6
7
8
9
10
11
|
class
motd::motd {
package
{ setup:
ensure => present,
}
file{
"/etc/motd"
:
owner =>
"puppet"
,
group =>
"puppet"
,
mode =>
0700
,
source =>
"puppet://$puppetserver/modules/motd/etc/motd"
,
require => Package[
"setup"
],
}
|
1
2
3
4
5
6
7
|
[root@agent1 ~]# puppet agent --test
info: Caching catalog
for
agent1.rsyslog.org
info: Applying configuration version
'1378193573'
notice: /File[/etc/motd]/ensure: defined content
as
'{md5}0acb622c16dbdecb670d8920d96bdd30'
notice: Finished catalog run
in
0.41
seconds
[root@agent1 ~]# ll /etc/motd
-rwx------
1
puppet puppet
82
Sep
3
15
:
33
/etc/motd
|
1
2
3
4
5
6
7
8
|
class
motd::file2 {
file{
"/etc/file2"
:
owner =>
"puppet"
,
group =>
"puppet"
,
ensure => link,
target =>
"/etc/passwd"
,
}
}
|
1
2
3
4
5
6
7
|
[root@agent1 ~]# puppet agent --test
info: Caching catalog
for
agent1.rsyslog.org
info: Applying configuration version
'1378194373'
notice: /File[/etc/file2]/ensure: created
notice: Finished catalog run
in
0.07
seconds
[root@agent1 ~]# ll /etc/file2
lrwxrwxrwx
1
puppet puppet
11
Sep
3
15
:
46
/etc/file2 -> /etc/passwd
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
class
motd::dir1 {
file{
"/etc/dir1"
:
owner =>
"puppet"
,
group =>
"puppet"
,
mode =>
0700
,
ensure => directory,
recurse =>
true
,
purge =>
true
,
force =>
true
,
ignore =>
"dir2"
,
}
notify {
"This is dir1!"
:
# withpath =>
true
,
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
[root@agent1 ~]# puppet agent --test
info: Caching catalog
for
agent1.rsyslog.org
info: Applying configuration version
'1378195554'
notice: This
is
dir1!
notice: /Stage[main]/Motd::Dir1/Notify[This
is
dir1!]/message: defined
'message'
as
'This is dir1!'
notice: /File[/etc/dir1/dir3]/owner: owner changed
'root'
to
'puppet'
notice: /File[/etc/dir1/dir3]/group: group changed
'root'
to
'puppet'
notice: /File[/etc/dir1/dir3]/mode: mode changed
'0755'
to
'0700'
notice: /File[/etc/dir1/dir3]/seluser: seluser changed
'root'
to
'system_u'
notice: /File[/etc/dir1/dir3/file3]/owner: owner changed
'root'
to
'puppet'
notice: /File[/etc/dir1/dir3/file3]/group: group changed
'root'
to
'puppet'
notice: /File[/etc/dir1/dir3/file3]/mode: mode changed
'0644'
to
'0700'
notice: /File[/etc/dir1/dir3/file3]/seluser: seluser changed
'root'
to
'system_u'
notice: Finished catalog run
in
0.11
seconds
[root@agent1 ~]#
[root@agent1 ~]#
[root@agent1 ~]# ll /etc/dir1/
total
16
drwxrwxrwx
2
puppet puppet
4096
Sep
3
16
:
00
dir2
drwx------
2
puppet puppet
4096
Sep
3
16
:
06
dir3
|
1
2
3
4
5
6
7
8
9
10
11
12
|
class
motd::dir2 {
file{
"/etc/dir2"
:
owner =>
"puppet"
,
group =>
"puppet"
,
mode =>
0700
,
ensure => directory,
recurse =>
true
,
purge =>
true
,
force =>
true
,
ignore =>
"dir1"
,
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
[root@agent1 ~]# puppet agent --test
info: Retrieving plugin
info: Loading facts
in
/
var
/lib/puppet/lib/facter/my_apply2.rb
info: Loading facts
in
/
var
/lib/puppet/lib/facter/my_apply1.rb
info: Loading facts
in
/
var
/lib/puppet/lib/facter/my_apply3.rb
info: Loading facts
in
/
var
/lib/puppet/lib/facter/backup_date.rb
info: Caching catalog
for
agent1.rsyslog.org
info: Applying configuration version
'1378195951'
notice: /File[/etc/dir2]/ensure: created
notice: Finished catalog run
in
0.05
seconds
[root@agent1 ~]# mkdir /etc/dir2/dir1
[root@agent1 ~]# mkdir /etc/dir2/dir2
[root@agent1 ~]# touch /etc/dir2/dir1/file1
[root@agent1 ~]# touch /etc/dir2/dir2/file2
[root@agent1 ~]# puppet agent --test
info: Retrieving plugin
info: Loading facts
in
/
var
/lib/puppet/lib/facter/my_apply2.rb
info: Loading facts
in
/
var
/lib/puppet/lib/facter/my_apply1.rb
info: Loading facts
in
/
var
/lib/puppet/lib/facter/my_apply3.rb
info: Loading facts
in
/
var
/lib/puppet/lib/facter/backup_date.rb
info: Caching catalog
for
agent1.rsyslog.org
info: Applying configuration version
'1378195951'
info: /File[/etc/dir2/dir2]: Recursively backing up to filebucket
info: FileBucket adding {md5}d41d8cd98f00b204e9800998ecf8427e
info: /File[/etc/dir2/dir2]: Filebucketed /etc/dir2/dir2/file2 to puppet
with
sum d41d8cd98f00b204e9800998ecf8427e
notice: /File[/etc/dir2/dir2]/ensure: removed
notice: Finished catalog run
in
0.09
seconds
[root@agent1 ~]# ll /etc/dir2/
total
8
drwxr-xr-x
2
root root
4096
Sep
3
16
:
13
dir1
[root@agent1 ~]#
|