-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathREADME.html
1454 lines (1237 loc) · 43 KB
/
README.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
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2016-02-07 Sun 21:51 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title></title>
<meta name="generator" content="Org-mode" />
<meta name="author" content="Joakim Verona" />
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
pre.src-sh:before { content: 'sh'; }
pre.src-bash:before { content: 'sh'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-R:before { content: 'R'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-java:before { content: 'Java'; }
pre.src-sql:before { content: 'SQL'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
/*]]>*/-->
</style>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2013 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
</head>
<body>
<div id="content">
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#orgheadline42">1. Code samples for the Practical Devops book</a>
<ul>
<li><a href="#orgheadline3">1.1. ch3 How Architecture affects DevOps</a>
<ul>
<li><a href="#orgheadline1">1.1.1. Liquibase hello-world</a></li>
<li><a href="#orgheadline2">1.1.2. Manual installation</a></li>
</ul>
</li>
<li><a href="#orgheadline8">1.2. ch4 Everything is code</a>
<ul>
<li><a href="#orgheadline4">1.2.1. Docker intermission</a></li>
<li><a href="#orgheadline5">1.2.2. setting up a basic git server</a></li>
<li><a href="#orgheadline6">1.2.3. Gerrit</a></li>
<li><a href="#orgheadline7">1.2.4. Gitlab</a></li>
</ul>
</li>
<li><a href="#orgheadline11">1.3. ch5 Build the code</a>
<ul>
<li><a href="#orgheadline9">1.3.1. Cheating with FPM</a></li>
<li><a href="#orgheadline10">1.3.2. Build servers, Jenkins in particular</a></li>
</ul>
</li>
<li><a href="#orgheadline20">1.4. ch6 Test the code</a>
<ul>
<li><a href="#orgheadline12">1.4.1. A Junit example</a></li>
<li><a href="#orgheadline13">1.4.2. Arquilian</a></li>
<li><a href="#orgheadline14">1.4.3. Automated acceptance testing</a></li>
<li><a href="#orgheadline19">1.4.4. A complete test automation scenario</a></li>
</ul>
</li>
<li><a href="#orgheadline27">1.5. ch7 Deploying the code</a>
<ul>
<li><a href="#orgheadline21">1.5.1. Executing code on the client</a></li>
<li><a href="#orgheadline22">1.5.2. Puppet master, Puppet agent</a></li>
<li><a href="#orgheadline23">1.5.3. Ansible</a></li>
<li><a href="#orgheadline24">1.5.4. Deploying with Chef</a></li>
<li><a href="#orgheadline25">1.5.5. Deploying with Saltstack</a></li>
<li><a href="#orgheadline26">1.5.6. Vagrant</a></li>
</ul>
</li>
<li><a href="#orgheadline33">1.6. ch8 Monitoring the code</a>
<ul>
<li><a href="#orgheadline28">1.6.1. Nagios</a></li>
<li><a href="#orgheadline29">1.6.2. Munin</a></li>
<li><a href="#orgheadline30">1.6.3. Ganglia</a></li>
<li><a href="#orgheadline31">1.6.4. Graphite</a></li>
<li><a href="#orgheadline32">1.6.5. Log handling</a></li>
</ul>
</li>
<li><a href="#orgheadline39">1.7. ch9 Issue Tracking</a>
<ul>
<li><a href="#orgheadline34">1.7.1. Bugzilla</a></li>
<li><a href="#orgheadline35">1.7.2. Trac</a></li>
<li><a href="#orgheadline36">1.7.3. Redmine</a></li>
<li><a href="#orgheadline37">1.7.4. The Gitlab issue tracker</a></li>
<li><a href="#orgheadline38">1.7.5. Jira</a></li>
</ul>
</li>
<li><a href="#orgheadline41">1.8. ch10 The Internet of Things and DevOps</a>
<ul>
<li><a href="#orgheadline40">1.8.1. NodeMCU</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-orgheadline42" class="outline-2">
<h2 id="orgheadline42"><span class="section-number-2">1</span> Code samples for the Practical Devops book</h2>
<div class="outline-text-2" id="text-1">
<p>
These are the code samples for the book "Practical Devops" by Joakim
Verona published by Packt Publishing.
</p>
<p>
The books home page:
<a href="https://www.packtpub.com/networking-and-servers/practical-devops">https://www.packtpub.com/networking-and-servers/practical-devops</a>
</p>
<p>
In most cases you will need the book to make the most out of the exercises.
</p>
<p>
Please ensure that you have the latest version of these exercises
before continuing.
</p>
<p>
To get the code samples from Github do:
</p>
<div class="org-src-container">
<pre class="src src-shell">git clone https://github.com/jave/practicaldevops.git
</pre>
</div>
<p>
And to keep the samples updated,
</p>
<div class="org-src-container">
<pre class="src src-shell"><span style="color: #96a5d9; font-style: italic;">cd</span> practicaldevops
git pull https://github.com/jave/practicaldevops.git
</pre>
</div>
</div>
<div id="outline-container-orgheadline3" class="outline-3">
<h3 id="orgheadline3"><span class="section-number-3">1.1</span> ch3 How Architecture affects DevOps</h3>
<div class="outline-text-3" id="text-1-1">
</div><div id="outline-container-orgheadline1" class="outline-4">
<h4 id="orgheadline1"><span class="section-number-4">1.1.1</span> Liquibase hello-world</h4>
<div class="outline-text-4" id="text-1-1-1">
<div class="org-src-container">
<pre class="src src-shell-script"><span style="color: #96a5d9; font-style: italic;">cd</span> ch3/liquibase-helloworld
mvn liquibase:update
</pre>
</div>
</div>
</div>
<div id="outline-container-orgheadline2" class="outline-4">
<h4 id="orgheadline2"><span class="section-number-4">1.1.2</span> Manual installation</h4>
<div class="outline-text-4" id="text-1-1-2">
<div class="org-src-container">
<pre class="src src-sh">dnf install postgresql
dnf install nginx
<span style="color: #96a5d9; font-style: italic;">cd</span> ch3/crm1
lein build
lein run
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgheadline8" class="outline-3">
<h3 id="orgheadline8"><span class="section-number-3">1.2</span> ch4 Everything is code</h3>
<div class="outline-text-3" id="text-1-2">
</div><div id="outline-container-orgheadline4" class="outline-4">
<h4 id="orgheadline4"><span class="section-number-4">1.2.1</span> Docker intermission</h4>
<div class="outline-text-4" id="text-1-2-1">
<p>
These instructions are for Fedora, but they are similar for other
distributions such as Ubuntu.
</p>
<p>
To make sure Docker is working properly,
see the following documentation for Fedora.
</p>
<p>
<a href="https://docs.docker.com/v1.5/installation/fedora/">https://docs.docker.com/v1.5/installation/fedora/</a>
</p>
<ul class="org-ul">
<li>For fedora 21 and later do:</li>
</ul>
<div class="org-src-container">
<pre class="src src-sh">dnf -y install docker
</pre>
</div>
<ul class="org-ul">
<li>docker-io was renamed to docker from Fedora 21, so use "docker-io" on older red hat
derivates, "docker" on newer</li>
<li>Use a sudo capable user to run docker commands, or the root user</li>
<li>You can also add a docker group with rights to use the docker socket
needed to communicate with the docker daemon.</li>
</ul>
<p>
This approach is described here
<a href="https://docs.docker.com/v1.5/installation/fedora/">https://docs.docker.com/v1.5/installation/fedora/</a>
</p>
<p>
In summary:
</p>
<div class="org-src-container">
<pre class="src src-sh">$ sudo groupadd docker
$ sudo chown root:docker /var/run/docker.sock
$ sudo usermod -a -G docker $<span style="color: #ff694d;">USERNAME</span>
</pre>
</div>
<ul class="org-ul">
<li>You might need "setenforce 0" to start docker. The comand will
disable selinux, which has security implications. Use this only on a
test machine.</li>
<li>To start and enable docker on reboot:</li>
</ul>
<div class="org-src-container">
<pre class="src src-sh">sudo systemctl start docker
sudo systemctl enable docker
</pre>
</div>
<p>
To verify that docker works:
</p>
<div class="org-src-container">
<pre class="src src-sh">sudo docker run -i -t fedora /bin/bash
</pre>
</div>
<p>
For some exercises you need to have docker-compose installed first.
</p>
<p>
On Fedora 23 you can do:
</p>
<div class="org-src-container">
<pre class="src src-sh">dnf install docker-compose
</pre>
</div>
<p>
In earlier versions you needed to download docker-compose manually.
</p>
</div>
</div>
<div id="outline-container-orgheadline5" class="outline-4">
<h4 id="orgheadline5"><span class="section-number-4">1.2.2</span> setting up a basic git server</h4>
<div class="outline-text-4" id="text-1-2-2">
<p>
bare repo:
</p>
<div class="org-src-container">
<pre class="src src-sh"><span style="color: #96a5d9; font-style: italic;">cd</span> /opt/git
mkdir project.git
<span style="color: #96a5d9; font-style: italic;">cd</span> project.git
git init --bare
</pre>
</div>
<ul class="org-ul">
<li>Now try cloning, making changes, and pushing to the server</li>
</ul>
</div>
</div>
<div id="outline-container-orgheadline6" class="outline-4">
<h4 id="orgheadline6"><span class="section-number-4">1.2.3</span> Gerrit</h4>
<div class="outline-text-4" id="text-1-2-3">
<p>
Run a Gerrit container:
</p>
<div class="org-src-container">
<pre class="src src-sh">docker run -d -p 8080:8080 -p 29418:29418 openfrontier/gerrit
</pre>
</div>
<p>
On the host machine you can now install the supporting git-review
package:
</p>
<div class="org-src-container">
<pre class="src src-sh">sudo dnf install git-review
</pre>
</div>
<p>
Rebase your commits on top of the commits in the remote repository:
</p>
<div class="org-src-container">
<pre class="src src-sh">git pull --rebase origin master
</pre>
</div>
<p>
Interactively edit the history, possibly squashing commits together to
make a more readable history:
</p>
<div class="org-src-container">
<pre class="src src-sh">git rebase -i origin/master
</pre>
</div>
</div>
</div>
<div id="outline-container-orgheadline7" class="outline-4">
<h4 id="orgheadline7"><span class="section-number-4">1.2.4</span> Gitlab</h4>
<div class="outline-text-4" id="text-1-2-4">
<p>
Now create a directory for gitlab, and fetch the compose file:
</p>
<div class="org-src-container">
<pre class="src src-sh">mkdir gitlab
<span style="color: #96a5d9; font-style: italic;">cd</span> gitlab
wget https://raw.githubusercontent.com/sameersbn/docker-gitlab/master/docker-compose.yml
</pre>
</div>
<p>
Now start the gitlab stack.
</p>
<div class="org-src-container">
<pre class="src src-sh">docker-compose up
</pre>
</div>
<p>
When the containers are up and running, access the web ui:
</p>
<p>
<a href="http://loaclhost:10080">http://loaclhost:10080</a>
</p>
<p>
and enter the following credentials:
</p>
<ul class="org-ul">
<li>username: root</li>
<li>password: 5iveL!fe</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-orgheadline11" class="outline-3">
<h3 id="orgheadline11"><span class="section-number-3">1.3</span> ch5 Build the code</h3>
<div class="outline-text-3" id="text-1-3">
<p>
Create a "freestyle" class job in Jenkins that runs the "fortune"
command.
</p>
<p>
First install Jenkins.
</p>
<div class="org-src-container">
<pre class="src src-sh">dnf install jenkins
</pre>
</div>
<p>
Then follow the instruction in the book to configure the job.
</p>
</div>
<div id="outline-container-orgheadline9" class="outline-4">
<h4 id="orgheadline9"><span class="section-number-4">1.3.1</span> Cheating with FPM</h4>
<div class="outline-text-4" id="text-1-3-1">
<p>
To install fpm:
</p>
<div class="org-src-container">
<pre class="src src-sh">yum install rubygems
yum install ruby
yum install ruby-devel
gem install fpm
</pre>
</div>
<p>
Package this shell script:
</p>
<div class="org-src-container">
<pre class="src src-sh"><span style="color: #2872b2;">#</span><span style="color: #2872b2;">!/bin/</span><span style="color: #96a5d9; font-weight: bold;">sh</span>
<span style="color: #96a5d9; font-style: italic;">echo</span> <span style="color: #68f6cb;">'Hello World!'</span>
chmod a+x usr/local/bin/hello.sh
fpm -s dir -t rpm -n hello-world -v 1 -C installdir usr
rpm -qivp hello-world.rpm
rpm -ivh hello-world.rpm
</pre>
</div>
</div>
</div>
<div id="outline-container-orgheadline10" class="outline-4">
<h4 id="orgheadline10"><span class="section-number-4">1.3.2</span> Build servers, Jenkins in particular</h4>
<div class="outline-text-4" id="text-1-3-2">
<div class="org-src-container">
<pre class="src src-shell">dnf install jenkins
</pre>
</div>
<div class="org-src-container">
<pre class="src src-shell">systemctl start jenkins
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgheadline20" class="outline-3">
<h3 id="orgheadline20"><span class="section-number-3">1.4</span> ch6 Test the code</h3>
<div class="outline-text-3" id="text-1-4">
</div><div id="outline-container-orgheadline12" class="outline-4">
<h4 id="orgheadline12"><span class="section-number-4">1.4.1</span> A Junit example</h4>
<div class="outline-text-4" id="text-1-4-1">
<div class="org-src-container">
<pre class="src src-shell"><span style="color: #96a5d9; font-style: italic;">cd</span> ch6/hello-junit
mvn install
</pre>
</div>
</div>
</div>
<div id="outline-container-orgheadline13" class="outline-4">
<h4 id="orgheadline13"><span class="section-number-4">1.4.2</span> Arquilian</h4>
<div class="outline-text-4" id="text-1-4-2">
<p>
There is an arquillian hello-world in the Arquillian documentation.
</p>
<div class="org-src-container">
<pre class="src src-java">git <span style="color: #f5b55f;">clone</span> <span style="color: #ff694d;">https</span>:<span style="color: #2872b2;">//</span><span style="color: #2872b2;">github.com/aslakknutsen/arquillian-example-helloworld.git</span>
cd arquillian-example-helloworld
mvn install
</pre>
</div>
</div>
</div>
<div id="outline-container-orgheadline14" class="outline-4">
<h4 id="orgheadline14"><span class="section-number-4">1.4.3</span> Automated acceptance testing</h4>
<div class="outline-text-4" id="text-1-4-3">
<p>
There are two implementations, one with annotations, and one with
Lambda notation.
</p>
<p>
While the lambda notation is easier to read than the annotation
syntax, cucumbers lambda notation is fairly new and can be problematic
to get to work depending on your Java implementation.
</p>
<p>
To run the annotation based example:
</p>
<div class="org-src-container">
<pre class="src src-java"><span style="color: #f5b55f;">cd</span> <span style="color: #ff694d;">ch6</span>/hello-cucumber6
mvn clean test
</pre>
</div>
<p>
To run the lambda based example:
</p>
<div class="org-src-container">
<pre class="src src-java"><span style="color: #f5b55f;">cd</span> <span style="color: #ff694d;">ch6</span>/hello-cucumber8
mvn clean test
</pre>
</div>
</div>
</div>
<div id="outline-container-orgheadline19" class="outline-4">
<h4 id="orgheadline19"><span class="section-number-4">1.4.4</span> A complete test automation scenario</h4>
<div class="outline-text-4" id="text-1-4-4">
</div><ol class="org-ol"><li><a id="orgheadline15"></a>hello-selenium-world<br /><div class="outline-text-5" id="text-1-4-4-1">
<p>
Hello selenium world is a minimal selenium example that should
open a firefox browser window and ask google 'hello world'.
You should see a list of search matches for 'hello world'.
</p>
<p>
It is useful to check that this example runs before testing other examples.
To run it:
</p>
<div class="org-src-container">
<pre class="src src-sh"><span style="color: #96a5d9; font-style: italic;">cd</span> ch6/hello-selenium
mvn test
</pre>
</div>
</div></li>
<li><a id="orgheadline16"></a>Running the usermanager example manually<br /><div class="outline-text-5" id="text-1-4-4-2">
<p>
You will need Leiningen, <a href="http://leiningen.org/">http://leiningen.org/</a>
<a href="https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein">https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein</a>
</p>
<div class="org-src-container">
<pre class="src src-sh">ch6/usermanager
lein run
</pre>
</div>
</div></li>
<li><a id="orgheadline17"></a>Running the automated test<br /><div class="outline-text-5" id="text-1-4-4-3">
<div class="org-src-container">
<pre class="src src-sh">autotest_v1/bin/autotest.sh
</pre>
</div>
</div></li>
<li><a id="orgheadline18"></a>Handling the tricky dependencies with Docker<br /><div class="outline-text-5" id="text-1-4-4-4">
<div class="org-src-container">
<pre class="src src-sh">docker run -d -p 4444:4444 --name selenium-hub selenium/hub
docker run -d --link selenium-hub:hub selenium/node-firefox
</pre>
</div>
</div></li></ol>
</div>
</div>
<div id="outline-container-orgheadline27" class="outline-3">
<h3 id="orgheadline27"><span class="section-number-3">1.5</span> ch7 Deploying the code</h3>
<div class="outline-text-3" id="text-1-5">
</div><div id="outline-container-orgheadline21" class="outline-4">
<h4 id="orgheadline21"><span class="section-number-4">1.5.1</span> Executing code on the client</h4>
<div class="outline-text-4" id="text-1-5-1">
<div class="org-src-container">
<pre class="src src-sh">salt -E <span style="color: #68f6cb;">'.*'</span> cmd.run <span style="color: #68f6cb;">'ls -l'</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgheadline22" class="outline-4">
<h4 id="orgheadline22"><span class="section-number-4">1.5.2</span> Puppet master, Puppet agent</h4>
<div class="outline-text-4" id="text-1-5-2">
<p>
rfkrocktk/puppet is a convenient docker image for exploring puppet.
</p>
<ul class="org-ul">
<li><a href="https://hub.docker.com/r/rfkrocktk/puppet/">https://hub.docker.com/r/rfkrocktk/puppet/</a> this is the agent</li>
<li><a href="https://hub.docker.com/r/rfkrocktk/puppetmaster/">https://hub.docker.com/r/rfkrocktk/puppetmaster/</a> this is the master</li>
</ul>
<div class="org-src-container">
<pre class="src src-sh">docker --name dockerduck --hostname dockerduck -e <span style="color: #ff694d;">PUPPETMASTER_TCP_HOST</span>=ultramaster.example.com <span style="color: #68f6cb;">\</span>
-v /var/lib/docker/dockercontainer/puppet/ssl:/var/lib/puppet/ssl rfkrocktk/puppet
</pre>
</div>
</div>
</div>
<div id="outline-container-orgheadline23" class="outline-4">
<h4 id="orgheadline23"><span class="section-number-4">1.5.3</span> Ansible</h4>
<div class="outline-text-4" id="text-1-5-3">
<div class="org-src-container">
<pre class="src src-Dockerfile">FROM williamyeh/ansible:centos7
</pre>
</div>
<div class="org-src-container">
<pre class="src src-sh">docker run -v <span style="color: #fa8072;">`pwd`</span>/ansible:/ansible -it <hash> bash
<span style="color: #96a5d9; font-style: italic;">cd</span> /ansible
ansible-playbook -i inventory playbook.yml --connection=local --sudo
</pre>
</div>
<p>
A docker container which supports systemd:
</p>
<div class="org-src-container">
<pre class="src src-dockerfile"><span style="color: #96a5d9; font-weight: bold;">FROM</span> fedora
<span style="color: #96a5d9; font-weight: bold;">RUN</span> yum -y update; yum clean all
<span style="color: #96a5d9; font-weight: bold;">RUN</span> yum install ansible sudo
<span style="color: #96a5d9; font-weight: bold;">RUN</span> systemctl mask systemd-remount-fs.service dev-hugepages.mount <span style="color: #68f6cb;">\</span>
sys-fs-fuse-connections.mount <span style="color: #68f6cb;">\</span>
systemd-logind.service getty.target console-getty.service
<span style="color: #96a5d9; font-weight: bold;">RUN</span> cp /usr/lib/systemd/system/dbus.service /etc/systemd/system/;<span style="color: #68f6cb;">\</span>
sed -i <span style="color: #68f6cb;">'s/OOMScoreAdjust=-900//'</span> /etc/systemd/system/dbus.service
<span style="color: #96a5d9; font-weight: bold;">VOLUME</span> [<span style="color: #68f6cb;">"/sys/fs/cgroup"</span>, <span style="color: #68f6cb;">"/run"</span>, <span style="color: #68f6cb;">"/tmp"</span>]
<span style="color: #96a5d9; font-weight: bold;">ENV</span> <span style="color: #ff694d;">container</span>=docker
<span style="color: #96a5d9; font-weight: bold;">CMD</span> [<span style="color: #68f6cb;">"/usr/sbin/init"</span>]
</pre>
</div>
<p>
To run the new container:
</p>
<div class="org-src-container">
<pre class="src src-shell-script">docker run -it --rm -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v <span style="color: #fa8072;">`pwd`</span>/ansible:/ansible <hash>
</pre>
</div>
<p>
Connect to the container:
</p>
<div class="org-src-container">
<pre class="src src-shell-script">docker exec -it <hash> bash
</pre>
</div>
<p>
A slightly more advanced exercise:
</p>
<div class="org-src-container">
<pre class="src src-yaml"><span style="color: #2872b2;">---</span>
- <span style="color: #ff694d;">hosts</span>: localhost
<span style="color: #ff694d;">vars</span>:
<span style="color: #ff694d;">http_port</span>: 80
<span style="color: #ff694d;">max_clients</span>: 200
<span style="color: #ff694d;">remote_user</span>: root
<span style="color: #ff694d;">tasks</span>:
- <span style="color: #ff694d;">name</span>: ensure apache is at the latest version
<span style="color: #ff694d;">yum</span>: name=httpd state=latest
- <span style="color: #ff694d;">name</span>: write the apache config file
<span style="color: #ff694d;">template</span>: src=/srv/httpd.j2 dest=/etc/httpd.conf
<span style="color: #ff694d;">notify</span>:
- restart apache
- <span style="color: #ff694d;">name</span>: ensure apache is running (and enable it at boot)
<span style="color: #ff694d;">service</span>: name=httpd state=started enabled=yes
<span style="color: #ff694d;">handlers</span>:
- <span style="color: #ff694d;">name</span>: restart apache
<span style="color: #ff694d;">service</span>: name=httpd state=restarted
</pre>
</div>
</div>
</div>
<div id="outline-container-orgheadline24" class="outline-4">
<h4 id="orgheadline24"><span class="section-number-4">1.5.4</span> Deploying with Chef</h4>
<div class="outline-text-4" id="text-1-5-4">
<p>
Start a clean container for the exercise:
</p>
<div class="org-src-container">
<pre class="src src-sh">docker run -it ubuntu bash
</pre>
</div>
<p>
Install Chef in the container:
</p>
<div class="org-src-container">
<pre class="src src-sh">curl -L https://www.opscode.com/chef/install.sh | bash
</pre>
</div>
<p>
Verify the chef-solo was installed:
</p>
<div class="org-src-container">
<pre class="src src-shell-script">chef-solo -v
</pre>
</div>
<p>
Fetch and unpack a pre-rolled chef configuration:
</p>
<div class="org-src-container">
<pre class="src src-shell-script">curl -L http://github.com/opscode/chef-repo/tarball/master -o master.tgz
tar -zxf master.tgz
mv chef-repo* chef-repo
rm master.tgz
</pre>
</div>
<p>
Create a configuration file for chef:
</p>
<div class="org-src-container">
<pre class="src src-shell-script">mkdir .chef
<span style="color: #96a5d9; font-style: italic;">echo</span> <span style="color: #68f6cb;">"cookbook_path [ '/root/chef-repo/cookbooks' ]"</span> > .chef/knife.rb
</pre>
</div>
<p>
Now create a template:
</p>
<div class="org-src-container">
<pre class="src src-shell-script">knife cookbook create phpapp
</pre>
</div>
</div>
</div>
<div id="outline-container-orgheadline25" class="outline-4">
<h4 id="orgheadline25"><span class="section-number-4">1.5.5</span> Deploying with Saltstack</h4>
<div class="outline-text-4" id="text-1-5-5">
<p>
Start a Saltstack container:
</p>
<div class="org-src-container">
<pre class="src src-sh">docker run -i -t --name=saltdocker_master_1 -h master -p 4505 -p 4506 <span style="color: #68f6cb;">\</span>
-p 8080 -p 8081 -e <span style="color: #ff694d;">SALT_NAME</span>=master -e <span style="color: #ff694d;">SALT_USE</span>=master <span style="color: #68f6cb;">\</span>
-v <span style="color: #fa8072;">`pwd`</span>/srv/salt:/srv/salt:rw jacksoncage/salt
</pre>
</div>
<p>
Start a shell inside the Saltstack container:
</p>
<div class="org-src-container">
<pre class="src src-shell-script">docker exec -i -t saltdocker_master_1 bash
</pre>
</div>
<p>
Salt state to install httpd:
</p>
<div class="org-src-container">
<pre class="src src-yaml"><span style="color: #ff694d;">top.sls</span>:
<span style="color: #ff694d;">base</span>:
<span style="color: #68f6cb;">'*'</span>:
- webserver
<span style="color: #ff694d;">webserver.sls</span>:
<span style="color: #ff694d;">apache2</span>: <span style="color: #2872b2;"># </span><span style="color: #2872b2;">ID declaration</span>
<span style="color: #ff694d;">pkg</span>: <span style="color: #2872b2;"># </span><span style="color: #2872b2;">state declaration</span>
- installed <span style="color: #2872b2;"># </span><span style="color: #2872b2;">function declaration</span>
</pre>
</div>
<p>
Run this command to ensure the desired state:
</p>
<div class="org-src-container">
<pre class="src src-shell-script">salt-call --local state.highstate -l debug
</pre>
</div>
</div>
</div>
<div id="outline-container-orgheadline26" class="outline-4">
<h4 id="orgheadline26"><span class="section-number-4">1.5.6</span> Vagrant</h4>
<div class="outline-text-4" id="text-1-5-6">
<div class="org-src-container">
<pre class="src src-sh">yum install <span style="color: #68f6cb;">'vagrant*'</span>
</pre>
</div>
<p>
To use Vagrants Virtualbox driver, you need to set up Virtualbox
according to your distribution.
</p>
<p>
Create a virtual machine with Vagrant from a recipy:
</p>
<div class="org-src-container">
<pre class="src src-shell-script">vagrant init hashicorp/precise32
</pre>
</div>
<p>
Try starting the machine:
</p>
<div class="org-src-container">
<pre class="src src-shell-script">vagrant up
</pre>
</div>
<p>
You can now ssh to the machine:
</p>
<div class="org-src-container">
<pre class="src src-shell-script">vagrant ssh
</pre>
</div>
<p>
Add this to the Vagrant file:
</p>
<div class="org-src-container">
<pre class="src src-shell-script"><span style="color: #bad6e2;">Vagrant.configure</span>(<span style="color: #68f6cb;">"2"</span>) <span style="color: #96a5d9; font-weight: bold;">do</span> |config|
config.vm.box = <span style="color: #68f6cb;">"hashicorp/precise32"</span>
config.vm.provision :shell, path: <span style="color: #68f6cb;">"bootstrap.sh"</span>
end
</pre>
</div>
<p>
And create a bootstrap.sh file that will install Apache httpd:
</p>
<div class="org-src-container">
<pre class="src src-shell-script"><span style="color: #2872b2;">#</span><span style="color: #2872b2;">!/usr/bin/</span><span style="color: #96a5d9; font-weight: bold;">env</span><span style="color: #2872b2;"> bash</span>
apt-get update
apt-get install -y apache2
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgheadline33" class="outline-3">
<h3 id="orgheadline33"><span class="section-number-3">1.6</span> ch8 Monitoring the code</h3>
<div class="outline-text-3" id="text-1-6">
</div><div id="outline-container-orgheadline28" class="outline-4">
<h4 id="orgheadline28"><span class="section-number-4">1.6.1</span> Nagios</h4>
<div class="outline-text-4" id="text-1-6-1">
<p>
Start a Nagios container:
</p>
<div class="org-src-container">
<pre class="src src-sh">docker run -e <span style="color: #ff694d;">NAGIOSADMIN_USER</span>=nagiosadmin -e <span style="color: #ff694d;">NAGIOSAMDIN_PASS</span>=nagios -p 80:30000 cpuguy83/nagios
</pre>
</div>
<p>