/
index.html
executable file
·500 lines (416 loc) · 14.3 KB
/
index.html
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=1024, user-scalable=no">
<title>Ansible</title>
<!-- Required stylesheet -->
<link rel="stylesheet" media="screen" href="core/deck.core.css">
<!-- Extension CSS files go here. Remove or add as needed. -->
<link rel="stylesheet" media="screen" href="extensions/goto/deck.goto.css">
<link rel="stylesheet" media="screen" href="extensions/menu/deck.menu.css">
<link rel="stylesheet" media="screen" href="extensions/navigation/deck.navigation.css">
<link rel="stylesheet" media="screen" href="extensions/status/deck.status.css">
<link rel="stylesheet" media="screen" href="extensions/scale/deck.scale.css">
<!-- Rainbow stylesheet -->
<link rel="stylesheet" media="screen" href="rainbow/sunburst.css">
<!-- Style theme. More available in /themes/style/ or create your own. -->
<link rel="stylesheet" media="screen" href="themes/style/adam12.css">
<!-- Transition theme. More available in /themes/transition/ or create your own. -->
<link rel="stylesheet" media="screen" href="themes/transition/horizontal-slide.css">
<!-- Basic black and white print styles -->
<link rel="stylesheet" media="print" href="core/print.css">
<!-- Required Modernizr file -->
<script src="modernizr.custom.js"></script>
</head>
<body>
<div class="deck-container">
<!-- Begin slides. Just make elements with a class of slide. -->
<section class="slide">
<h1>
<img src="ansible_logo.png">
</h1>
</section>
<section class="slide inverted">
<h1>What?</h1>
</section>
<section class="slide">
<h2>What is Ansible?</h2>
<ul>
<li>
Application Deployment
<ul>
<li>Fetch source from VCS</li>
<li>Install from package</li>
<li>Pull artifact from CI</li>
</ul>
</li>
<li>
Simple IT Orchestration
<ul>
<li>Rolling changes</li>
<li>Ad-hoc commands</li>
</ul>
</li>
<li>
Configuration Management
<ul>
<li>Version control of 'state'</li>
<li>Reproducable environments</li>
<li>Easily spin up test / development environments</li>
<li>No more wondering who made what change</li>
</ul>
</li>
</ul>
</section>
<section class="slide">
<h2>What makes Ansible different?</h2>
<ul>
<li>Written in Python</li>
<li>YAML config</li>
<li>Uses 'push' strategy</li>
<li>Doesn't require a remote agent to be running</li>
<li>Doesn't require a central server to 'pull' from</li>
<li>Uses 'ssh' for a transport</li>
<li>Idempotent</li>
</ul>
</section>
<section class="slide">
<h2>Getting Ansible</h2>
<h3>Linux</h3>
<pre><code data-language="shell">
|# CentOS/RPM based distro
|yum install ansible
|
|# Ubuntu via PPA
|apt-get install apt-add-repository
|apt-add-repository ppa:rquillo/ansible
|apt-get update
|apt-get install ansible
</code></pre>
<h3>Mac</h3>
<pre><code data-language="shell">
|# Homebrew
|brew install ansible
|# or via PIP (includes development deps)
|pip install ansible
</code></pre>
<h3>Windows</h3>
<p>NOPE.JPG</p>
</section>
<section class="slide">
<h2>Running of ad-hoc commands</h2>
<pre><code data-language="shell">
|# Internal PING (not actual ICMP)
|ansible -m ping all
|
|# Uptime of all your inventory
|ansible -m command -a "uptime"
</code></pre>
<h3>Be aware...</h3>
<ul>
<li>Good for evaluating the status of your inventory</li>
<li>Anything more involved should be in a Playbook</li>
</ul>
</section>
<section class="slide inverted">
<h1>Modules</h1>
</section>
<section class="slide">
<h2>What are modules?</h2>
<ul>
<li>Small programs pushed to nodes for Ansible to execute</li>
<li>Provide a structured interface for performing a specific management function</li>
<li>Can be written in any language (normally Python)</li>
<li>Cover an incredible range of operations</li>
<li>Already 237 pre-written (as of July 2014)</li>
</ul>
<h3>Calling a Module</h3>
<pre><code data-language="yaml">
|module_name: argument=value argument=value argument=value
</code></pre>
<h3>Some common tasks with module examples...</h3>
</section>
<section class="slide">
<h2>Package Management</h2>
<pre><code data-language="yaml">
|# Add the PPA
|- apt_repository: repo="ppa:chris-lea/node.js"
|
|# Install the package
|- apt: pkg=nodejs state=present
|
|# Pinned versions
|- apt: pkg=php=5.6 state=present
</code></pre>
</section>
<section class="slide">
<h2>Setup up authorized keys</h2>
<pre><code data-language="yaml">
|- authorized_key: user=deployer key="{{item}}"
| with_file:
| - keys/adam.pub
| - keys/otherUser.pub
</code></pre>
</section>
<section class="slide">
<h2>Manage files/folders</h2>
<pre><code data-language="yaml">
|- file: dest=/home/someUser/.ssh state=directory mode=0700 owner=someUser group=someGroup
|
|- copy: src="{{item}}" dest=/home/someUser/.ssh/ owner=someUser mode=0600
| with_items:
| - id_rsa
| - id_rsa.pub
</code></pre>
</section>
<section class="slide">
<h2>Manage crontab entries</h2>
<pre><code data-language="yaml">
|# Ensure a job that runs at 2 and 5 exists.
|# Creates an entry like "* 5,2 * * ls -alh > /dev/null"
|- cron: name="check dirs" hour="5,2" job="ls -alh > /dev/null"
|
|# Ensure an old job is no longer present. Removes any job that is
|# prefixed by "#Ansible: an old job" from the crontab
|- cron: name="an old job" state=absent
</code></pre>
</section>
<section class="slide">
<h2>Manage lines in files</h2>
<pre><code data-language="yaml">
|# Search and replace
|- replace: >
| dest=/etc/php5/fpm/pool.d/www.conf
| regexp='^listen = /var/run/php5-fpm.sock'
| replace='listen = 127.0.0.1:9000'
|
|# Ensure line doesn't exist in file
|- lineinfile: dest=/etc/sudoers state=absent regexp="^%wheel"
</code></pre>
</section>
<section class="slide">
<h2>Manage mySQL resources</h2>
<pre><code data-language="yaml">
|# Ensure the python dependency exists for Ansible to manage mySQL
|- apt: pkg=python-mysqldb state=present
|
|# Create our deployer user
|- mysql_user: name=deployer password=deployer state=present priv=*.*:ALL
|
|# Create our database
|- mysql_db: name=some_db state=present
</code></pre>
</section>
<section class="slide">
<h2>Manage files using Templates</h2>
<p>
Templates use the Jinga2 library, which is covered in the next section.
</p>
<pre><code data-language="yaml">
|# Upload template somefile.j2 to /home/someUser/someFile
|# Replacing variables/expressions
|- template: src=somefile.j2 dest=/home/someUser/someFile
</code></pre>
</section>
<section class="slide">
<h2>Manage Services</h2>
<pre><code data-language="yaml">
|# Service must be running
|- service: name=apache2 state=running
|
|# Restart service if running, start if not
|- service: name=ntpd state=restarted
|
|# Stop service if running
|- service: name=samba state=stopped
</code></pre>
</section>
<section class="slide inverted">
<h1>Playbooks</h1>
</section>
<section class="slide">
<h2>What are Playbooks</h2>
<ul>
<li>Written in YAML</li>
<li>Describe policy on how remote systems should be configured</li>
<li>Human readable</li>
</ul>
<blockquote>If Ansible modules are the tools in your workshop, playbooks are your design plans.</blockquote>
</section>
<section class="slide">
<h2>YAML for configuration</h2>
<pre><code data-language="yaml">
|---
|# Start your YAML file with 3 dashes to signify start
|
|# Define a value
|php_version: 5.6
|
|# Create an array
|create_users:
| - adam
| - admin
| - deployer
|
|# Multi-dimensional hash/dict/whatever name you are familiar with
|virtual_hosts:
| production:
| - web1.somehost.com
| - web2.somehost.com
| staging:
| - test.somehost.com
</code></pre>
<p>
Not covering much YAML here - check the docs!
</p>
</section>
<section class="slide">
<h2>Variables</h2>
<h3>Some variables are provided by Ansible</h3>
<pre><code data-language="yaml">
|ansible_distribution # Ubuntu
|ansible_distribution_release # precise
|ansible_distribution_version # 12.04
</code></pre>
<h3>Can be defined by the user as well</h3>
</section>
<section class="slide">
<h2>Templates</h2>
<ul>
<li>Parsed using the Python Jinga2 library</li>
<li>Normal conventions use the *.j2 file extension</li>
<li>Curly braces '{{ }}' to indicate variable interopolation</li>
<li>Pipe to filters</li>
</ul>
<pre><code data-language="generic">
|<VirtualHost *:80>
| # Expand docroot variable
| DocumentRoot {{ docroot }}
|
| # Expand serveradmin variable with default filter
| ServerAdmin {{ serveradmin | default("admin@admin.com") }}
|</VirtualHost>
</code></pre>
</section>
<section class="slide">
<h2>Roles</h2>
<ul>
<li>Used to organize playbooks</li>
<li>Grouping by roles allows easy sharing of playbooks</li>
<li>
When structured the Ansible way, facilitates automatic loading of
certain vars, tasks, and handlers
</li>
</ul>
</section>
<section class="slide">
<h2>Tasks</h2>
<ul>
<li>Are executed in order, one at a time</li>
<li>Should include a name (I've left the name off most examples thus far for brevity)</li>
<li>Will accept variables for arguments</li>
</ul>
<pre><code data-language="yaml">
|- name: Install Apache2
| apt: pkg=apache2 state=present
|
|- name: Install php5 v{{ php5_version }}
| apt: pkg=php5={{ php5_version }} state=present
</code></pre>
</section>
<section class="slide">
<h2>Handlers</h2>
<ul>
<li>Perform actions when something has "changed"</li>
<li>Commonly used to restart services</li>
<li>Run once at the end of the task list</li>
<li>Use the same modules as tasks</li>
</ul>
<pre><code data-language="yaml">
|# Task
|- apt: pkg=php5 state=present
| notify: restart Apache
|
|# Handler
|- name: restart Apache
| service: name=apache2 state=restarted
</code></pre>
</section>
<section class="slide inverted">
<h1>Demo</h1>
</section>
<section class="slide">
<h2>More Information</h2>
<ul class="more-information">
<li>
<a href="http://docs.ansible.com/" target="_new">Ansible</a>
</li>
<li>
<a href="https://devopsu.com/newsletters/ansible-weekly-newsletter.html" target="_new">Ansible Weekly</a>
</li>
<li>
<a href="http://www.yaml.org" target="_new">YAML</a>
</li>
<li>
<a href="http://www.ansible.com/tower" target="_new">Ansible Tower</a>
</li>
<li>
<a href="https://galaxy.ansible.com" target="_new">Ansible Galaxy</a>
</li>
</ul>
</section>
<section class="slide">
<h2>Thank You</h2>
<dl>
<dt>Github</dt>
<dd><a href="http://github.com/adam12">github.com/adam12</a></dd>
<dt>Twitter</dt>
<dd><a href="http://twitter.com/adamrdaniels">@adamrdaniels</a></dd>
<dt>Sourcecode</dt>
<dd><a href="http://github.com/adam12/ansible-devtricks-2014">github.com/adam12/ansible-devtricks-2014</a></dd>
</dl>
</section>
<!-- End slides. -->
<!-- Begin extension snippets. Add or remove as needed. -->
<!-- deck.navigation snippet -->
<div aria-role="navigation">
<a href="#" class="deck-prev-link" title="Previous">←</a>
<a href="#" class="deck-next-link" title="Next">→</a>
</div>
<!-- deck.status snippet -->
<p class="deck-status" aria-role="status">
<span class="deck-status-current"></span>
/
<span class="deck-status-total"></span>
</p>
<!-- deck.goto snippet -->
<form action="." method="get" class="goto-form">
<label for="goto-slide">Go to slide:</label>
<input type="text" name="slidenum" id="goto-slide" list="goto-datalist">
<datalist id="goto-datalist"></datalist>
<input type="submit" value="Go">
</form>
<!-- End extension snippets. -->
</div>
<!-- Required JS files. -->
<script src="jquery.min.js"></script>
<script src="core/deck.core.js"></script>
<!-- Extension JS files. Add or remove as needed. -->
<script src="extensions/menu/deck.menu.js"></script>
<script src="extensions/goto/deck.goto.js"></script>
<script src="extensions/status/deck.status.js"></script>
<script src="extensions/navigation/deck.navigation.js"></script>
<script src="extensions/scale/deck.scale.js"></script>
<script src="rainbow/rainbow-custom.min.js"></script>
<script src="pretty-pre.js"></script>
<!-- Initialize the deck. You can put this in an external file if desired. -->
<script>
$(function() {
prettyPre.strip("pre > code");
$.deck('.slide');
});
</script>
</body>
</html>