sandervanvugt

Untitled

Jun 19th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.31 KB | None | 0 0
  1. [ansible@control lesson16]$ history
  2. 1 sudo -i
  3. 2 sudo yum install -y ansible
  4. 3 sudo yum install -y epel-release
  5. 4 yum install -y ansible
  6. 5 sudo yum install -y ansible
  7. 6 sudo -i
  8. 7 ssh-keygen
  9. 8 ssh-copy-id ansible1
  10. 9 ssh-copy-id ansible2
  11. 10 ssh ansible2
  12. 11 ansible --version
  13. 12 git clone https://github.com/sandervanvugt/rhce8-live
  14. 13 git clone https://github.com/sandervanvugt/rhce8-book
  15. 14 cd rhce8-live/
  16. 15 ls
  17. 16 ./countdown 12
  18. 17 sudo vim /etc/ansible/hosts
  19. 18 vim myinventory
  20. 19 ansible -i myinventory all --list-hosts
  21. 20 ansible -i myinventory dbase --list-hosts
  22. 21 ansible -i myinventory ungrouped --list-hosts
  23. 22 cd lesson2/
  24. 23 ls
  25. 24 sudo vim /etc/ansible/ansible.cfg
  26. 25 vim ansible.cfg
  27. 26 ansible --version
  28. 27 vim ansible.cfg
  29. 28 ansible all -m user -a "name=lisa"
  30. 29 cd ..
  31. 30 ansible all -m user -a "name=lisa"
  32. 31 ls
  33. 32 cd -
  34. 33 ansible all -m command -a "id lisa"
  35. 34 cat inventory
  36. 35 ansible --help
  37. 36 ../countdown 12
  38. 37 history
  39. 38 ansible-doc -l
  40. 39 ansible-doc -l | wc
  41. 40 ansible-doc -l | grep vmware
  42. 41 ansible-doc -l | grep mel
  43. 42 ansible-doc -l | grep cisco
  44. 43 ansible-doc -l | grep ios
  45. 44 ansible-doc user
  46. 45 ansible all -m ping
  47. 46 ansible all -m service -a "name=httpd state=started"
  48. 47 ansible all -m service -a "name=sshd state=started"
  49. 48 ansible all -m service -a "name=sshd state=stopped"
  50. 49 history
  51. 50 ansible all -m ping
  52. 51 ansible all -m command "id ansible"
  53. 52 ansible all -m command -a "id ansible"
  54. 53 ansible-doc service
  55. 54 ansible all -a "ps aux |grep ssh"
  56. 55 ansible all -a "ps -aux |grep ssh"
  57. 56 ansible all -m shell -a "ps -aux |grep ssh"
  58. 57 ansible all -m command -a "rpm -qa | grep vi"
  59. 58 ansible all -m shell -a "rpm -qa | grep vi"
  60. 59 ansible-doc -l cisco
  61. 60 ansible all -m copy -a 'content="hello world" dest=/etc/motd"
  62. 61 ansible all -m copy -a 'content="hello world" dest=/etc/motd'
  63. 62 ansible all -m shell -a "cat /etc/motd"
  64. 63 history
  65. 64 vim myscript.sh
  66. 65 chmod +x myscript.sh
  67. 66 ./myscript.sh
  68. 67 vim myscript.sh
  69. 68 vim ~/.vimrc
  70. 69 cd ../lesson4/
  71. 70 ls
  72. 71 vim vsftpd.yml
  73. 72 ansible-playbook vsftpd.yml
  74. 73 cat /etc/hosts
  75. 74 cat ~/.vimrc
  76. 75 ../countdown 12
  77. 76 cat ~/.vimrc
  78. 77 vim vsftpd.yml
  79. 78 ls
  80. 79 vim install-httpd.yml
  81. 80 ansible-playbook install-httpd.yml
  82. 81 vim uninstall-httpd.yml
  83. 82 vim install-httpd.yml
  84. 83 ansible-doc service
  85. 84 ansible-doc yum
  86. 85 vim vsftpd.yml
  87. 86 ansible-playbook vsftpd.yml
  88. 87 ansible-playbook --syntax-check vsftpd.yml
  89. 88 ansible-playbook -C vsftpd.yml
  90. 89 ansible-playbook -v vsftpd.yml
  91. 90 vim vsftpd.yml
  92. 91 ansible-playbook -v vsftpd.yml
  93. 92 ansible-playbook -vv vsftpd.yml
  94. 93 ansible-playbook -vvvv vsftpd.yml
  95. 94 ansible-playbook -vvvvv vsftpd.yml
  96. 95 ansible-playbook -vvvvvv vsftpd.yml
  97. 96 ansible-playbook --help | less
  98. 97 vim web-setup-and-test.yml
  99. 98 ansible-playbook web-setup-and-test.yml
  100. 99 ls
  101. 100 vim install-httpd.yml
  102. 101 vim web-setup-and-test.yml
  103. 102 vim install-httpd.yml
  104. 103 cd ../lesson5/
  105. 104 ls
  106. 105 ansible ansible1.example.com -m setup > facts.txt
  107. 106 less facts.txt
  108. 107 ls
  109. 108 vim user.yml
  110. 109 ansible-playbook user.yml
  111. 110 ansible-playbook user.yml -e user=linda
  112. 111 history
  113. 112 exit
  114. 113 vim homework1.txt
  115. 114 pwd
  116. 115 ls
  117. 116 cd rhce8-live/
  118. 117 ls
  119. 118 cd lesson5/
  120. 119 vim new-http.yaml
  121. 120 vim new-unhttp.yaml
  122. 121 sudo vim /etc/hosts
  123. 122 ping ansible3.example.com
  124. 123 vim inventory
  125. 124 ansible -u root -i inventory ansible3.example.com --ask-pass -m raw -a "yum install python3"
  126. 125 ansible -u root -i inventory ansible3.example.com --ask-pass -m raw -a "yum install -y python3"
  127. 126 vim ansible.cfg
  128. 127 vim new-http.yaml
  129. 128 ansible-playbook new-http.yaml
  130. 129 curl http://ansible2.example.com
  131. 130 vim new-unhttp.yaml
  132. 131 ansible-playbook new-unhttp.yaml
  133. 132 history
  134. 133 sudo firewall-cmd --list-all
  135. 134 sudo firewall-cmd --add-service ftp
  136. 135 sudo firewall-cmd --list-all
  137. 136 sudo firewall-cmd --reload
  138. 137 sudo firewall-cmd --list-all
  139. 138 sudo firewall-cmd --add-service ftp --permanent
  140. 139 sudo firewall-cmd --list-all
  141. 140 sudo firewall-cmd --add-service ftp
  142. 141 vim new-http.yaml
  143. 142 ansible-doc firewalld
  144. 143 history
  145. 144 vim new-http.yaml
  146. 145 vim user.yml
  147. 146 ansible-playbook user.yml -e user=anna
  148. 147 ls
  149. 148 cd
  150. 149 history | grep git
  151. 150 cd rhce8-book/
  152. 151 ls
  153. 152 less listing66.yaml
  154. 153 vim listing66.yaml
  155. 154 cat inventory
  156. 155 ansible-playbook listing66.yaml
  157. 156 cd ../rhce8-live/lesson5/
  158. 157 ls
  159. 158 cat ../../rhce8-book/listing66.yaml
  160. 159 less facts.txt
  161. 160 ls
  162. 161 cd webservers/
  163. 162 ls
  164. 163 vim site.yml
  165. 164 vim group_vars/lamp
  166. 165 vim site.yml
  167. 166 ansible-playbook site.yml
  168. 167 cat ../../rhce8-book/listing66.yaml
  169. 168 cat ../../../rhce8-book/listing66.yaml
  170. 169 cd ..
  171. 170 vim user.yml
  172. 171 ansible-vault --help
  173. 172 ../countdown 12
  174. 173 cd ../lesson7/
  175. 174 ls
  176. 175 cd vault/
  177. 176 ls
  178. 177 cat secret.yml
  179. 178 rm secret.yml
  180. 179 ansible-vault create secret.yml
  181. 180 vim create-user.yml
  182. 181 ansible-playbook create-user.yml
  183. 182 ansible-playbook --ask-vault-pass create-user.yml
  184. 183 echo password > vault-pass
  185. 184 cat vault-pass
  186. 185 ls -l vault-pass
  187. 186 chmod 400 vault-pass
  188. 187 ansible-playbook --vault-password-file=vault-pass create-users.yml
  189. 188 ansible-playbook --vault-password-file=vault-pass create-user.yml
  190. 189 ansible-playbook -m setup all
  191. 190 ansible all -m setup
  192. 191 pwd
  193. 192 cd ../../..
  194. 193 cd rhce8-book/
  195. 194 vim listing61.yaml
  196. 195 vim listing62.yaml
  197. 196 ansible-playbook listing62.yaml
  198. 197 vim listing63.yaml
  199. 198 vim listing64.yaml
  200. 199 vim listing65.yaml
  201. 200 ansible-playbook listing65.yaml
  202. 201 ansible-playbook listing66.yaml
  203. 202 vim listing66.yaml
  204. 203 vim listing67.yaml
  205. 204 vim listing68.yaml
  206. 205 vim listing69.yaml
  207. 206 vim listing68.yaml
  208. 207 vim listing69.yaml
  209. 208 ansible-playbook listing69.yaml
  210. 209 ansible all -m setup -a "filter=ansible_local"
  211. 210 cd ../rhce8-live/lesson7/
  212. 211 ls
  213. 212 cd facts
  214. 213 ls
  215. 214 cat newlocalfacts.yml
  216. 215 cat localfacts.fact
  217. 216 ansible-playbook newlocalfacts.yml
  218. 217 ansible ansible1.example.com -m setup -a "filter=ansible_local"
  219. 218 pwd
  220. 219 cd ../lesson5
  221. 220 cd ..
  222. 221 cd ../lesson5
  223. 222 ls
  224. 223 cd -
  225. 224 ls
  226. 225 cd arrays/
  227. 226 ls
  228. 227 ls vars/users-dictionary
  229. 228 cat vars/users-dictionary
  230. 229 cat vars/users-list
  231. 230 ls
  232. 231 vim multi-list.yml
  233. 232 ansible-playbook multi-list.yml
  234. 233 vim multi-dictionary.yml
  235. 234 ansible-playbook multi-dictionary.yml
  236. 235 ls
  237. 236 pwd
  238. 237 ../../countdown 14
  239. 238 cd ../..
  240. 239 ls
  241. 240 cd lesson8
  242. 241 ls
  243. 242 vim loopservices.yml
  244. 243 ansible-playbook loopservices.yml
  245. 244 vim loopusers.yml
  246. 245 ansible-playbook loopusers.yml
  247. 246 vim loop-over-variable.yml
  248. 247 vim loopvars.yml
  249. 248 vim loop-over-variable.yml
  250. 249 ansible-playbook loop-over-variable.yml
  251. 250 ls
  252. 251 vim register_command.yml
  253. 252 pwd
  254. 253 vim ../../rhce8-book/listing618.yaml
  255. 254 ansible-playbook ../../rhce8-book/listing618.yaml
  256. 255 vim register_loop.yml
  257. 256 ansible-playbook register_loop.yml
  258. 257 vim register_command.yml
  259. 258 ansible-playbook register_command.yml
  260. 259 vim register_command.yml
  261. 260 ansible-playbook register_command.yml
  262. 261 vim register_command.yml
  263. 262 ansible-playbook register_command.yml
  264. 263 vim register_command.yml
  265. 264 ansible-playbook register_command.yml
  266. 265 ansible-doc debug
  267. 266 history
  268. 267 vim distro.yml
  269. 268 ansible-playbook distro.yml
  270. 269 vim distro.yml
  271. 270 ansible-playbook distro.yml
  272. 271 vim quicktest.yml
  273. 272 ansible-playbook quicktest.yml
  274. 273 date
  275. 274 vim quicktest.yml
  276. 275 ansible-playbook quicktest.yml
  277. 276 vim quicktest.yml
  278. 277 ansible-playbook quicktest.yml
  279. 278 vim quicktest.yml
  280. 279 vim command-output-test.yml
  281. 280 ansible-playbook command-output-test.yml
  282. 281 vim command-output-test.yml
  283. 282 ../countdown 12
  284. 283 vim when_multiple
  285. 284 vim when_multiple.yml
  286. 285 ansible-playbook when_multiple.yml
  287. 286 vim when_multiple.yml
  288. 287 ansible-playbook when_multiple.yml
  289. 288 vim when_multiple.yml
  290. 289 ansible-playbook when_multiple.yml
  291. 290 vim when_multiple.yml
  292. 291 ansible-playbook when_multiple.yml
  293. 292 vim when_multiple_complex.yml
  294. 293 ansible-playbook when_multiple_complex.yml
  295. 294 vim restart.yml
  296. 295 ansible-playbook restart.yml
  297. 296 vim restart.yml
  298. 297 vim ../../rhce8-book/listing79.yaml
  299. 298 ansible-playbook ../../rhce8-book/listing79.yaml
  300. 299 ansible-playbook ../../rhce8-book/listing710.yaml
  301. 300 vim ../../rhce8-book/listing710.yaml
  302. 301 vim ../../rhce8-book/listing711.yaml
  303. 302 vim ../../rhce8-book/listing712.yaml
  304. 303 vim ../../rhce8-book/listing78.yaml
  305. 304 ansible-playbook ../../rhce8-book/listing78.yaml
  306. 305 vim ../../rhce8-book/listing78.yaml
  307. 306 history
  308. 307 vim handlers.yml
  309. 308 ansible-playbook handlers.yml
  310. 309 touch /tmp/index.html
  311. 310 ansible-playbook handlers.yml
  312. 311 vim handlers.yml
  313. 312 ansible-playbook handlers.yml
  314. 313 ansible all -m file "name=/var/www/html/index.html state=absent"
  315. 314 ansible all -m file -a "name=/var/www/html/index.html state=absent"
  316. 315 ansible-playbook handlers.yml
  317. 316 history
  318. 317 vim blocks.yml
  319. 318 ansible-playbook blocks.yml
  320. 319 ansible-playbook blocks2.yml
  321. 320 vim blocks2.yml
  322. 321 ansible-playbook blocks2.yml
  323. 322 vim blocks2.yml
  324. 323 history
  325. 324 cd rhce8-live/
  326. 325 cd lesson8/
  327. 326 vim homework.yml
  328. 327 vim homework.txt
  329. 328 ls
  330. 329 vim homework.yml
  331. 330 cat homework.yml
  332. 331 vim homework.txt
  333. 332 vim failure.yml
  334. 333 ansible-playbook failure.yml
  335. 334 vim failure.yml
  336. 335 ansible-playbook failure.yml
  337. 336 vim failure2.yml
  338. 337 ansible-doc fail
  339. 338 vim failure2.yml
  340. 339 ansible-playbook failure2.yml
  341. 340 vim changed.yml
  342. 341 ansible-playbook changed.yml
  343. 342 vim failure2.yml
  344. 343 cd ../lesson9/
  345. 344 ls
  346. 345 vim file.yml
  347. 346 ansible-playbook file.yml
  348. 347 vim file.yml
  349. 348 ls -lZ /tmp/
  350. 349 vim file.yml
  351. 350 ansible all -m shell -a "ls -lZ /tmp/re*"
  352. 351 vim copy.yml
  353. 352 ansible-playbook copy.yml
  354. 353 cd /tmp
  355. 354 ls
  356. 355 cd ansible1.example.com/
  357. 356 ls
  358. 357 cd tmp/
  359. 358 ls
  360. 359 cat hosts
  361. 360 cd -
  362. 361 cd
  363. 362 cd rhce8-live/
  364. 363 cd lesson8/
  365. 364 ls
  366. 365 cat homework.yml
  367. 366 ../countdown 15
  368. 367 ls -lrt
  369. 368 vim chad.yml
  370. 369 cat vars/web_vars
  371. 370 vim chad.yml
  372. 371 ansible all -m file -a "name=/var/www/html/index.html state=absent"
  373. 372 vim chad.yml
  374. 373 ansible-playbook chad.yml
  375. 374 cat chad.yml
  376. 375 cat vars/web_vars
  377. 376 cd ../lesson9/
  378. 377 ls
  379. 378 vim selinux.yml
  380. 379 ansible-playbook selinux.yml
  381. 380 vim selinux.yml
  382. 381 ansible-playbook selinux.yml
  383. 382 vim selinux.yml
  384. 383 ansible-doc file
  385. 384 vim selinux.yml
  386. 385 vim vsftpd-template.yml
  387. 386 ls
  388. 387 cat templates/vsftpd.j2
  389. 388 ansible-playbook vsftpd-template.yml
  390. 389 ansible ansible2.example.com -a "cat /etc/vsftpd/vsftpd.conf"
  391. 390 vim hostsfile.yml
  392. 391 vim templates/hosts.j2
  393. 392 ansible-playbook hostsfile.yml
  394. 393 ansible ansible2.example.com -a "cat /etc/hosts"
  395. 394 vim hostsfile.yml
  396. 395 history | grep git
  397. 396 ls
  398. 397 cat hostsfile.yml
  399. 398 cat templates/hosts.j2
  400. 399 ansible-doc sefcontext
  401. 400 ansible-doc -l | grep selinux
  402. 401 ansible-doc -l | grep -A 5 -B 5 sefcontext
  403. 402 ../countdown 13
  404. 403 cd ../lesson10
  405. 404 cd ../lesson11/
  406. 405 ansible-galaxy install geerlingguy.nginx
  407. 406 cd ~/.ansible/
  408. 407 ls
  409. 408 cd roles/
  410. 409 s
  411. 410 ls
  412. 411 cd geerlingguy.nginx/
  413. 412 ls
  414. 413 tree
  415. 414 sudo yum install tree -y
  416. 415 tree
  417. 416 cd tasks/
  418. 417 ls
  419. 418 vim main.yml
  420. 419 vim setup-RedHat.yml
  421. 420 cd ..
  422. 421 ls
  423. 422 cd defaults/
  424. 423 ls
  425. 424 vim main.yml
  426. 425 cd ../handlers/
  427. 426 ls
  428. 427 vim main.yml
  429. 428 cd ../templates/
  430. 429 ls
  431. 430 vim nginx.repo.j2
  432. 431 cd
  433. 432 cd rhce8-live/
  434. 433 cd lesson11/
  435. 434 ls
  436. 435 vim nginx-role.yml
  437. 436 ansible-playbook nginx-role.yml
  438. 437 ansible-galaxy --help
  439. 438 ansible-galaxy --init
  440. 439 ansible-galaxy myrole --init
  441. 440 ansible-galaxy myrole init
  442. 441 ansible-galaxy role init myrole
  443. 442 ls
  444. 443 tree myrole/
  445. 444 cd roles/
  446. 445 ls
  447. 446 ls -l
  448. 447 date
  449. 448 history | grep git
  450. 449 tree motd2
  451. 450 tree motd
  452. 451 cd motd
  453. 452 cat defaults/main.yml
  454. 453 cat meta/main.yml
  455. 454 cat README.md
  456. 455 ls
  457. 456 cat tasks/main.yml
  458. 457 cat templates/motd.j2
  459. 458 pwd
  460. 459 cd ../..
  461. 460 vim motd-role.yml
  462. 461 ansible-playbook motd-role.yml
  463. 462 ansible ansible2.example.com -a "cat /etc/motd"
  464. 463 sudo yum install rhel-system-roles -y
  465. 464 ls /usr/share/ansible/roles/
  466. 465 rpm -qf /usr/share/ansible/roles/rhel-system-roles.network/
  467. 466 rpm -ql /usr/share/ansible/roles/rhel-system-roles.network/
  468. 467 rpm -ql rhel-system-roles
  469. 468 cd /usr/share/doc/rhel-system-roles/
  470. 469 ls
  471. 470 cd network/
  472. 471 ls
  473. 472 vim example-eth-simple-auto-playbook.yml
  474. 473 cd ../timesync/
  475. 474 ls
  476. 475 vim example-timesync-playbook.yml
  477. 476 cp example-timesync-playbook.yml ~/rhce8-live/lesson11/
  478. 477 cd
  479. 478 cd rhce8-live/lesson11/
  480. 479 ls
  481. 480 mv example-timesync-playbook.yml name-that-they-want-it-to-be.yaml
  482. 481 vim name-that-they-want-it-to-be.yaml
  483. 482 grep roles /etc/ansible/ansible.cfg
  484. 483 ../countdown 13
  485. 484 ansible all -a "cat /etc/sudoers.d/ansible"
  486. 485 ansible localhost -m debug -a "msg={{ 'password' | password_hash('sha512','mypassword') }}"
  487. 486 cd ../lesson16/
  488. 487 ls
  489. 488 vim userpw.yml
  490. 489 pwd
  491. 490 cd ../../rhce8-book/
  492. 491 grep register *
  493. 492 vim exercise133.yaml
  494. 493 grep stdin listing*
  495. 494 vim listing1313.yaml
  496. 495 sudo -i
  497. 496 vim listing1313.yaml
  498. 497 ls
  499. 498 cd ../rhce8-live/
  500. 499 ls
  501. 500 cd lesson16/
  502. 501 ls
  503. 502 vim users-advanced.yml
  504. 503 vim exercise134-vars.yaml
  505. 504 vim users-advanced.yml
  506. 505 vim exercise134-tasks.yaml
  507. 506 vim users-advanced.yml
  508. 507 ansible-playbook users-advanced.yml
  509. 508 vim users-advanced.yml
  510. 509 vim users-advanced.yml --tags setupremote
  511. 510 ansible-playbook users-advanced.yml --tags setupremote
  512. 511 vim inventory
  513. 512 ansible-playbook users-advanced.yml --tags setupremote
  514. 513 ssh sharon@ansible2
  515. 514 vim users-advanced.yml
  516. 515 history
  517. 516 history | grep git
  518. 517 exit
  519. 518 cd rhce8-live/lesson12/
  520. 519 vim dmitriy.yaml
  521. 520 vim vsftpd.j2
  522. 521 vim dmitriy.yaml
  523. 522 vim vsftpd.j2
  524. 523 ansible-playbook dmitriy.yaml
  525. 524 vim dmitriy.yaml
  526. 525 ansible-playbook dmitriy.yaml
  527. 526 sudo yum provides */semanage
  528. 527 vim dmitriy.yaml
  529. 528 vim inventory
  530. 529 ansible-playbook dmitriy.yaml
  531. 530 vim vsftpd.j2
  532. 531 lsftp ansible2.example.com
  533. 532 lftp ansible2.example.com
  534. 533 cat vsftpd.j2
  535. 534 vim dmitriy.yaml
  536. 535 cat dmitriy.yaml
  537. 536 ls
  538. 537 cd ../../rhce8-book/
  539. 538 grep block *
  540. 539 vim listing731.yaml
  541. 540 ansible-doc debug
  542. 541 vim listing731.yaml
  543. 542 grep yum * 2>/dev/null
  544. 543 vim listing814.yaml
  545. 544 grep supported_distro *
  546. 545 cd ../rhce8-live/
  547. 546 grep -R supported_dis *
  548. 547 vim lesson8/chad.yml
  549. 548 cd lesson16/
  550. 549 vim users-advanced.yml
  551. 550 cd ../lesson13/
  552. 551 ls
  553. 552 vim pascal.py
  554. 553 ./pascal.py --list
  555. 554 ansible-inventory -i pascal.py --graph
  556. 555 ansible-playbook --list-tasks ../lesson16/users-advanced.yml
  557. 556 vim includes.yml
  558. 557 vim install-and-setup.yml
  559. 558 ansible-playbook includes.yml
  560. 559 ansible-playbook --list-tasks includes.yml
  561. 560 vim imports.yaml
  562. 561 vim tasks/service.yaml
  563. 562 vim tasks/firewall.yaml
  564. 563 ansible-playbook --list-tasks imports
  565. 564 ansible-playbook --list-tasks imports.yaml
  566. 565 ansible-playbook imports.yaml
  567. 566 vim imports.yaml
  568. 567 ansible-playbook imports.yaml
  569. 568 vim inventory
  570. 569 ansible-playbook imports.yaml
  571. 570 ../countdown 14
  572. 571 cd ../../rhce8-book/
  573. 572 vim listing111.yaml
  574. 573 vim listing112.j2
  575. 574 ansible-playbook listing111.yaml --check --diff
  576. 575 vim listing112.j2
  577. 576 ansible-playbook -vvvv listing111.yaml
  578. 577 grep log_path /etc/ansible/ansible.cfg
  579. 578 ansible-playbook --list-tasks exercise81.yaml
  580. 579 ansible-playbook --start-at-task "add a message" --step exercise81.yaml
  581. 580 vim listing116.yaml
  582. 581 ansible-playbook listing116.yaml
  583. 582 vim listing117.yaml
  584. 583 vim listing116.yaml
  585. 584 vim listing119.yaml
  586. 585 ansible-playbook listing119.yaml
  587. 586 vim listing119.yaml
  588. 587 ansible-playbook listing119.yaml
  589. 588 ansible-doc stat
  590. 589 vim listing1113.yaml
  591. 590 ansible-playbook listing1113.yaml
  592. 591 vim listing1113.yaml
  593. 592 vim listing1111.yaml
  594. 593 ansible-playbook listing1111.yaml
  595. 594 vim listing1115.yaml
  596. 595 ansible-playbook listing1115.yaml --tags services
  597. 596 vim listing1115.yaml
  598. 597 ansible-playbook listing1115.yaml --tags services
  599. 598 ls
  600. 599 vim chapters.txt
  601. 600 ../rhce8-live/countdown 13
  602. 601 cd /usr/share/doc/rhel-system-roles/
  603. 602 ls
  604. 603 cd selinux/
  605. 604 ls
  606. 605 vim example-selinux-playbook.yml
  607. 606 pwd
  608. 607 cd
  609. 608 cd rhce8-live/lesson16/
  610. 609 vim software-advanced.yml
  611. 610 cd ../../rhce8-book/
  612. 611 grep yum_repo *
  613. 612 vim exercise122-server.yaml
  614. 613 ansible-playbook exercise122-server.yaml
  615. 614 vim exercise122-client.yaml
  616. 615 ansible-playbook exercise122-client.yaml
  617. 616 ansible all -a "yum repolist"
  618. 617 history
  619. 618 ../rhce8-live/countdown 13
  620. 619 ansible-doc | grep stratis
  621. 620 ansible-doc -l | grep stratis
  622. 621 sudo yum install -y vdo
  623. 622 cd ../rhce8-live/
  624. 623 cd lesson16/
  625. 624 ls
  626. 625 vim storage-advanced.yml
  627. 626 ansible-playbook storage-advanced.yml
  628. 627 ansible all -m ping
  629. 628 vim inventory
  630. 629 sudo vim /etc/hosts
  631. 630 ssh root@ansible3
  632. 631 ssh-copy-id ansible3
  633. 632 ssh ansible3
  634. 633 ansible all -m ping
  635. 634 ansible-playbook storage-advanced.yml
  636. 635 vim inventory
  637. 636 ansible all -a "dd if=/dev/zero of=/dev/sdb bs=1M count=1"
  638. 637 ansible-playbook storage-advanced.yml
  639. 638 ansible all -a "reboot"
  640. 639 ansible all -m ping
  641. 640 history
  642. 641 ansible-playbook storage-advanced.yml
  643. 642 history
  644.  
  645. 15.3 Configuring Storage Advanced Exercise
  646. At the end of this chapter it's time again for an advanced exercise. This is probably the most advanced exercise of all exercises in this book, so make sure to take your time to understand all that is covered. To work on this exercise, you have need managed machines with an additional disk device: add a 10 GB second disk to host ansible2, and a 5 GB second disk to host ansible3. The exercise assumes the name of the second disk is /dev/sdb, if a different disk name is used in your configuration, change this according to your specifications.
  647.  
  648. Exercise 15.3: Setting up an Advanced Storage Solution
  649. In this exercise you'll need to set up a storage solution that meets the following requirements:
  650. • Tasks in this playbook should only be executed on hosts where the device /dev/sdb exists.
  651. • If no device /dev/sdb exists, the playbook should print "device sdb not present" and stop executing tasks on that host
  652. • Configure the device with one partition that includes all available disk space
  653. • Create an LVM volume group with the name vgfiles
  654. • If the volume group is bigger than 5 GB, create an LVM logical volume with the name lvfiles and a size of 6 GB. Note that you must check the LVM Volume Group size and not the /dev/sdb1 size, because in theory you could have multiple block devices in a volume group.
  655. • If the volume group is equal to or smaller than 5 GB, create an LVM logical volume with the name lvfiles and a size of 3 GB
  656. • Format the volume with the XFS filesystem
  657. • Mount it on the /files directory
  658.  
  659. 1. As this is going to be a bigger playbook, it's wise to split development into different parts, so that the different parts can be tested individually. If this would be a task on the EX294 exam, it's smart to start with the most challenging task, and write it in a small playbook so that it can run independently. This is because of time management: if you can't configure the challenging task, it doesn't make sense to spend your time on other tasks. With this in mind, let's focus on the condition where you need to check the size of the volume group. It might not be the best idea to start working on all tasks that are required to get you testing the volume group that needs to be created. You can however perfectly write a test that works on a default volume group, and that is what we're going to do first, using the name of the default volume group on CentOS 8, which is "cl". The purpose is to test the constructions, which is why it doesn't really matter that the two tasks have overlapping when statements. So create a file with the name exercise153-dev1.yaml and give it the following contents:
  660.  
  661. ---
  662. - name: get vg sizes
  663. hosts: all
  664. tasks:
  665. - name: find small vgroup sizes
  666. debug:
  667. msg: volume group smaller than or equal to 20G
  668. when:
  669. - ansible_facts['lvm']['vgs']['cl'] is defined
  670. - ansible_facts['lvm']['vgs']['cl']['size_g'] <= 20.00
  671. - name: find large vgroup size
  672. debug:
  673. msg: volume group larger than or equal to 19G
  674. when:
  675. - ansible_facts['lvm']['vgs']['cl'] is defined
  676. - ansible_facts['lvm']['vgs']['cl']['size_g'] >= 19.00
  677.  
  678. 2. Run the playbook, using ansible-playbook exercise153-dev1.yaml. You'll notice that it fails with the error seen in listing 15.12:
  679.  
  680. Listing 15.12: exercise153-dev1.yaml Failure Message
  681. TASK [find small vgroups sizes] ***************************************************
  682. fatal: [ansible1]: FAILED! => {"msg": "The conditional check 'ansible_facts['lvm']['vgs']['cl']['size_g'] <= 20.00' failed. The error was: Unexpected templating type error occurred on ({% if ansible_facts['lvm']['vgs']['cl']['size_g'] <= 20.00 %} True {% else %} False {% endif %}): '<=' not supported between instances of 'AnsibleUnsafeText' and 'float'\n\nThe error appears to be in '/home/ansible/rhce8-book/exercise153-dev1.yaml': line 5, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: find small vgroups sizes\n ^ here\n"}
  683. fatal: [ansible2]: FAILED! => {"msg": "The conditional check 'ansible_facts['lvm']['vgs']['cl']['size_g'] <= 20.00' failed. The error was: Unexpected templating type error occurred on ({% if ansible_facts['lvm']['vgs']['cl']['size_g'] <= 20.00 %} True {% else %} False {% endif %}): '<=' not supported between instances of 'AnsibleUnsafeText' and 'float'\n\nThe error appears to be in '/home/ansible/rhce8-book/exercise153-dev1.yaml': line 5, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: find small vgroups sizes\n ^ here\n"}
  684. fatal: [ansible3]: FAILED! => {"msg": "The conditional check 'ansible_facts['lvm']['vgs']['cl']['size_g'] <= 20.00' failed. The error was: Unexpected templating type error occurred on ({% if ansible_facts['lvm']['vgs']['cl']['size_g'] <= 20.00 %} True {% else %} False {% endif %}): '<=' not supported between instances of 'AnsibleUnsafeText' and 'float'\n\nThe error appears to be in '/home/ansible/rhce8-book/exercise153-dev1.yaml': line 5, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: find small vgroups sizes\n ^ here\n"}
  685. fatal: [ansible4]: FAILED! => {"msg": "The conditional check 'ansible_facts['lvm']['vgs']['cl']['size_g'] <= 20.00' failed. The error was: Unexpected templating type error occurred on ({% if ansible_facts['lvm']['vgs']['cl']['size_g'] <= 20.00 %} True {% else %} False {% endif %}): '<=' not supported between instances of 'AnsibleUnsafeText' and 'float'\n\nThe error appears to be in '/home/ansible/rhce8-book/exercise153-dev1.yaml': line 5, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: find small vgroups sizes\n ^ here\n"}
  686. skipping: [ansible5]
  687. skipping: [ansible6]
  688.  
  689. TASK [find large vgroups sizes] ***************************************************
  690. skipping: [ansible5]
  691. skipping: [ansible6]
  692.  
  693. 3. As you can see in the errors in listing 15.12, there are two problems in the playbook. The first problem is that there is no ignore_errors in the failing play, which means that only hosts that haven't failed will reach the next task. The second error is the "Unexpected templating error". The playbook as it is now tries to perform a logical test to compare the value of two variables that have an incompatible variable type. The Ansible fact has the type "AnsibleUnsafeText", and the value of 20.00 is a float, and not an integer. To make this test work, you'll have to force the type of both variables to be set to an integer. Let's write exercise153-dev2.yaml where this is happening - notice the use of the filter int which is essential for the success of this playboo:
  694.  
  695. ---
  696. - name: get vg sizes
  697. ignore_errors: yes
  698. hosts: all
  699. tasks:
  700. - name: set vgroup sizes in variables
  701. set_fact:
  702. vgsize: "{{ ansible_facts['lvm']['vgs']['cl']['size_g'] | int }}"
  703. - name: debug this
  704. debug:
  705. msg: the value of vgsize is {{ vgsize }}
  706. - name: testing big vgsize value
  707. debug:
  708. msg: the value of vgsize is bigger than 5
  709. when: vgsize | int > 5
  710. - name: testing small vgsize value
  711. debug:
  712. msg: the value of vgsize is smaller than 5
  713. when: vgsize | int <= 5
  714.  
  715. 4. Run this playbook, you'll notice it is skipping and ignoring some tasks, but doesn't fail anywhere, which means that this playbook although absolutely not perfect is useable as example to test the size of the vgfiles volume group later in this exercise.
  716. 5. Now that you've tested the most complex part of the assignment, you can start writing the rest of the playbook. As this playbook has quite a few tasks to accomplish, it may be smart to define the rough structure, and ensure that all elements that are needed later are at least documented, so that you can later work out the details. So let's start with the first part, where the play header is defined, as well as the rough structure. This is the part where you still have the global overview of all the tasks in this requirement, so you need to make sure you won't forget about them later - which is a real risk if you've been into details too much for too long.
  717.  
  718. ---
  719. - name: set up hosts that have an sdb device
  720. hosts: all
  721. tasks:
  722. - name: getting out with a nice failure message if there is no second disk
  723. # fail:
  724. debug:
  725. msg: write a nice failure message and a when test here
  726. # when: something
  727. - name: create a partition
  728. #parted
  729. debug:
  730. msg: creating the partition
  731. - name: create a volume group
  732. #lvg:
  733. debug:
  734. msg: creating the volume group
  735. - name: get the vg size and store it in a variable
  736. #set_fact:
  737. debug:
  738. msg: storing variable as an integer
  739. - name: create an LVM on big volume groups
  740. #lvol:
  741. debug:
  742. msg: use when statement to create 6g lvol if vsize > 5
  743. - name: create an LVM on small volume groups
  744. #lvol:
  745. debug:
  746. msg: use when statement to create 3g lvol if vsize <= 5
  747. - name: formatting the XFS filesystem
  748. # filesystem
  749. debug:
  750. msg: creating the filesystem
  751. - name: mounting /dev/vgfiles/lvfiles
  752. # mount:
  753. debug:
  754. msg: mounting the volume
  755.  
  756. 6. The advantage of a generic structure like the one you've just defined, is that you can run a test at any moment. Now it's time to fill it in. Let's start with the play header and the check if /dev/sdb is present on the managed system:
  757.  
  758. ---
  759. - name: setup up hosts that have an sdb device
  760. hosts: all
  761. tasks:
  762. - name: getting out with a nice failure message if there is no second disk
  763. fail:
  764. msg: there is no second disk
  765. when: ansible_facts['devices']['sdb'] is not defined
  766.  
  767. 7. At this point I'd recommend you run a test to see that the playbook really is going to skip all hosts that don't have a second disk device. Use ansible-playbook exercise153.yaml to do so and observe that you see a lot of skipping messages in the output.
  768. 8. If all is well so far, you can continue to create the partition, and let's do the logical volume group as well. Here are the tasks you need to enter. Notice that no size is specified at any point, which means that the partition as well as the VG will be allowed to grow up to the maximum size:
  769.  
  770. - name: create a partition
  771. parted:
  772. device: /dev/sdb
  773. number: 1
  774. state: present
  775. - name: create a volume group
  776. lvg:
  777. pvs: /dev/sdb1
  778. vg: vgfiles
  779.  
  780. 9. At this point you can insert the part where you are going to save the volume group size into a variable, which can be used in the when statement that is going to occur in one of the next tasks. Also, because it's good to check a lot while you are writing a complex playbook, let's use the debug module to verify the results:
  781.  
  782. - name: get vg size and convert to integer in new variable
  783. set_fact:
  784. vgsize: "{{ ansible_facts['lvm']['vgs']['vgfiles']['size_g'] | int }}"
  785. - name: show vgsize value
  786. debug:
  787. var: "{{ vgsize }}"
  788.  
  789. 10. After this important step, it's time to run a test. If you need it, you can find a sample playbook of the state so far as exercise153-step9.yaml in the GitHub repository at https://github.com/sandervanvugt/rhce8-book, but it's obviously much better and recommended to run your own code! So use ansible-playbook exercise153.yaml to verify what you've got so far. Notice that you must make sure to run it on hosts that don't have any configuration yet, if configuration already exists that will most likely give you false positives! So if you want to make sure all is clean, use ansible all -a "dd if=/dev/zero of=/dev/sdb bs=1M count=10" to wipe the /dev/sdb devices on your managed hosts, followed by ansible all -m reboot to also reboot all of them before you're testing. The purpose of all this is that at this point you see the error message that is in listing 15.13. Before moving on to the next step, try to understand what is going wrong.
  790.  
  791. Listing 15.13: Error Message After Exercise 15.3 Step 10
  792. TASK [get vg size and convert to integer in new variable] ******************************
  793. fatal: [ansible2]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'vgfiles'\n\nThe error appears to be in '/home/ansible/rhce8-book/exercise153-step9.yaml': line 18, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n vg: vgfiles\n - name: get vg size and convert to integer in new variable\n ^ here\n"}
  794. fatal: [ansible3]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'vgfiles'\n\nThe error appears to be in '/home/ansible/rhce8-book/exercise153-step9.yaml': line 18, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n vg: vgfiles\n - name: get vg size and convert to integer in new variable\n ^ here\n"}
  795.  
  796. 11. As you can see, the variable that you are trying to use, has no value yet. And that is for the simple reason that fact gathering is required to set the variable, and fact gathering is happening at the beginning of the playbook. So at this point, you'll need to add a task that runs the setup module right after creating the volume group, and then you can try again. In the output you'll have to look at the [show vgsize value] task, that should look all right now, and everything after that can be ignored. See exercise153-step11.yaml in the GitHiub repository if you need the complete example.
  797.  
  798. ...
  799. - name: create a volume group
  800. lvg:
  801. pvs: /dev/sdb1
  802. vg: vgfiles
  803. - name: run the setup module so that we can use updated facts
  804. setup:
  805. - name: get vg size and convert to integer in new variable
  806. set_fact:
  807. vgsize: "{{ ansible_facts['lvm']['vgs']['vgfiles']['size_g'] | int }}"
  808. - name: show vgsize value
  809. debug:
  810. var: "{{ vgsize }}"
  811. ...
  812. 12. Assuming that all went well, you can now add the two conditional tests, where according to the vgsize value the lvol module will be used to create the logical volumes:
  813.  
  814. - name: create an LVM on big volume groups
  815. lvol:
  816. vg: vgfiles
  817. lv: lvfiles
  818. size: 6g
  819. when: vgsize | int > 5
  820. - name: create an LVM on small volume groups
  821. lvol:
  822. vg: vgfiles
  823. lv: lvfiles
  824. size: 3g
  825. when: vgsize | int <=5
  826.  
  827. 13. Next, you can add the tasks to format the volumes with the XFS filesystem, and mount them:
  828.  
  829. - name: formatting the XFS filesystem
  830. filesystem:
  831. dev: /dev/vgfiles/lvfiles
  832. fstype: xfs
  833. - name: mounting /dev/vgfile/lvfiles
  834. mount:
  835. path: /file
  836. state: mounted
  837. src: /dev/vgfiles/lvfiles
  838.  
  839. 14. That's all! The playbook is now ready for use. Run it, using ansible-playbook exercise153.yaml and verify its output.
  840. 15. Use the ad-hoc command ansible ansible2,ansible3 -a "lvs" to show LVM logical volume sizes on the machines with the additional hard drive. You should see that all has worked out well and you are done!
Add Comment
Please, Sign In to add comment