forked from telmerobert/DocRepository
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPupetcode.txt
More file actions
192 lines (117 loc) · 3.2 KB
/
Copy pathPupetcode.txt
File metadata and controls
192 lines (117 loc) · 3.2 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
Step by step puppet code and execution
---------------------------------------
Yum install puppet
yum install puppet-3.6.1
cd /etc/puppet
if it is enterprise puppet version
cd /etc/puppetlabs/puppet
depending version you will site.pp
cd /etc/puppet/manifests/site.pp
Manifests:
what is manifests?
Manifests contains resources and relationships
Resource?
All commands,services and configuration in linux operating system.
Resource syntax:
resource_type { "name":
attribute => value
}
example:
file { "/etc/test.txt":
content => " this is test file",
owner => root,
mode => 755,
}
Relations ships:
Puppet chaining using -> symbol
and metaparameters like require,before,subscribe and notify
Puppet class:
Puppet class is allow us to write re-usable code.
Simple manifest file:
java.pp
-------
node default {
include ::java( this java folder should be in the /etc/puppet/module)
}
using our owns resources:
java.pp
------
node default {
exec { "installing_java":
command => "yum install java-1.8.0-openjdk-devel",
path => "/usr/bin:/usr/local/bin:/bin",
}
}
Puppet does not maintain the order if we write more than one resources
we will write puppet chaining using ->
example:
This file should be in /etc/puppet/manifests/jenkins.pp
jenkins.pp
----------
node default {
exec { "wgetjenkins":
command => "wget jenkins.repo",
path => "/usr/bin:/usr/local/bin:/bin",
}
exec { "rpmimportkey":
command => "rpt keyname"<
path => "/usr/bin:/usr/local/bin:bin",
}
exec { "yuminstalljenkins":
command => "yum install jenkins",
path => "/usr/bin:/usr/local/bin:/bin",
}
}
command to run the puppet:
pupet apply -v /etc/puppet/manifests/jenkins.pp
In this case, puppet may execute any resource if it executes "yuminstalljenkins" first puppet
installation will be failed because it does not have rpm and tarball"
so we will give puppet chaining here to maintain the order of execution.
jenkins.pp
----------
node default {
exec { "wgetjenkins":
command => "wget jenkins.repo",
path => "/usr/bin:/usr/local/bin:/bin",
} ->
exec { "rpmimportkey":
command => "rpt keyname"<
path => "/usr/bin:/usr/local/bin:bin",
} ->
exec { "yuminstalljenkins":
command => "yum install jenkins",
path => "/usr/bin:/usr/local/bin:/bin",
}
}
if resources are more and to maintain dependency we will use metaparameters
require
node default {
exec { "yuminstalljenkins":
command => "yum install jenkins",
path => "/usr/bin:/usr/local/bin:/bin",
require => Exec["rpmimportkey"],
}
exec { "wgetjenkins":
command => "wget jenkins.repo",
path => "/usr/bin:/usr/local/bin:/bin",
}
exec { "rpmimportkey":
command => "rpt keyname",
path => "/usr/bin:/usr/local/bin:bin",
require => Exec["wgetjenkins"]
}
}
To validate the puppet files:
puppet parser validate puppetppfiles
Hiera.yaml
Hiera.yaml file is for loop up the data with in the puppet directories.
Hiera.yaml should be in /etc/puppet path
Hiera.yaml
---------
---
:backends:
- yaml
:yaml:
:datadir: "/etc/puppet/hieradata" "this directory has role yaml files"
:hierarchy:
- scm