-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
415 lines (382 loc) · 14.1 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Ansible tutorial</title>
<meta name="description" content="A quick intro to Ansible CM for CSE 5914">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="reveal.js/css/reveal.css">
<link rel="stylesheet" href="reveal.js/css/theme/blood.css" id="theme">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="reveal.js/lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>What is Ansible?</h1>
<h3>Looking into Ansible</h3>
<p>
<small>By Faster than Light</small>
</p>
</section>
<!-- Overview -->
<section>
<section>
<h2> Ansible: Automation for sysadmins </h2>
<p>Ansible allows automation and configuration management for numerous hosts.</p>
</section>
<section>
<h3>In details</h3>
<p>
<small>It’s a simple automation language that can perfectly describe an IT application infrastructure in Ansible Playbooks.</small>
<small>It’s an automation engine that runs Ansible Playbooks</small>
<small>Playbooks are Ansible’s configuration, deployment, and orchestration language. They can describe a policy you want your remote systems to enforce, or a set of steps in a general IT process. At a basic level, playbooks can be used to manage configurations of and deployments to remote machines. At a more advanced level, they can sequence multi-tier rollouts involving rolling updates, and can delegate actions to other hosts, interacting with monitoring servers and load balancers along the way.</small>
</p>
</section>
</section>
<section>
<section>
<img src="architecture.png">
<h4>Ansilbe’s architecture is very straight forward</h4>
</section>
<section>
<small>Ansible works by connecting to your nodes and pushing out small programs, called "Ansible modules" to them. These programs are written to be resource models of the desired state of the system. Ansible then executes these modules (over SSH by default), and removes them when finished.</small>
<small>Your library of modules can reside on any machine, and there are no servers, daemons, or databases required. Typically you'll work with your favorite terminal program, a text editor, and probably a version control system to keep track of changes to your content.</small>
</section>
</section>
<!-- Guts of ansible -->
<section>
<h2> Tools of Ansible </h2>
<p>
Ansible is composed of some tools such as:
<ul>
<li> modules </li>
<li> playbooks </li>
<li> Roles </li>
<li> vaults </li>
<li> inventory </li>
</ul>
</p>
</section>
<section>
<section>
<h2> modules, roles, and playbooks: telling ansible what to do </h2>
<p>
Modules and playbooks are the actually code that gets run on different hosts
</p>
</section>
<section>
<h3> If Ansible modules are the tools in your workshop, playbooks are your instruction manuals, and your inventory of hosts are your raw material. </h3> <h5>-Ansible documentation</h5>
</section>
<section>
Modules allow common commands to be packaged into an easy to use tool. Modules such as <a href="https://docs.ansible.com/ansible/package_module.html"> package, </a> which allows managing installed packages across distribution package managers (e.g. apt, yum, pacman, emerge) make system administration simple.
</section>
<section>
Playbooks allow the stringing together of commands to allow automated status updates. Playbooks are the most frequent tool you'll be using in Ansible to run a series of tasks (possibly repeatedly via cron)
</section>
<section>
<h3>Running playbooks</h3>
<br/>
<pre><code class="hljs">
ansible-playbook playbook.yml
</code></pre>
</section>
<section>
<h3>Running one off commands</h3>
One off commands be run with `ansible` as seen below
<br/>
<pre><code class="hljs">
$ansible localhost -m ping
$ansible localhost -a ls
</code></pre>
</section>
<section>
<h3> Roles: DRY(Don't repeat yourself) </h3>
Roles are a useful tool to avoid writing the same task over and over with the same variables and features in different playbooks. The file structure including roles might look like:
</section>
<section>
<pre><code>
site.yml
webservers.yml
roles/
role1/
files/
templates/
tasks/
handlers/
vars/
defaults/
meta/
</code></pre>
</section>
</section>
<section>
<h2> Vaults: protecting credentials </h2>
Vaults help to keep your secrets, such as passwords, safe. Files are encrypted with AES
<br/>
<pre><code class="hljs">
ansible-vault [create|decrypt|edit|encrypt|rekey|view] vault_file.yml
</code></pre>
</section>
<section>
<h2> Inventory </h2>
Inventory files list the hosts (and possibly variables such as ports and users).
<br/>
<pre><code class="hljs">
; /etc/ansible/hosts
[my-awesome-site:children]
webservers
databases
[webservers]
main ansible_host=74.125.21.100 ;named entry
www.example.com ;simple domain name
[databases]
db.example.com
backup.example.com
</code></pre>
</section>
<!-- USE CASES-->
<section>
<section>
<h2> Use Case Example 1: Installing new software my servers</h2>
<p>
We need to install the package "nginx" on all of our servers
</p>
</section>
<section>
<p>
We can do this by running:
</p>
<pre><code>
$ansible all -s -m shell -a 'apt-get install nginx'
</code></pre>
<p>
We have just ran a task. Ansible also allows combining different tasks into a taskfile, which will itself be part of a "Role". A Role will have the taskfile and all its related files. (more on this later)
</p>
</section>
<section>
<p>
However, we could probably have done the same thing with a bash script. What sets ansible apart is the ability to ensure idempotence (same final result).
</p>
</section>
<section>
<p>
Running the code below will also install nginx on all of our servers
</p>
<pre><code>
ansible all -s -m apt -a
'pkg=nginx state=installed update_cache=true'
</code></pre>
<p>
The response will be:
</p>
<pre><code>
127.0.0.1 | success >>
{
"changed": false
}
</code></pre>
</section>
<section>
<p>
Note that this will also ensure idempotence. Note that we used the ansible module 'apt' to accomplish this. Modules are an essential part of ansible.
</p>
</section>
</section>
<section>
<section>
<h2> Use Case Example 2: Adding a database to our servers</h2>
<p>
We can write the following taskfile for our "createDB" role:
</p>
</section>
<section>
<p>Recall that the structure of a role looks like this:</p>
<img src="roleStruct.png" align="middle">
<p>When we run the role, Ansible will automatically run the "main.yml" taskfile in that role.</p>
</section>
<section>
<img src="pic.png" align="middle">
</section>
<section>
<p>To run our role, we need to create a playbook file which calls our role, running our taskfile.</p>
<p>Playbook files are in the .yml format, and can call multiple roles. Here is one which will call our "createDB" role. Assume that the following playbook file is "DBplaybook.yml"</p>
<img src="pic2.png" align="middle">
</section>
<section>
<p>We now simply run:</p>
<pre><code>ansible-playbook DBplaybook.yml</code></pre>
<p>And the database will be set up on all of our servers!</p>
</section>
<section>
<h3> Other use cases</h3>
<p>-Adding users to databases</p>
<p>-Managing services on servers</p>
<p>-Deploying applications to servers</p>
<p>-Running application scripts on servers</p>
</section>
</section>
<!-- End use cases -->
<!-- alternatives to ansible -->
<section>
<section>
<h2> Ansible: Is it right for you? </h2>
</section>
<section>
<p>
The competitors of Ansible include:
<ul>
<li> Puppet </li>
<li> Chef </li>
<li> SaltStack </li>
<li> Terraform </li>
<li> CloudFormation </li>
</ul>
</p>
</section>
<section>
<p>
Ansible users write playbooks in a descriptive language similar to YAML and Jinja. Users may prefer to use a competitor that uses a language they know, or that is coded in a more procedural style. For example, Terraform uses Go, and Puppet uses Ruby.
</p>
</section>
<section>
<p>
Ansible is often preferred because it uses client-only architecture. Many of its competitors, including Chef, SaltStack, and Puppet, use client-server architecture. However, there are two competitors, CloudFormation and Terraform, that also offer client-only architecture. Ansible is flexible and can be used either as push-based or pull-based system.
</p>
</section>
<section>
<p>
Ansible was first written for use in command line only. Unfortunately, this remains relevant, because the majority of functionality available in the command line is not available from the user interface.
</p>
</section>
<section>
<p>
Ansible is one of the newer configuration management tools, and some of its more established competitors, like Chef, offer greater stability. Chef and Puppet users will benefit from a larger user and developer communities.
</p>
</section>
<section>
<p>
Ansible nodes are managed by default over SSH. SSH communication can face reduced speed in a scaled or downsized environment. Furthermore, although Ansible uses an agentless architecture, machines must have a Python interpreter installed and require root SSH access for most functionality.
</p>
</section>
</section>
<!-- TODO: Make the three examples/tutorials below -->
<section>
<section>
<h2> Example/tutorial 1: Localhost </h2>
</section>
<section>
<h3> Dependencies </h3>
<ul>
<li> Ansible </li>
</ul>
</section>
<section>
<h3> Ad Hoc commands: Pinging the localhost </h3>
<pre><code class="hljs">
#this uses the module 'ping' on localhost
$ansible localhost -m ping
</code></pre>
</section>
<section>
<h3> Ad Hoc commands: running shell commands </h3>
<pre><code class="hljs">
#this allows a single command to be run
$ansible localhost -a 'ls -al'
</code></pre>
</section>
<section>
<h3> Making a playbook </h3>
<pre><code class="hljs">
---
# test-playbook.yml
- hosts: localhost
tasks:
- name: list homedir
shell: ls
- name: make ~/temp or update access time
shell: touch temp
- name: fail to make or update /tmp
shell: touch tmp
args:
chdir: /
</code></pre>
</section>
<section>
<h3> Running our playbook </h3>
<pre><code class="hljs">
ansible-playbook test-playbook.yml
</code></pre>
</section>
<section>
<h2> The command failed. Can you fix it </h3>
</section>
</section>
<section>
<section>
<h2> Example/tutorial 2: docker/ansible-container </h2>
</section>
<section>
<p> Ansible container allows you to configure and automate your containers in a sane manner that doesn't require bash scripts, and uses ansible playbooks. yay!</p>
</section>
<section>
<h3> Dependencies </h3>
<p>Ansible-container is not included in Ansible. You'll need to install it <a href="https://docs.ansible.com/ansible-container/installation.html#getting-ansible-container"> here </a> </p>
</section>
<section>
<h3> Basic example </h3>
<p> Make a new directory and cd into it then run: </p>
<pre><code>
$ansible-container init
$ansible-container build
$ansible-container run
</code></pre>
</section>
</section>
<section>
<section>
<h2> Example/tutorial 3: vagrant </h2>
<a href="https://github.com/geerlingguy/ansible-vagrant-examples">Shamelessly stolen from geerlingguy</a>
</section>
</section>
</div>
</div>
<script src="reveal.js/lib/js/head.min.js"></script>
<script src="reveal.js/js/reveal.js"></script>
<script>
// Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{ src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'reveal.js/plugin/zoom-js/zoom.js', async: true },
{ src: 'reveal.js/plugin/notes/notes.js', async: true }
]
});
</script>
</body>
</html>