chrisluiz16

Day3 Git

Jul 7th, 2023
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.16 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5. ####---------------------------------- Task 1 --------------------####
  6.  
  7.  
  8.  
  9.  
  10.  
  11. [ec2-user@ip-172-31-35-28 ~]$ touch main.yml variables.yml aws.pem inventory
  12.  
  13.  
  14.  
  15. [ec2-user@ip-172-31-35-28 apache-project]$ cat .gitignore
  16. aws.pem
  17. inventory
  18.  
  19.  
  20. [ec2-user@ip-172-31-35-28 apache-project]$
  21. [ec2-user@ip-172-31-35-28 apache-project]$
  22. [ec2-user@ip-172-31-35-28 apache-project]$
  23. [ec2-user@ip-172-31-35-28 apache-project]$ git init
  24. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  25. On branch master
  26.  
  27. No commits yet
  28.  
  29. Untracked files:
  30. (use "git add <file>..." to include in what will be committed)
  31. .gitignore
  32. main.yml
  33. variables.yml
  34.  
  35. nothing added to commit but untracked files present (use "git add" to track)
  36. [ec2-user@ip-172-31-35-28 apache-project]$
  37.  
  38.  
  39.  
  40.  
  41. #### First Commit #####
  42.  
  43.  
  44. [ec2-user@ip-172-31-35-28 apache-project]$ cat variables.yml
  45. ---
  46.  
  47. packages:
  48. - httpd
  49. - php-fpm
  50.  
  51.  
  52. [ec2-user@ip-172-31-35-28 apache-project]$ cat main.yml
  53. ---
  54.  
  55. - name: "Apache installation"
  56. hosts: amazon
  57. become: true
  58. vars_files:
  59. - variables.yml
  60. tasks:
  61. - name: "Installing the apache packages"
  62. yum:
  63. name: "{{ packages }}"
  64. state: present
  65. - name: "Service restart apache"
  66. service:
  67. name: "{{ item }}"
  68. state: restarted
  69. enabled: true
  70. with_items:
  71. - "{{ packages }}"
  72.  
  73.  
  74. [ec2-user@ip-172-31-35-28 apache-project]$ ansible-playbook -i inventory main.yml --syntax-check
  75.  
  76. playbook: main.yml
  77.  
  78.  
  79. [ec2-user@ip-172-31-35-28 apache-project]$ ansible-playbook -i inventory main.yml
  80.  
  81. PLAY [Apache installation] *********************************************************************************************
  82. TASK [Gathering Facts] *************************************************************************************************ok: [client]
  83.  
  84. TASK [Installing the apache packages] **********************************************************************************changed: [client]
  85.  
  86. TASK [Service restart apache] ******************************************************************************************changed: [client] => (item=httpd)
  87. changed: [client] => (item=php-fpm)
  88.  
  89. PLAY RECAP *************************************************************************************************************
  90. client : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
  91.  
  92.  
  93.  
  94.  
  95.  
  96. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  97. On branch master
  98.  
  99. No commits yet
  100.  
  101. Untracked files:
  102. (use "git add <file>..." to include in what will be committed)
  103. .gitignore
  104. main.yml
  105. variables.yml
  106.  
  107. nothing added to commit but untracked files present (use "git add" to track)
  108. [ec2-user@ip-172-31-35-28 apache-project]$
  109. [ec2-user@ip-172-31-35-28 apache-project]$
  110. [ec2-user@ip-172-31-35-28 apache-project]$ git add .
  111. [ec2-user@ip-172-31-35-28 apache-project]$
  112. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  113. On branch master
  114.  
  115. No commits yet
  116.  
  117. Changes to be committed:
  118. (use "git rm --cached <file>..." to unstage)
  119. new file: .gitignore
  120. new file: main.yml
  121. new file: variables.yml
  122.  
  123. [ec2-user@ip-172-31-35-28 apache-project]$
  124. [ec2-user@ip-172-31-35-28 apache-project]$
  125. [ec2-user@ip-172-31-35-28 apache-project]$
  126. [ec2-user@ip-172-31-35-28 apache-project]$ git commit -m "apache webserver installed and restarted"
  127. [master (root-commit) 49255a4] apache webserver installed and restarted
  128. 3 files changed, 27 insertions(+)
  129. create mode 100644 .gitignore
  130. create mode 100644 main.yml
  131. create mode 100644 variables.yml
  132. [ec2-user@ip-172-31-35-28 apache-project]$
  133. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  134. On branch master
  135. nothing to commit, working tree clean
  136. [ec2-user@ip-172-31-35-28 apache-project]$
  137. [ec2-user@ip-172-31-35-28 apache-project]$ git log
  138. commit 49255a4d4cb2dfc32b628e42b1ad7df33abc8311 (HEAD -> master)
  139. Author: chrisluiz <[email protected]>
  140. Date: Fri Jul 7 15:32:22 2023 +0000
  141.  
  142. apache webserver installed and restarted
  143. [ec2-user@ip-172-31-35-28 apache-project]$
  144.  
  145.  
  146.  
  147.  
  148. #### Second Commit #####
  149.  
  150.  
  151. ---
  152.  
  153. packages:
  154. - httpd
  155. - php-fpm
  156. httpd_owner: apache
  157. httpd_group: apache
  158. [ec2-user@ip-172-31-35-28 apache-project]$
  159. [ec2-user@ip-172-31-35-28 apache-project]$
  160. [ec2-user@ip-172-31-35-28 apache-project]$ cat main.yml
  161. ---
  162.  
  163. - name: "Apache installation"
  164. hosts: amazon
  165. become: true
  166. vars_files:
  167. - variables.yml
  168. tasks:
  169. - name: "Installing the apache packages"
  170. yum:
  171. name: "{{ packages }}"
  172. state: present
  173. - name: "Uploading the test contantents"
  174. copy:
  175. src: "{{ item }"
  176. dest: /var/www/html
  177. owner: "{{ httpd_owner }}"
  178. group: "{{ httpd_group }}"
  179. - name: "Service restart apache"
  180. service:
  181. name: "{{ item }}"
  182. state: restarted
  183. enabled: true
  184. with_items:
  185. - "{{ packages }}"
  186.  
  187.  
  188.  
  189. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  190. On branch master
  191. Changes not staged for commit:
  192. (use "git add <file>..." to update what will be committed)
  193. (use "git restore <file>..." to discard changes in working directory)
  194. modified: main.yml
  195. modified: variables.yml
  196.  
  197. Untracked files:
  198. (use "git add <file>..." to include in what will be committed)
  199. test.html
  200. test.php
  201.  
  202.  
  203.  
  204. [ec2-user@ip-172-31-35-28 apache-project]$ ansible-playbook -i inventory main.yml
  205.  
  206. PLAY [Apache installation] *******************************************************************************************
  207.  
  208. TASK [Gathering Facts] ***********************************************************************************************
  209. ok: [client]
  210.  
  211. TASK [Installing the apache packages] ********************************************************************************
  212. ok: [client]
  213.  
  214. TASK [Uploading the test contantents] ********************************************************************************
  215. changed: [client] => (item=test.php)
  216. changed: [client] => (item=test.html)
  217.  
  218. TASK [Service restart apache] ****************************************************************************************
  219. changed: [client] => (item=httpd)
  220. changed: [client] => (item=php-fpm)
  221.  
  222. PLAY RECAP ***********************************************************************************************************
  223. client : ok=4 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
  224.  
  225.  
  226.  
  227. [ec2-user@ip-172-31-35-28 apache-project]$ git add .
  228. [ec2-user@ip-172-31-35-28 apache-project]$
  229. [ec2-user@ip-172-31-35-28 apache-project]$
  230. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  231. On branch master
  232. Changes to be committed:
  233. (use "git restore --staged <file>..." to unstage)
  234. modified: main.yml
  235. new file: test.html
  236. new file: test.php
  237. modified: variables.yml
  238.  
  239.  
  240. [ec2-user@ip-172-31-35-28 apache-project]$ git log
  241. commit 918b3a1d59cf3bfdd1e22a3e4633475d807a7f88 (HEAD -> master)
  242. Author: chrisluiz <[email protected]>
  243. Date: Fri Jul 7 15:43:19 2023 +0000
  244.  
  245. php support added
  246.  
  247. commit 49255a4d4cb2dfc32b628e42b1ad7df33abc8311
  248. Author: chrisluiz <[email protected]>
  249. Date: Fri Jul 7 15:32:22 2023 +0000
  250.  
  251. apache webserver installed and restarted
  252. [ec2-user@ip-172-31-35-28 apache-project]$
  253. [ec2-user@ip-172-31-35-28 apache-project]$ git cat-file -p 918b3a1d59cf3bfdd1e22a3e4633475d807a7f88
  254. tree ae05bf53a23a181f464eb49111aae03de92ec853
  255. parent 49255a4d4cb2dfc32b628e42b1ad7df33abc8311
  256. author chrisluiz <[email protected]> 1688744599 +0000
  257. committer chrisluiz <[email protected]> 1688744599 +0000
  258.  
  259. php support added
  260.  
  261.  
  262.  
  263.  
  264. ### Third Commit ###
  265.  
  266. [ec2-user@ip-172-31-35-28 apache-project]$ ansible -i inventory amazon -b -m fetch -a "src=/etc/httpd/conf/httpd.conf dest=./ flat=true"
  267. client | CHANGED => {
  268. "changed": true,
  269. "checksum": "fcfc3261dbe43ccf2a521213571849cf36e277c0",
  270. "dest": "/home/ec2-user/apache-project/httpd.conf",
  271. "md5sum": "abc2d98f55602c033626f046ce72fffc",
  272. "remote_checksum": "fcfc3261dbe43ccf2a521213571849cf36e277c0",
  273. "remote_md5sum": null
  274. }
  275.  
  276.  
  277. [ec2-user@ip-172-31-35-28 apache-project]$ cat variables.yml
  278. ---
  279.  
  280. packages:
  281. - httpd
  282. - php-fpm
  283. httpd_owner: apache
  284. httpd_group: apache
  285. httpd_port: 8080
  286. [ec2-user@ip-172-31-35-28 apache-project]$
  287. [ec2-user@ip-172-31-35-28 apache-project]$
  288. [ec2-user@ip-172-31-35-28 apache-project]$ cat main.yml
  289. ---
  290.  
  291. - name: "Apache installation"
  292. hosts: amazon
  293. become: true
  294. vars_files:
  295. - variables.yml
  296. tasks:
  297. - name: "Installing the apache packages"
  298. yum:
  299. name: "{{ packages }}"
  300. state: present
  301. - name: "Copying the httpd_conf.tmpl"
  302. copy:
  303. src: httpd.conf.tmpl
  304. dest: /etc/httpd/conf/httpd.conf
  305. notify:
  306. - restart-httpd
  307. - name: "Uploading the test contantents"
  308. copy:
  309. src: "{{ item }}"
  310. dest: /var/www/html/
  311. owner: "{{ httpd_owner }}"
  312. group: "{{ httpd_group }}"
  313. with_items:
  314. - test.php
  315. - test.html
  316. notify:
  317. - restart-php
  318.  
  319. handlers:
  320. - name: "restart-php"
  321. service:
  322. name: php-fpm
  323. state: restarted
  324. enabled: true
  325. - name: "restart-httpd"
  326. service:
  327. name: httpd
  328. state: restarted
  329. enabled: true
  330.  
  331. ec2-user@ip-172-31-35-28 apache-project]$ ansible-playbook -i inventory main.yml
  332.  
  333. PLAY [Apache installation] *******************************************************************************************
  334.  
  335. TASK [Gathering Facts] ***********************************************************************************************
  336. ok: [client]
  337.  
  338. TASK [Installing the apache packages] ********************************************************************************
  339. ok: [client]
  340.  
  341. TASK [Copying the httpd_conf.tmpl] ***********************************************************************************
  342. changed: [client]
  343.  
  344. TASK [Uploading the test contantents] ********************************************************************************
  345. ok: [client] => (item=test.php)
  346. ok: [client] => (item=test.html)
  347.  
  348. RUNNING HANDLER [restart-httpd] **************************************************************************************
  349. changed: [client]
  350.  
  351. PLAY RECAP ***********************************************************************************************************
  352. client : ok=5 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
  353.  
  354.  
  355.  
  356. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  357. On branch master
  358. Changes not staged for commit:
  359. (use "git add <file>..." to update what will be committed)
  360. (use "git restore <file>..." to discard changes in working directory)
  361. modified: main.yml
  362. modified: variables.yml
  363.  
  364. Untracked files:
  365. (use "git add <file>..." to include in what will be committed)
  366. httpd.conf.tmpl
  367.  
  368. no changes added to commit (use "git add" and/or "git commit -a")
  369. [ec2-user@ip-172-31-35-28 apache-project]$
  370. [ec2-user@ip-172-31-35-28 apache-project]$
  371. [ec2-user@ip-172-31-35-28 apache-project]$ git add .
  372. [ec2-user@ip-172-31-35-28 apache-project]$
  373. [ec2-user@ip-172-31-35-28 apache-project]$ git commit -m "Adding httpd.conf.tmpl"
  374. [master 14e31ef] Adding httpd.conf.tmpl
  375. 3 files changed, 381 insertions(+), 6 deletions(-)
  376. create mode 100644 httpd.conf.tmpl
  377. [ec2-user@ip-172-31-35-28 apache-project]$
  378. [ec2-user@ip-172-31-35-28 apache-project]$
  379. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  380. On branch master
  381. nothing to commit, working tree clean
  382. [ec2-user@ip-172-31-35-28 apache-project]$
  383. [ec2-user@ip-172-31-35-28 apache-project]$ git log
  384. commit 14e31efa9fc6df1eb1850b8c1fbc7c089cd42708 (HEAD -> master)
  385. Author: chrisluiz <[email protected]>
  386. Date: Fri Jul 7 15:58:51 2023 +0000
  387.  
  388. Adding httpd.conf.tmpl
  389.  
  390. commit 918b3a1d59cf3bfdd1e22a3e4633475d807a7f88
  391. Author: chrisluiz <[email protected]>
  392. Date: Fri Jul 7 15:43:19 2023 +0000
  393.  
  394. php support added
  395.  
  396. commit 49255a4d4cb2dfc32b628e42b1ad7df33abc8311
  397. Author: chrisluiz <[email protected]>
  398. Date: Fri Jul 7 15:32:22 2023 +0000
  399.  
  400. apache webserver installed and restarted
  401. [ec2-user@ip-172-31-35-28 apache-project]$
  402.  
  403.  
  404. #### Foourth commit ####
  405.  
  406.  
  407. [ec2-user@ip-172-31-35-28 apache-project]$ cat main.yml
  408. ---
  409.  
  410. - name: "Apache installation"
  411. hosts: amazon
  412. become: true
  413. vars_files:
  414. - variables.yml
  415. tasks:
  416. - name: "Installing the apache packages"
  417. yum:
  418. name: "{{ packages }}"
  419. state: present
  420. - name: "Copying the httpd_conf.tmpl"
  421. template:
  422. src: httpd.conf.tmpl
  423. dest: /etc/httpd/conf/httpd.conf
  424. notify:
  425. - restart-httpd
  426. - name: "Copying the virtualhost.tmpl"
  427. template:
  428. src: virtualhost.conf.tmpl
  429. dest: /etc/httpd/conf.d/default.conf
  430. notify:
  431. - restart-httpd
  432. - name: "Uploading the test contantents"
  433. copy:
  434. src: "{{ item }}"
  435. dest: /var/www/html/
  436. owner: "{{ httpd_owner }}"
  437. group: "{{ httpd_group }}"
  438. with_items:
  439. - test.php
  440. - test.html
  441. notify:
  442. - restart-php
  443.  
  444. handlers:
  445. - name: "restart-php"
  446. service:
  447. name: php-fpm
  448. state: restarted
  449. enabled: true
  450. - name: "restart-httpd"
  451. service:
  452. name: httpd
  453. state: restarted
  454. enabled: true
  455.  
  456. [ec2-user@ip-172-31-35-28 apache-project]$ ansible-playbook -i inventory main.yml
  457.  
  458. PLAY [Apache installation] *******************************************************************************************
  459.  
  460. TASK [Gathering Facts] ***********************************************************************************************
  461. ok: [client]
  462.  
  463. TASK [Installing the apache packages] ********************************************************************************
  464. ok: [client]
  465.  
  466. TASK [Copying the httpd_conf.tmpl] ***********************************************************************************
  467. ok: [client]
  468.  
  469. TASK [Copying the virtualhost.tmpl] **********************************************************************************
  470. changed: [client]
  471.  
  472. TASK [Uploading the test contantents] ********************************************************************************
  473. ok: [client] => (item=test.php)
  474. ok: [client] => (item=test.html)
  475.  
  476. RUNNING HANDLER [restart-httpd] **************************************************************************************
  477. changed: [client]
  478.  
  479. PLAY RECAP ***********************************************************************************************************
  480. client : ok=6 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
  481.  
  482.  
  483.  
  484. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  485. On branch master
  486. Changes not staged for commit:
  487. (use "git add <file>..." to update what will be committed)
  488. (use "git restore <file>..." to discard changes in working directory)
  489. modified: main.yml
  490. modified: variables.yml
  491.  
  492. Untracked files:
  493. (use "git add <file>..." to include in what will be committed)
  494. virtualhost.conf.tmpl
  495.  
  496. no changes added to commit (use "git add" and/or "git commit -a")
  497. [ec2-user@ip-172-31-35-28 apache-project]$
  498. [ec2-user@ip-172-31-35-28 apache-project]$
  499. [ec2-user@ip-172-31-35-28 apache-project]$
  500. [ec2-user@ip-172-31-35-28 apache-project]$
  501. [ec2-user@ip-172-31-35-28 apache-project]$ git add .
  502. [ec2-user@ip-172-31-35-28 apache-project]$
  503. [ec2-user@ip-172-31-35-28 apache-project]$
  504. [ec2-user@ip-172-31-35-28 apache-project]$ git commit -m "Virtaulhost port 80 conf added"
  505. [master 71f5b74] Virtaulhost port 80 conf added
  506. 3 files changed, 18 insertions(+)
  507. create mode 100644 virtualhost.conf.tmpl
  508. [ec2-user@ip-172-31-35-28 apache-project]$
  509. [ec2-user@ip-172-31-35-28 apache-project]$
  510. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  511. On branch master
  512. nothing to commit, working tree clean
  513. [ec2-user@ip-172-31-35-28 apache-project]$
  514. [ec2-user@ip-172-31-35-28 apache-project]$ git log
  515. commit 71f5b7457e603c0009f4c7adf54d684a2eb82ff1 (HEAD -> master)
  516. Author: chrisluiz <[email protected]>
  517. Date: Fri Jul 7 16:14:21 2023 +0000
  518.  
  519. Virtaulhost port 80 conf added
  520.  
  521. commit 14e31efa9fc6df1eb1850b8c1fbc7c089cd42708
  522. Author: chrisluiz <[email protected]>
  523. Date: Fri Jul 7 15:58:51 2023 +0000
  524.  
  525. Adding httpd.conf.tmpl
  526.  
  527. commit 918b3a1d59cf3bfdd1e22a3e4633475d807a7f88
  528. Author: chrisluiz <[email protected]>
  529. Date: Fri Jul 7 15:43:19 2023 +0000
  530.  
  531. php support added
  532.  
  533. commit 49255a4d4cb2dfc32b628e42b1ad7df33abc8311
  534. Author: chrisluiz <[email protected]>
  535. Date: Fri Jul 7 15:32:22 2023 +0000
  536.  
  537. apache webserver installed and restarted
  538.  
  539.  
  540.  
  541.  
  542. #### Git ammending the latest header ####
  543.  
  544. [ec2-user@ip-172-31-35-28 apache-project]$ git commit --amend -m "virtualhostconf.tmpl 8080 added"
  545. [master 9bb91b7] virtualhostconf.tmpl 8080 added
  546. Date: Fri Jul 7 16:14:21 2023 +0000
  547. 3 files changed, 18 insertions(+)
  548. create mode 100644 virtualhost.conf.tmpl
  549. [ec2-user@ip-172-31-35-28 apache-project]$
  550. [ec2-user@ip-172-31-35-28 apache-project]$
  551. [ec2-user@ip-172-31-35-28 apache-project]$ git log
  552. commit 9bb91b78bfd4e4ba6b7720e69fc671ba025f75e5 (HEAD -> master)
  553. Author: chrisluiz <[email protected]>
  554. Date: Fri Jul 7 16:14:21 2023 +0000
  555.  
  556. virtualhostconf.tmpl 8080 added
  557.  
  558. commit 14e31efa9fc6df1eb1850b8c1fbc7c089cd42708
  559. Author: chrisluiz <[email protected]>
  560. Date: Fri Jul 7 15:58:51 2023 +0000
  561.  
  562. Adding httpd.conf.tmpl
  563.  
  564. commit 918b3a1d59cf3bfdd1e22a3e4633475d807a7f88
  565. Author: chrisluiz <[email protected]>
  566. Date: Fri Jul 7 15:43:19 2023 +0000
  567.  
  568. php support added
  569.  
  570. commit 49255a4d4cb2dfc32b628e42b1ad7df33abc8311
  571. Author: chrisluiz <[email protected]>
  572. Date: Fri Jul 7 15:32:22 2023 +0000
  573.  
  574. apache webserver installed and restarted
  575. [ec2-user@ip-172-31-35-28 apache-project]$
  576.  
  577.  
  578.  
  579. #### Adding new file ####
  580.  
  581. [ec2-user@ip-172-31-35-28 apache-project]$ echo "This is a new line">>newline.txt
  582. [ec2-user@ip-172-31-35-28 apache-project]$
  583. [ec2-user@ip-172-31-35-28 apache-project]$
  584. [ec2-user@ip-172-31-35-28 apache-project]$ git ls-files -s
  585. 100644 7e766e72a428da4d2daa930736890495bcd79070 0 .gitignore
  586. 100644 41c670e5de1326c3d97265aaa1237659b2463e0b 0 httpd.conf.tmpl
  587. 100644 8c6d46bc6ab48087780d16aa2f7dff191737bd1f 0 main.yml
  588. 100644 e308298a79ff1b247125f7cf1b9a7b6f03a2323d 0 test.html
  589. 100644 e8d48bac9f33bdc446bc6bc947c78187b46761dd 0 test.php
  590. 100644 6e6f6b07e9b0ea6f2609d4f9f569094e513414ed 0 variables.yml
  591. 100644 fadbf3dbd16812dea171216cee18a886ddd1b4d1 0 virtualhost.conf.tmpl
  592. [ec2-user@ip-172-31-35-28 apache-project]$
  593. [ec2-user@ip-172-31-35-28 apache-project]$
  594. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  595. On branch master
  596. Untracked files:
  597. (use "git add <file>..." to include in what will be committed)
  598. newline.txt
  599.  
  600. nothing added to commit but untracked files present (use "git add" to track)
  601. [ec2-user@ip-172-31-35-28 apache-project]$
  602. [ec2-user@ip-172-31-35-28 apache-project]$ git add newline.txt
  603. [ec2-user@ip-172-31-35-28 apache-project]$
  604. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  605. On branch master
  606. nothing to commit, working tree clean
  607. [ec2-user@ip-172-31-35-28 apache-project]$
  608. [ec2-user@ip-172-31-35-28 apache-project]$ git commit --amend --no-edit
  609. [master cc4555c] virtualhostconf.tmpl 8080 added
  610. Date: Fri Jul 7 16:14:21 2023 +0000
  611. 4 files changed, 19 insertions(+)
  612. create mode 100644 newline.txt
  613. create mode 100644 virtualhost.conf.tmpl
  614. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  615. On branch master
  616. nothing to commit, working tree clean
  617. [ec2-user@ip-172-31-35-28 apache-project]$ git log
  618. commit cc4555c154a80f89136b26196076e3250cccd319 (HEAD -> master)
  619. Author: chrisluiz <[email protected]>
  620. Date: Fri Jul 7 16:14:21 2023 +0000
  621.  
  622. virtualhostconf.tmpl 8080 added
  623.  
  624. commit 14e31efa9fc6df1eb1850b8c1fbc7c089cd42708
  625. Author: chrisluiz <[email protected]>
  626. Date: Fri Jul 7 15:58:51 2023 +0000
  627.  
  628. Adding httpd.conf.tmpl
  629.  
  630. commit 918b3a1d59cf3bfdd1e22a3e4633475d807a7f88
  631. Author: chrisluiz <[email protected]>
  632. Date: Fri Jul 7 15:43:19 2023 +0000
  633.  
  634. php support added
  635.  
  636. commit 49255a4d4cb2dfc32b628e42b1ad7df33abc8311
  637. Author: chrisluiz <[email protected]>
  638. Date: Fri Jul 7 15:32:22 2023 +0000
  639.  
  640. apache webserver installed and restarted
  641. [ec2-user@ip-172-31-35-28 apache-project]$ git ls-files -s
  642. 100644 7e766e72a428da4d2daa930736890495bcd79070 0 .gitignore
  643. 100644 41c670e5de1326c3d97265aaa1237659b2463e0b 0 httpd.conf.tmpl
  644. 100644 8c6d46bc6ab48087780d16aa2f7dff191737bd1f 0 main.yml
  645. 100644 1ac99b8906e05692417c5b96a0829f7d6b1d607f 0 newline.txt
  646. 100644 e308298a79ff1b247125f7cf1b9a7b6f03a2323d 0 test.html
  647. 100644 e8d48bac9f33bdc446bc6bc947c78187b46761dd 0 test.php
  648. 100644 6e6f6b07e9b0ea6f2609d4f9f569094e513414ed 0 variables.yml
  649. 100644 fadbf3dbd16812dea171216cee18a886ddd1b4d1 0 virtualhost.conf.tmpl
  650.  
  651.  
  652. #### Creating a new branch and 5th commit #####
  653.  
  654.  
  655. [ec2-user@ip-172-31-35-28 apache-project]$ git branch mariadb
  656. [ec2-user@ip-172-31-35-28 apache-project]$ git log
  657. commit cc4555c154a80f89136b26196076e3250cccd319 (HEAD -> master, mariadb)
  658. Author: chrisluiz <[email protected]>
  659. Date: Fri Jul 7 16:14:21 2023 +0000
  660.  
  661. virtualhostconf.tmpl 8080 added
  662.  
  663. commit 14e31efa9fc6df1eb1850b8c1fbc7c089cd42708
  664. Author: chrisluiz <[email protected]>
  665. Date: Fri Jul 7 15:58:51 2023 +0000
  666.  
  667. Adding httpd.conf.tmpl
  668.  
  669. commit 918b3a1d59cf3bfdd1e22a3e4633475d807a7f88
  670. Author: chrisluiz <[email protected]>
  671. Date: Fri Jul 7 15:43:19 2023 +0000
  672.  
  673. php support added
  674.  
  675. commit 49255a4d4cb2dfc32b628e42b1ad7df33abc8311
  676. Author: chrisluiz <[email protected]>
  677. Date: Fri Jul 7 15:32:22 2023 +0000
  678.  
  679. apache webserver installed and restarted
  680. [ec2-user@ip-172-31-35-28 apache-project]$
  681.  
  682.  
  683. [ec2-user@ip-172-31-35-28 apache-project]$ git switch mariadb
  684. M main.yml
  685. Switched to branch 'mariadb'
  686. [ec2-user@ip-172-31-35-28 apache-project]$
  687. [ec2-user@ip-172-31-35-28 apache-project]$
  688. [ec2-user@ip-172-31-35-28 apache-project]$
  689. [ec2-user@ip-172-31-35-28 apache-project]$ git log
  690. commit cc4555c154a80f89136b26196076e3250cccd319 (HEAD -> mariadb, master)
  691. Author: chrisluiz <[email protected]>
  692. Date: Fri Jul 7 16:14:21 2023 +0000
  693.  
  694. virtualhostconf.tmpl 8080 added
  695.  
  696. commit 14e31efa9fc6df1eb1850b8c1fbc7c089cd42708
  697. Author: chrisluiz <[email protected]>
  698. Date: Fri Jul 7 15:58:51 2023 +0000
  699.  
  700. Adding httpd.conf.tmpl
  701.  
  702. commit 918b3a1d59cf3bfdd1e22a3e4633475d807a7f88
  703. Author: chrisluiz <[email protected]>
  704. Date: Fri Jul 7 15:43:19 2023 +0000
  705.  
  706. php support added
  707.  
  708. commit 49255a4d4cb2dfc32b628e42b1ad7df33abc8311
  709. Author: chrisluiz <[email protected]>
  710. Date: Fri Jul 7 15:32:22 2023 +0000
  711.  
  712. apache webserver installed and restarted
  713.  
  714. [ec2-user@ip-172-31-35-28 apache-project]$ cat .git/refs/heads/mariadb
  715. cc4555c154a80f89136b26196076e3250cccd319
  716.  
  717.  
  718. ---
  719.  
  720. - name: "Apache installation"
  721. hosts: amazon
  722. become: true
  723. vars_files:
  724. - variables.yml
  725. tasks:
  726. - name: "Installing the apache packages"
  727. yum:
  728. name: "{{ packages }}"
  729. state: present
  730. - name: "Copying the httpd_conf.tmpl"
  731. template:
  732. src: httpd.conf.tmpl
  733. dest: /etc/httpd/conf/httpd.conf
  734. notify:
  735. - restart-httpd
  736. - name: "Copying the virtualhost.tmpl"
  737. template:
  738. src: virtualhost.conf.tmpl
  739. dest: /etc/httpd/conf.d/default.conf
  740. notify:
  741. - restart-httpd
  742. - name: "Uploading the test contantents"
  743. copy:
  744. src: "{{ item }}"
  745. dest: /var/www/html/
  746. owner: "{{ httpd_owner }}"
  747. group: "{{ httpd_group }}"
  748. with_items:
  749. - test.php
  750. - test.html
  751. notify:
  752. - restart-php
  753. - name: "Installing mariadb"
  754. yum:
  755. name: mariadb105-server
  756. state: present
  757.  
  758. handlers:
  759. - name: "restart-php"
  760. service:
  761. name: php-fpm
  762. state: restarted
  763. enabled: true
  764. - name: "restart-httpd"
  765. service:
  766. name: httpd
  767. state: restarted
  768. enabled: true
  769.  
  770.  
  771.  
  772.  
  773. #### Inspecting the branch #####
  774.  
  775. [ec2-user@ip-172-31-35-28 apache-project]$ git add .
  776. [ec2-user@ip-172-31-35-28 apache-project]$
  777. [ec2-user@ip-172-31-35-28 apache-project]$
  778. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  779. On branch mariadb
  780. Changes to be committed:
  781. (use "git restore --staged <file>..." to unstage)
  782. modified: main.yml
  783.  
  784. [ec2-user@ip-172-31-35-28 apache-project]$
  785. [ec2-user@ip-172-31-35-28 apache-project]$
  786. [ec2-user@ip-172-31-35-28 apache-project]$ git commit -m "Mariadb Installation succefull"
  787. [mariadb 1f522f0] Mariadb Installation succefull
  788. 1 file changed, 5 insertions(+)
  789. [ec2-user@ip-172-31-35-28 apache-project]$
  790. [ec2-user@ip-172-31-35-28 apache-project]$
  791. [ec2-user@ip-172-31-35-28 apache-project]$ git log
  792. commit 1f522f00414b404c1aae2e982b244d7f1e563799 (HEAD -> mariadb)
  793. Author: chrisluiz <[email protected]>
  794. Date: Fri Jul 7 16:29:52 2023 +0000
  795.  
  796. Mariadb Installation succefull
  797.  
  798. commit cc4555c154a80f89136b26196076e3250cccd319 (master)
  799. Author: chrisluiz <[email protected]>
  800. Date: Fri Jul 7 16:14:21 2023 +0000
  801.  
  802. virtualhostconf.tmpl 8080 added
  803.  
  804. commit 14e31efa9fc6df1eb1850b8c1fbc7c089cd42708
  805. Author: chrisluiz <[email protected]>
  806. Date: Fri Jul 7 15:58:51 2023 +0000
  807.  
  808. Adding httpd.conf.tmpl
  809.  
  810. commit 918b3a1d59cf3bfdd1e22a3e4633475d807a7f88
  811. Author: chrisluiz <[email protected]>
  812. Date: Fri Jul 7 15:43:19 2023 +0000
  813.  
  814. php support added
  815.  
  816. commit 49255a4d4cb2dfc32b628e42b1ad7df33abc8311
  817. Author: chrisluiz <[email protected]>
  818. Date: Fri Jul 7 15:32:22 2023 +0000
  819.  
  820. apache webserver installed and restarted
  821. [ec2-user@ip-172-31-35-28 apache-project]$
  822.  
  823.  
  824. [ec2-user@ip-172-31-35-28 apache-project]$ git cat-file -p 1f522f00414b404c1aae2e982b244d7f1e563799
  825. tree 6e516e3a43228c87bbc7b6f38906e3a7dd409aea
  826. parent cc4555c154a80f89136b26196076e3250cccd319
  827. author chrisluiz <[email protected]> 1688747392 +0000
  828. committer chrisluiz <[email protected]> 1688747392 +0000
  829.  
  830. Mariadb Installation succefull
  831. [ec2-user@ip-172-31-35-28 apache-project]$ git cat-file -p cc4555c154a80f89136b26196076e3250cccd319
  832. tree 15bb027b7332f0828d115e8d7dfc69320519a493
  833. parent 14e31efa9fc6df1eb1850b8c1fbc7c089cd42708
  834. author chrisluiz <[email protected]> 1688746461 +0000
  835. committer chrisluiz <[email protected]> 1688746949 +0000
  836.  
  837. virtualhostconf.tmpl 8080 added
  838. [ec2-user@ip-172-31-35-28 apache-project]$ git cat-file -p 15bb027b7332f0828d115e8d7dfc69320519a493
  839. 100644 blob 7e766e72a428da4d2daa930736890495bcd79070 .gitignore
  840. 100644 blob 41c670e5de1326c3d97265aaa1237659b2463e0b httpd.conf.tmpl
  841. 100644 blob 8c6d46bc6ab48087780d16aa2f7dff191737bd1f main.yml
  842. 100644 blob 1ac99b8906e05692417c5b96a0829f7d6b1d607f newline.txt
  843. 100644 blob e308298a79ff1b247125f7cf1b9a7b6f03a2323d test.html
  844. 100644 blob e8d48bac9f33bdc446bc6bc947c78187b46761dd test.php
  845. 100644 blob 6e6f6b07e9b0ea6f2609d4f9f569094e513414ed variables.yml
  846. 100644 blob fadbf3dbd16812dea171216cee18a886ddd1b4d1 virtualhost.conf.tmpl
  847. [ec2-user@ip-172-31-35-28 apache-project]$ git cat-file -p 8c6d46bc6ab48087780d16aa2f7dff191737bd1f
  848. ---
  849.  
  850. - name: "Apache installation"
  851. hosts: amazon
  852. become: true
  853. vars_files:
  854. - variables.yml
  855. tasks:
  856. - name: "Installing the apache packages"
  857. yum:
  858. name: "{{ packages }}"
  859. state: present
  860. - name: "Copying the httpd_conf.tmpl"
  861. template:
  862. src: httpd.conf.tmpl
  863. dest: /etc/httpd/conf/httpd.conf
  864. notify:
  865. - restart-httpd
  866. - name: "Copying the virtualhost.tmpl"
  867. template:
  868. src: virtualhost.conf.tmpl
  869. dest: /etc/httpd/conf.d/default.conf
  870. notify:
  871. - restart-httpd
  872. - name: "Uploading the test contantents"
  873. copy:
  874. src: "{{ item }}"
  875. dest: /var/www/html/
  876. owner: "{{ httpd_owner }}"
  877. group: "{{ httpd_group }}"
  878. with_items:
  879. - test.php
  880. - test.html
  881. notify:
  882. - restart-php
  883.  
  884. handlers:
  885. - name: "restart-php"
  886. service:
  887. name: php-fpm
  888. state: restarted
  889. enabled: true
  890. - name: "restart-httpd"
  891. service:
  892. name: httpd
  893. state: restarted
  894. enabled: true
  895.  
  896.  
  897.  
  898. #### 6th commit in mariadb branch ####
  899.  
  900. [ec2-user@ip-172-31-35-28 apache-project]$ cat main.yml
  901. ---
  902.  
  903. - name: "Apache installation"
  904. hosts: amazon
  905. become: true
  906. vars_files:
  907. - variables.yml
  908. tasks:
  909. - name: "Installing the apache packages"
  910. yum:
  911. name: "{{ packages }}"
  912. state: present
  913. - name: "Copying the httpd_conf.tmpl"
  914. template:
  915. src: httpd.conf.tmpl
  916. dest: /etc/httpd/conf/httpd.conf
  917. notify:
  918. - restart-httpd
  919. - name: "Copying the virtualhost.tmpl"
  920. template:
  921. src: virtualhost.conf.tmpl
  922. dest: /etc/httpd/conf.d/default.conf
  923. notify:
  924. - restart-httpd
  925. - name: "Uploading the test contantents"
  926. copy:
  927. src: "{{ item }}"
  928. dest: /var/www/html/
  929. owner: "{{ httpd_owner }}"
  930. group: "{{ httpd_group }}"
  931. with_items:
  932. - test.php
  933. - test.html
  934. notify:
  935. - restart-php
  936. - name: "Installing mariadb"
  937. yum:
  938. name: mariadb105-server
  939. state: present
  940. - name: "Service Start/emnable mariadb"
  941. service:
  942. name: mariadb
  943. state: started
  944. enabled: true
  945. - name: "Installing mysql pip required modules"
  946. pip:
  947. name: PyMySQL
  948. - name: "Changing mysql root password"
  949. community.mysql.mysql_user:
  950. login_user: root
  951. login_password: ""
  952. login_unix_socket: /var/lib/mysql/mysql.sock
  953. name: root
  954. password: "{{ mysql_passwd }}"
  955.  
  956. handlers:
  957. - name: "restart-php"
  958. service:
  959. name: php-fpm
  960. state: restarted
  961. enabled: true
  962. - name: "restart-httpd"
  963. service:
  964. name: httpd
  965. state: restarted
  966. enabled: true
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  974. On branch mariadb
  975. Changes not staged for commit:
  976. (use "git add <file>..." to update what will be committed)
  977. (use "git restore <file>..." to discard changes in working directory)
  978. modified: main.yml
  979. modified: variables.yml
  980.  
  981. [ec2-user@ip-172-31-35-28 apache-project]$ git add .
  982. [ec2-user@ip-172-31-35-28 apache-project]$
  983. [ec2-user@ip-172-31-35-28 apache-project]$
  984. [ec2-user@ip-172-31-35-28 apache-project]$ git status
  985. On branch mariadb
  986. Changes to be committed:
  987. (use "git restore --staged <file>..." to unstage)
  988. modified: main.yml
  989. modified: variables.yml
  990.  
  991. [ec2-user@ip-172-31-35-28 apache-project]$
  992. [ec2-user@ip-172-31-35-28 apache-project]$
  993. [ec2-user@ip-172-31-35-28 apache-project]$ git commit -m "Mysql root passwd changed"
  994. [mariadb 17b7a35] Mysql root passwd changed
  995. 2 files changed, 17 insertions(+)
  996. [ec2-user@ip-172-31-35-28 apache-project]$
  997. [ec2-user@ip-172-31-35-28 apache-project]$
  998. [ec2-user@ip-172-31-35-28 apache-project]$ git log
  999. commit 17b7a35f8ba62daa350eb1d0651180312e70be2f (HEAD -> mariadb)
  1000. Author: chrisluiz <[email protected]>
  1001. Date: Fri Jul 7 16:40:33 2023 +0000
  1002.  
  1003. Mysql root passwd changed
  1004.  
  1005. commit 1f522f00414b404c1aae2e982b244d7f1e563799
  1006. Author: chrisluiz <[email protected]>
  1007. Date: Fri Jul 7 16:29:52 2023 +0000
  1008.  
  1009. Mariadb Installation succefull
  1010.  
  1011. commit cc4555c154a80f89136b26196076e3250cccd319 (master)
  1012. Author: chrisluiz <[email protected]>
  1013. Date: Fri Jul 7 16:14:21 2023 +0000
  1014.  
  1015. virtualhostconf.tmpl 8080 added
  1016.  
  1017. commit 14e31efa9fc6df1eb1850b8c1fbc7c089cd42708
  1018. Author: chrisluiz <[email protected]>
  1019. Date: Fri Jul 7 15:58:51 2023 +0000
  1020.  
  1021. Adding httpd.conf.tmpl
  1022.  
  1023. commit 918b3a1d59cf3bfdd1e22a3e4633475d807a7f88
  1024. Author: chrisluiz <[email protected]>
  1025. Date: Fri Jul 7 15:43:19 2023 +0000
  1026.  
  1027. php support added
  1028.  
  1029. commit 49255a4d4cb2dfc32b628e42b1ad7df33abc8311
  1030. Author: chrisluiz <[email protected]>
  1031. Date: Fri Jul 7 15:32:22 2023 +0000
  1032.  
  1033. apache webserver installed and restarted
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039. #### Switching from mariadb to master branc ####
  1040.  
  1041.  
  1042. [ec2-user@ip-172-31-35-28 apache-project]$ git switch master
  1043. Switched to branch 'master'
  1044. [ec2-user@ip-172-31-35-28 apache-project]$
  1045. [ec2-user@ip-172-31-35-28 apache-project]$
  1046. [ec2-user@ip-172-31-35-28 apache-project]$ git log
  1047. commit cc4555c154a80f89136b26196076e3250cccd319 (HEAD -> master)
  1048. Author: chrisluiz <[email protected]>
  1049. Date: Fri Jul 7 16:14:21 2023 +0000
  1050.  
  1051. virtualhostconf.tmpl 8080 added
  1052.  
  1053. commit 14e31efa9fc6df1eb1850b8c1fbc7c089cd42708
  1054. Author: chrisluiz <[email protected]>
  1055. Date: Fri Jul 7 15:58:51 2023 +0000
  1056.  
  1057. Adding httpd.conf.tmpl
  1058.  
  1059. commit 918b3a1d59cf3bfdd1e22a3e4633475d807a7f88
  1060. Author: chrisluiz <[email protected]>
  1061. Date: Fri Jul 7 15:43:19 2023 +0000
  1062.  
  1063. php support added
  1064.  
  1065. commit 49255a4d4cb2dfc32b628e42b1ad7df33abc8311
  1066. Author: chrisluiz <[email protected]>
  1067. Date: Fri Jul 7 15:32:22 2023 +0000
  1068.  
  1069. apache webserver installed and restarted
  1070. [ec2-user@ip-172-31-35-28 apache-project]$ cat main.yml
  1071. ---
  1072.  
  1073. - name: "Apache installation"
  1074. hosts: amazon
  1075. become: true
  1076. vars_files:
  1077. - variables.yml
  1078. tasks:
  1079. - name: "Installing the apache packages"
  1080. yum:
  1081. name: "{{ packages }}"
  1082. state: present
  1083. - name: "Copying the httpd_conf.tmpl"
  1084. template:
  1085. src: httpd.conf.tmpl
  1086. dest: /etc/httpd/conf/httpd.conf
  1087. notify:
  1088. - restart-httpd
  1089. - name: "Copying the virtualhost.tmpl"
  1090. template:
  1091. src: virtualhost.conf.tmpl
  1092. dest: /etc/httpd/conf.d/default.conf
  1093. notify:
  1094. - restart-httpd
  1095. - name: "Uploading the test contantents"
  1096. copy:
  1097. src: "{{ item }}"
  1098. dest: /var/www/html/
  1099. owner: "{{ httpd_owner }}"
  1100. group: "{{ httpd_group }}"
  1101. with_items:
  1102. - test.php
  1103. - test.html
  1104. notify:
  1105. - restart-php
  1106.  
  1107. handlers:
  1108. - name: "restart-php"
  1109. service:
  1110. name: php-fpm
  1111. state: restarted
  1112. enabled: true
  1113. - name: "restart-httpd"
  1114. service:
  1115. name: httpd
  1116. state: restarted
  1117. enabled: true
  1118.  
Advertisement
Add Comment
Please, Sign In to add comment