-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDevops Tools Commands quick reference.txt
More file actions
599 lines (464 loc) · 17.7 KB
/
Devops Tools Commands quick reference.txt
File metadata and controls
599 lines (464 loc) · 17.7 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
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
Git COMMANDS
------------------------------------------------------------------------------------------------------------------------
git config --global user.name "username"
git config --global user.email "email@example.com"
git clone
git --help
git --version
git add filename
git add .
git commit -m "any message"
git push
git pull
git log
git status
git init
git remote add anyname url_of_empty_repository
git push anyname master
git branch branchname
git checkout branchname
git merge branchname1 branchname2
git rebase branchname1 branchname2
git branch -d branchname1 //delete the merged branch
git diff
git revert
git reset
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status
grow, mark and tweak your common history
branch List, create, or delete branches
checkout Switch branches or restore working tree files
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
tag Create, list, delete or verify a tag object signed with GPG
collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
------------------------------------------------------------------------------------------------------------------------
ANT COMMANDS
ant clean
ant
ant compile
------------------------------------------------------------------------------------------------------------------------
MAVEN COMMANDS
mvn clean
mvn compile
mvn verify
mvn install
mvn clean install
mvn test
------------------------------------------------------------------------------------------------------------------------
GRADLE COMMANDS
gradle clean
gradle assemble
gradle build
------------------------------------------------------------------------------------------------------------------------
VAGRANTUP COMMANDS
vagrant box
vagrant init
vagrant init ubuntu/trusty64
vagrant up
vagrant halt
vagrant ssh
vagrant destroy
vagrant resume
vagrant suspend
------------------------------------------------------------------------------------------------------------------------
LINUX BASIC COMMANDS
pwd
ls
ls -la
echo "content of file > name.txt
echo "additional content" >>name.txt
touch name1.txt
chmod 755 name1.txt
vi name1.txt
------------------------------------------------------------------------------------------------------------------------
VI Editor commands
i - insert mode
ESC + :wq - to write and quit
Esc + :Q! - quit without save
Esc + :Q - quit the editor
------------------------------------------------------------------------------------------------------------------------
PUPPET COMMANDS
------------------------------------------------------------------------------------------------------------------------
//vagrant file
Vagrant.configure("2") do |config|
config.vm.define "puppet" do |puppet|
puppet.vm.box = "ubuntu/xenial64"
puppet.vm.network "private_network", ip: "192.168.0.175"
puppet.vm.hostname = "puppet"
puppet.vm.provider "virtualbox" do |v|
v.memory = 4096
end
end
config.vm.define "node1" do |node1|
node1.vm.box = "ubuntu/xenial64"
node1.vm.network "private_network", ip: "192.168.0.176"
node1.vm.hostname = "node1"
end
end
------------------------------------------------------------------------------------------------------------------------
//puppet server
$sudo vi /etc/hosts
192.168.0.176 node1
sudo curl -O https://apt.puppetlabs.com/puppetlabs-release-pc1-xenial.deb
sudo dpkg -i puppetlabs-release-pc1-xenial.deb
sudo apt-get update
sudo apt-get install puppetserver
sudo ufw allow 8140
sudo vi /etc/default/puppetserver
sudo systemctl start puppetserver
sudo systemctl status puppetserver
------------------------------------------------------------------------------------------------------------------------
//node
sudo vi /etc/hosts
192.168.0.175 puppet
sudo wget https://apt.puppetlabs.com/puppetlabs-release-pc1-xenial.deb
sudo dpkg -i puppetlabs-release-pc1-xenial.deb
sudo apt-get update
sudo apt-get install puppet-agent
sudo systemctl start puppet
sudo systemctl enable puppet
------------------------------------------------------------------------------------------------------------------------
// puppet server
sudo /opt/puppetlabs/bin/puppet cert list
sudo /opt/puppetlabs/bin/puppet cert list --all //to view all certificate list
sudo /opt/puppetlabs/bin/puppet cert sign node1.domain.name
or
sudo /opt/puppetlabs/bin/puppet cert sign –all
sudo vi /etc/puppetlabs/code/environments/production/manifests/site.pp
------------------------------------------------------------------------------------------------------------------------
//paste below commands in site.pp file
file {'/tmp/tempfile': # resource type file and filename
ensure => present, # make sure it exists
mode => '0644', # file permissions
content => "This is temporary file",
}
or
package {'screen':
ensure => present,
}
package {'git':
ensure => present,
}
package {'wget':
ensure => present,
}
package {'python':
ensure => present,
}
package {'apache2':
ensure => present,
}
package {'ant':
ensure => present,
}
//node
sudo /opt/puppetlabs/bin/puppet agent --test
//to verify all the software installed on node use below command
apt list --installed
------------------------------------------------------------------------------------------------------------------------
CHEF COMMANDS
First Step
Install Vagrant and virtual box
Create vagrant file
------------------------------------------------------------------------------------------------------------------------
Second step
vagrant init ubuntu/trusty64
Replace with below commands in vagrant file
Vagrant.configure("2") do |config|
config.vm.define "developmentkit" do |developmentkit|
developmentkit.vm.box = "ubuntu/trusty64"
developmentkit.vm.network "private_network", ip: "192.168.0.252"
developmentkit.vm.hostname = "developmentkit.example.com"
end
config.vm.define "chefserver" do |chefserver|
chefserver.vm.box = "ubuntu/trusty64"
chefserver.vm.network "private_network", ip: "192.168.0.253"
chefserver.vm.hostname = "chefserver.example.com"
chefserver.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 2
end
end
config.vm.define "node" do |node|
node.vm.box = "ubuntu/trusty64"
node.vm.network "private_network", ip: "192.168.0.3"
node.vm.hostname = "node.example.com"
end
end
//up the machine using below commands
vagrant up
------------------------------------------------------------------------------------------------------------------------
Third Step
paste the chef developmentkit and chef server of ubuntu in vagrant folder
------------------------------------------------------------------------------------------------------------------------
Fourth Step
vagrant ssh developmentkit
ls /vagrant
sudo dpkg -i /vagrant/chefdk_0.9.0-1_amd64.deb
mkdir cookbooks
mkdir .chef
vi .chef/knife.rb
cookbook_path ['/home/vagrant/cookbooks'] //In knife.rb
cd cookbooks
chef generate cookbook my_cookbook
ls my_cookbook/
cd my_cookbook/recipes
vi default.rb
// In default.rb paste the below commands
file '/tmp/hello.txt' do
content 'hello world'
end
or
package 'nginx' do
action :install
end
service 'nginx' do
action [ :enable, :start ]
end
sudo chef-client -z --runlist 'recipe[my_cookbook]' //to verify my_cookbook is working or not
exit
------------------------------------------------------------------------------------------------------------------------
Fifth step
// go to root user of developmentkit
sudo -s
ls /etc
vi hosts
//add these three lines in hosts file
192.168.0.253 chefserver.example.com chefserver
192.168.0.252 developmentkit.example.com developmentkit
192.168.0.3 node.example.com node
//save it by using escape :wq
exit
------------------------------------------------------------------------------------------------------------------------
Sixth Step
//In chefserver machine
vagrant ssh chefserver
sudo -s
ls /etc
vi hosts
//add these three lines in hosts file
192.168.0.253 chefserver.example.com chefserver
192.168.0.252 developmentkit.example.com developmentkit
192.168.0.3 node.example.com node
//save it by using escape :wq
ping node // to verify node is connected to server - stop using ctrl+c
exit
------------------------------------------------------------------------------------------------------------------------
Seventh Step //In node machine
vagrant ssh node
sudo -s
ls /etc
vi hosts
//add these three lines in hosts file
192.168.0.253 chefserver.example.com chefserver
192.168.0.252 developmentkit.example.com developmentkit
192.168.0.3 node.example.com node
//save it by using escape :wq
exit
------------------------------------------------------------------------------------------------------------------------
Eighth Step //In chefserver machine
vagrant ssh chefserver
sudo -s
ls /vagrant/
dpkg -i /vagrant/chef-server-core_XXXXXXXX.deb //install chef server software in chef server
chef-server-ctl reconfigure
chef-server-ctl user-create admin admin admin admin@example.com LearnDevops -f admin.pem
chef-server-ctl org-create learndevops "Learn Devops Course" --association_user admin -f org.pem //optional
cp admin.pem org.pem /vagrant
or
cp admin.pem /vagrant
exit
------------------------------------------------------------------------------------------------------------------------
Ninth Step // In Developmentkit machine
vagrant ssh developmentkit
cp /vagrant/*.pem .
ls
vi .chef/knife.rb
//Add below commands in knife.rb
current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
node_name "admin"
client_key "/home/vagrant/admin.pem"
chef_server_url "https://chefserver.example.com/organizations/learndevops"
cookbook_path ["/home/vagrant/cookbooks"]
cat .chef/knife.rb // to display all above commands - to verify
knife ssl fetch
knife client list // it will shows learndevops-validator
knife bootstrap node.example.com -N node -s -x vagrant --sudo // it will ask vagrant password - enter "vagrant"
knife client list //it will show node also
cd cookbooks/
ls
knife cookbook upload my_cookbook //uploading my_cookbook to chefserver
knife node run_list set node 'recipe[my_cookbook]' //it will show node run list and same uploaded to node run list
ssh node 'sudo chef-client' //give yes and enter vagrant node password in vagrant node - "vagrant"
------------------------------------------------------------------------------------------------------------------------
Tenth Step
Verify Now hello.txt is copied in node /tmp folder
------------------------------------------------------------------------------------------------------------------------
ANSIBLE COMMANDS
Installation
----------------------------------------------------------------------------------------------------------------------------
Vagrant File -Installation
----------------------------------------------------------------------------------------------------------------------------
Vagrant.configure("2") do |config|
config.vm.define "ansible" do |ansible|
ansible.vm.box = "ubuntu/trusty64"
ansible.vm.network "private_network", ip: "192.168.0.51"
ansible.vm.hostname = "ansible"
end
config.vm.define "node1" do |node1|
node1.vm.box = "ubuntu/trusty64"
node1.vm.network "private_network", ip: "192.168.0.52"
node1.vm.hostname = "node1"
end
end
-----------------------------------------------------------------------------------------------------------------------
vagrant up //to up the two machines
vagrant ssh ansible //login ansible machine
------------------------------------------------------------------------------------------------------------------------
Ansibe Installation for ubuntu // In ansible machine
sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
------------------------------------------------------------------------------------------------------------------------
//In ansible machine
ssh-keygen
pwd // it will be in a directory /home/vagrant
ls -la //to list hidden files and folders - it will show .ssh folder
cd .ssh // changing the directory to .ssh - it will show generated private and public key
cat id_rsa.pub //copy the public key
(or)
vi id_rsa.pub //copy the public key
//In node machine
sudo -s //to obtain a admin rights or login through root user
cd /root //change the directory to root folder
cd .ssh //change the directory to hidden .ssh folder
ls //to view the authorized_keys file
vi authorized_keys //paste the key
(or)
sudo -s
echo "ssh-rsa paste_the_key">/root/.ssh/authorized_keys
// go back to ansible machine
vi hosts => add ip address => 192.168.0.52
ssh-agent bash
ssh-add .ssh/id_rsa // add the private key
ansible -i hosts -u root -m ping all
-----------------------------------------------------------------------------------------------------------------------
//In ansible machine
ls -lha /etc/ansible //to view the ansible core files
cp -R /etc/ansible myplatform // copy the ansible core files into myplatform directory
cd myplatform // change the directory to myplatform
ls -lha // confirm all the core files or copies to myplatform
------------------------------------------------------------------------------------------------------------------
//In Ansible machine - Creating configuration in myplatform directory
vi ansible.cfg
inventory = hosts //uncomment inventory and change the hosts path
vi hosts // open the hosts file in editor
192.168.0.52 // insert ip address of node1
ansible -u root -m ping all
ansible -u root -m shell -a 'hostname' all
ansible -u root -m shell -a 'df-h' all
ansible -u root -m shell -a 'whoami' all
--------------------------------------------------------------------------------------
Creating Main.YML file
//change the directory to myplatform
cd roles //change the directory to roles
mkdir basic // create a directory called basic
cd basic //change directory to basic
mkdir tasks // create a directory called tasks
cd tasks //change the directory to tasks
vi main.yml // create a main.yml file using vi editor
// In Main.Yml file - paste the below commands
- name: "Installing Vim"
apt: pkg=vim state=installed
(or)
// Multipe installaiton configuration -- // vi roles/basic/tasks/main.yml
- name: "Installing Vim"
apt: pkg=vim state=installed
- name: "Installing DNS Utils"
apt: pkg=dnsutils state=installed
- name: "Installing Vim"
apt: pkg=git state=installed
Run => ansible playbook -K playbook.yml
(or)
- name: "Installing additional software"
apt: pkg={{item}} state=installed
with_items:
- dnsutils
- git
- vim
- ntp
- at
- lvm2
------------------------------------------------------------------------------------------------------------------------
// Go to myplatform directory or home directory - Create a playbook.yml
// it need to be created in myplatform directory
vi playbook.yml // to create a new playbook.yml file using vi editor
//IN playbook.yml file -paste below commands
---
- hosts: all
become: true
roles:
- basic
// Run playbook.yml using following command - verify you are in myplatform directory
ansible-playbook -u root -s playbook.yml
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
Docker Commands
docker info
docker pull
docker images
docker run
docker ps
docker ps -a
docker stop
docker rm
docker exec -it <container ID> /bin/bash
docker run <image>
docker run --name=<customname> <image>
docker run --rm <image>
docker run --d <image>
docker run --d -it <image>
docker run --d -p 4000:4000
Examples:
docker pull alpine
docker run alpine sh
docker ps -a
docker run -d -it alpine sh
docker run -it alpine sh
ps
docker run -it --name=MyLinux alpine sh
docker ps -a
docker stop MyLinux
docker rm MyLinux
docker pull microsoft/nanoserver
docker run -it microsoft/nanoserver cmd
docker run -it microsoft/nanoserver cmd /c echo "some message"
docker network ls
docker inspect nat
docker inspect <container ID>
docker pull microsoft/iis:nanoserver
docker run -d microsoft/iis
docker run -d -p 8000:8000 microsoft/iis:nanoserver
docker ps -a