-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathmanifest-examples.txt
More file actions
145 lines (117 loc) · 3.54 KB
/
manifest-examples.txt
File metadata and controls
145 lines (117 loc) · 3.54 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
example 1:
## create a file
file {'/tmp/hellodevops': # resource type file and filename
ensure => present, # make sure it exists
mode => '0644', # file permissions
content => "It works on ${ipaddress_eth0}!\n", # Print the eth0 IP fact
}
=============================================================================================
example 2:
# execute 'apt-get update'
exec { 'apt-update': # exec resource named 'apt-update'
command => '/usr/bin/apt-get update' # command this resource will run
}
# install nginx package
package { 'nginx':
require => Exec['apt-update'], # require 'apt-update' before installing
ensure => installed,
}
# ensure nginx service is running
service { 'nginx':
ensure => running,
}
===============================================================================================
example 3: class definitions
class apache {
# execute 'apt-get update'
exec { 'apt-update': # exec resource named 'apt-update'
command => '/usr/bin/apt-get update' # command this resource will run
}
# install apache2 package
package { 'apache2':
require => Exec['apt-update'], # require 'apt-update' before installing
ensure => installed,
}
# ensure apache2 service is running
service { 'apache2':
ensure => running,
}
}
class{'apache':}
class linux{
$soft=['git','vim']
exec { 'apt-update':
command => '/usr/bin/apt-get update'
}
package {$soft:
require => Exec['apt-update'],
ensure => installed,
}
}
class{'linux':}
================================================================================================
example 4: class definitions
class docker {
package {'curl':
ensure => present,
}
exec {'apt-update':
command => '/usr/bin/apt-get update'
}
exec {'download_docker_key':
command => '/usr/bin/curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -'
}
exec {'add_docker_repo':
command => '/usr/bin/add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"',
require => Exec['apt-update']
}
exec {'docker_cache':
command => '/usr/bin/apt-cache policy docker-ce'
}
exec {'install_docker':
command => '/usr/bin/apt-get install -y docker-ce'
}
}
class{'docker':}
================================================================================================
example 5: node & class definitions
node 'node1ip'{
file {'/tmp/node1':
ensure => present,
mode => '0644',
content => "It works on ${ipaddress_eth0}!\n",
}
class{'node1':}
}
node 'node2ip'{
file {'/tmp/node2':
ensure => present,
mode => '0644',
content => "It works on ${ipaddress_eth0}!\n",
}
class{'node2':}
}
class node1{
exec { 'apt-update':
command => '/usr/bin/apt-get update'
}
package { 'nginx':
require => Exec['apt-update'],
ensure => installed,
}
service { 'nginx':
ensure => running,
}
}
class node2{
exec { 'apt-update':
command => '/usr/bin/apt-get update'
}
package { 'apache2':
require => Exec['apt-update'],
ensure => installed,
}
service { 'apache2':
ensure => running,
}
}