├── .gitignore ├── Assignments ├── Extras.md └── Original.md ├── LICENSE.TXT ├── README.md ├── Solutions ├── task10.compose ├── task2.sh ├── task3.sh ├── task4.sh ├── task5.sh ├── task6.Dockerfile ├── task6.sh ├── task7.Dockerfile ├── task7.sh ├── task8.sh ├── task9.dockerfile └── task9.sh ├── Vagrantfile ├── ansible.cfg ├── inventory └── playbooks ├── files ├── beer.sql ├── create_webpage.sh ├── dockerfiles │ ├── mosquitto │ │ ├── Dockerfile │ │ ├── colors.tar │ │ └── skeeter.sh │ ├── nginx │ │ ├── Dockerfile │ │ ├── duffman.png │ │ └── index.html │ └── voting │ │ └── docker-compose.yml └── index.html ├── master.yml ├── registry.yml ├── reset.yml ├── welcome.yml └── workstation.yml /.gitignore: -------------------------------------------------------------------------------- 1 | *.retry.yml/ 2 | *.vagrant/ 3 | **/.DS_Store -------------------------------------------------------------------------------- /Assignments/Extras.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | The original sample exam did not have questions for all topics on the 2023 EX188 exam. 4 | 5 | This document adds a few missing topics. 6 | 7 | 8 | # Extra tasks 9 | 10 | ## Task 8 11 | 12 | Use the MariaDB container from task 3. 13 | 14 | Refactor your configuration in such a way that you create four Podman secrets: 15 | 16 | * mysql_user: "duffman", from file ~/mysql_user 17 | * mysql_password: "saysoyeah", from file ~/mysql_password 18 | * mysql_root_password: "SQLp4ss", from file ~/mysql_root_password 19 | * mysql_database: "beer", from file ~/mysql_database 20 | 21 | Run the container in the background, with the following parameters: 22 | 23 | * You will again use the image "mariadb" from the registry on registry.do180.lab. 24 | * Give the container the name secretsdb. 25 | * Publish port 3306 on external port 3307. 26 | * The variables for database startup should be set as secret environment variables. 27 | * MYSQL_USER 28 | * MYSQL_PASSWORD 29 | * MYSQL_ROOT_PASSWORD 30 | * MYSQL_DATABASE 31 | 32 | Once the container is up and running, prove that your settings are correctly applied. 33 | 34 | Connect to your database as the root user and check for the existence of the beer database: 35 | 36 | `echo "show databases;" | mysql -uduffman -h 192.168.88.4 -psaysoyeah` 37 | 38 | Run the command located in /sql/beer.sql to insert values into the database. 39 | 40 | `mysql -uroot -h 192.168.88.4 -pSQLp4ss < /sql/beer.sql` 41 | 42 | 43 | ## Task 9 44 | 45 | Create a Dockerfile which creates a container image with the following requirements. Store the Dockerfile as ~/task9.dockerfile. 46 | 47 | * Based on centos:7. 48 | * During the build, create a user account. 49 | * "joe" must be the default user. 50 | * Read an argument during build-time to override the name "joe". 51 | * The container must run "whoami" to show the active user. 52 | 53 | NOTE: Arguments are NOT passed during runtime of the container! They are passed during the container build. 54 | 55 | Create two container images using this Dockerfile, named hello-joe:1.0 and hello-lisa:1.0. 56 | 57 | When run, they should respectively output "joe" and "lisa". 58 | 59 | 60 | 61 | ## Task 10 62 | 63 | **Note:** 64 | 65 | > This task heavily leans on the Docker Samples project's _Voting App_. 66 | 67 | Use the incomplete Podman Stack file located in /dockerfiles/voting/docker-compose.yml. Use the comments in the file to guide you through the process of creating a Podman Stack with the following requirements: 68 | 69 | * There are two networks: front-end (of type bridge) and back-end (of type internal). 70 | * There is one volume: db-data 71 | 72 | The Stack consists of five services: 73 | 74 | * Using the "redis" image, named "redis", in network "front-end" 75 | * Using the "postgres:9.4" image, named "db", in network "back-end", with volume "db-data" mounted on /var/postgres. 76 | * The Postgres container needs to have two environment variables: POSTGRES_USER and POSTGRES_PASSWORD, both set to "postgres". 77 | * Using the "dockersamples/examplevotingapp_vote" image, named "vote", in networks "back-end" and in "front-end". 78 | * The "vote" container exposes port 5000 on public port 5000. It depends on "redis". 79 | * Using the "dockersamples/examplevotingapp_result" image, named "result", in networks "back-end" and in "front-end". 80 | * The "vote" container exposes port 5001 on public port 5001. It depends on "db". 81 | * Using the "dockersamples/examplevotingapp_worker" image, named "worker", in networks "back-end" and "front-end". 82 | * The "worker" container depends on both "db" and "redis". 83 | 84 | 85 | -------------------------------------------------------------------------------- /Assignments/Original.md: -------------------------------------------------------------------------------- 1 | # Source 2 | 3 | I have, as of yet, not found out what the original source is for this sample / practice exam. 4 | 5 | Per June of 2023, I knew of both a Google Doc and a Github repo which served identical content: 6 | 7 | * [https://github.com/khamidziyo/sampleexam180](https://github.com/khamidziyo/sampleexam180) 8 | * [Google Docs EX180 sample exam](https://docs.google.com/document/d/e/2PACX-1vS-91bm_QXLo4oRy94wB0FPxzNk-yAhCs9gE2ljU9xjTGGtHmCXdc7TVBalhr59bl49-qZDJuSP0bDL/pub) 9 | 10 | I can't tell if they were made by the same person, or if one copied from another. 11 | 12 | I will not include the original texts here, on the off chance that it was a stolen and real exam. 13 | 14 | # Walkthrough 15 | 16 | Ziyo Notes wrote a nice walkthrough that shows you how each assignment could be completed. 17 | 18 | * [https://ziyonotes.uz/ex180-sample](https://ziyonotes.uz/ex180-sample) -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | Attribution-ShareAlike 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution-ShareAlike 4.0 International Public 58 | License 59 | 60 | By exercising the Licensed Rights (defined below), You accept and agree 61 | to be bound by the terms and conditions of this Creative Commons 62 | Attribution-ShareAlike 4.0 International Public License ("Public 63 | License"). To the extent this Public License may be interpreted as a 64 | contract, You are granted the Licensed Rights in consideration of Your 65 | acceptance of these terms and conditions, and the Licensor grants You 66 | such rights in consideration of benefits the Licensor receives from 67 | making the Licensed Material available under these terms and 68 | conditions. 69 | 70 | 71 | Section 1 -- Definitions. 72 | 73 | a. Adapted Material means material subject to Copyright and Similar 74 | Rights that is derived from or based upon the Licensed Material 75 | and in which the Licensed Material is translated, altered, 76 | arranged, transformed, or otherwise modified in a manner requiring 77 | permission under the Copyright and Similar Rights held by the 78 | Licensor. For purposes of this Public License, where the Licensed 79 | Material is a musical work, performance, or sound recording, 80 | Adapted Material is always produced where the Licensed Material is 81 | synched in timed relation with a moving image. 82 | 83 | b. Adapter's License means the license You apply to Your Copyright 84 | and Similar Rights in Your contributions to Adapted Material in 85 | accordance with the terms and conditions of this Public License. 86 | 87 | c. BY-SA Compatible License means a license listed at 88 | creativecommons.org/compatiblelicenses, approved by Creative 89 | Commons as essentially the equivalent of this Public License. 90 | 91 | d. Copyright and Similar Rights means copyright and/or similar rights 92 | closely related to copyright including, without limitation, 93 | performance, broadcast, sound recording, and Sui Generis Database 94 | Rights, without regard to how the rights are labeled or 95 | categorized. For purposes of this Public License, the rights 96 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 97 | Rights. 98 | 99 | e. Effective Technological Measures means those measures that, in the 100 | absence of proper authority, may not be circumvented under laws 101 | fulfilling obligations under Article 11 of the WIPO Copyright 102 | Treaty adopted on December 20, 1996, and/or similar international 103 | agreements. 104 | 105 | f. Exceptions and Limitations means fair use, fair dealing, and/or 106 | any other exception or limitation to Copyright and Similar Rights 107 | that applies to Your use of the Licensed Material. 108 | 109 | g. License Elements means the license attributes listed in the name 110 | of a Creative Commons Public License. The License Elements of this 111 | Public License are Attribution and ShareAlike. 112 | 113 | h. Licensed Material means the artistic or literary work, database, 114 | or other material to which the Licensor applied this Public 115 | License. 116 | 117 | i. Licensed Rights means the rights granted to You subject to the 118 | terms and conditions of this Public License, which are limited to 119 | all Copyright and Similar Rights that apply to Your use of the 120 | Licensed Material and that the Licensor has authority to license. 121 | 122 | j. Licensor means the individual(s) or entity(ies) granting rights 123 | under this Public License. 124 | 125 | k. Share means to provide material to the public by any means or 126 | process that requires permission under the Licensed Rights, such 127 | as reproduction, public display, public performance, distribution, 128 | dissemination, communication, or importation, and to make material 129 | available to the public including in ways that members of the 130 | public may access the material from a place and at a time 131 | individually chosen by them. 132 | 133 | l. Sui Generis Database Rights means rights other than copyright 134 | resulting from Directive 96/9/EC of the European Parliament and of 135 | the Council of 11 March 1996 on the legal protection of databases, 136 | as amended and/or succeeded, as well as other essentially 137 | equivalent rights anywhere in the world. 138 | 139 | m. You means the individual or entity exercising the Licensed Rights 140 | under this Public License. Your has a corresponding meaning. 141 | 142 | 143 | Section 2 -- Scope. 144 | 145 | a. License grant. 146 | 147 | 1. Subject to the terms and conditions of this Public License, 148 | the Licensor hereby grants You a worldwide, royalty-free, 149 | non-sublicensable, non-exclusive, irrevocable license to 150 | exercise the Licensed Rights in the Licensed Material to: 151 | 152 | a. reproduce and Share the Licensed Material, in whole or 153 | in part; and 154 | 155 | b. produce, reproduce, and Share Adapted Material. 156 | 157 | 2. Exceptions and Limitations. For the avoidance of doubt, where 158 | Exceptions and Limitations apply to Your use, this Public 159 | License does not apply, and You do not need to comply with 160 | its terms and conditions. 161 | 162 | 3. Term. The term of this Public License is specified in Section 163 | 6(a). 164 | 165 | 4. Media and formats; technical modifications allowed. The 166 | Licensor authorizes You to exercise the Licensed Rights in 167 | all media and formats whether now known or hereafter created, 168 | and to make technical modifications necessary to do so. The 169 | Licensor waives and/or agrees not to assert any right or 170 | authority to forbid You from making technical modifications 171 | necessary to exercise the Licensed Rights, including 172 | technical modifications necessary to circumvent Effective 173 | Technological Measures. For purposes of this Public License, 174 | simply making modifications authorized by this Section 2(a) 175 | (4) never produces Adapted Material. 176 | 177 | 5. Downstream recipients. 178 | 179 | a. Offer from the Licensor -- Licensed Material. Every 180 | recipient of the Licensed Material automatically 181 | receives an offer from the Licensor to exercise the 182 | Licensed Rights under the terms and conditions of this 183 | Public License. 184 | 185 | b. Additional offer from the Licensor -- Adapted Material. 186 | Every recipient of Adapted Material from You 187 | automatically receives an offer from the Licensor to 188 | exercise the Licensed Rights in the Adapted Material 189 | under the conditions of the Adapter's License You apply. 190 | 191 | c. No downstream restrictions. You may not offer or impose 192 | any additional or different terms or conditions on, or 193 | apply any Effective Technological Measures to, the 194 | Licensed Material if doing so restricts exercise of the 195 | Licensed Rights by any recipient of the Licensed 196 | Material. 197 | 198 | 6. No endorsement. Nothing in this Public License constitutes or 199 | may be construed as permission to assert or imply that You 200 | are, or that Your use of the Licensed Material is, connected 201 | with, or sponsored, endorsed, or granted official status by, 202 | the Licensor or others designated to receive attribution as 203 | provided in Section 3(a)(1)(A)(i). 204 | 205 | b. Other rights. 206 | 207 | 1. Moral rights, such as the right of integrity, are not 208 | licensed under this Public License, nor are publicity, 209 | privacy, and/or other similar personality rights; however, to 210 | the extent possible, the Licensor waives and/or agrees not to 211 | assert any such rights held by the Licensor to the limited 212 | extent necessary to allow You to exercise the Licensed 213 | Rights, but not otherwise. 214 | 215 | 2. Patent and trademark rights are not licensed under this 216 | Public License. 217 | 218 | 3. To the extent possible, the Licensor waives any right to 219 | collect royalties from You for the exercise of the Licensed 220 | Rights, whether directly or through a collecting society 221 | under any voluntary or waivable statutory or compulsory 222 | licensing scheme. In all other cases the Licensor expressly 223 | reserves any right to collect such royalties. 224 | 225 | 226 | Section 3 -- License Conditions. 227 | 228 | Your exercise of the Licensed Rights is expressly made subject to the 229 | following conditions. 230 | 231 | a. Attribution. 232 | 233 | 1. If You Share the Licensed Material (including in modified 234 | form), You must: 235 | 236 | a. retain the following if it is supplied by the Licensor 237 | with the Licensed Material: 238 | 239 | i. identification of the creator(s) of the Licensed 240 | Material and any others designated to receive 241 | attribution, in any reasonable manner requested by 242 | the Licensor (including by pseudonym if 243 | designated); 244 | 245 | ii. a copyright notice; 246 | 247 | iii. a notice that refers to this Public License; 248 | 249 | iv. a notice that refers to the disclaimer of 250 | warranties; 251 | 252 | v. a URI or hyperlink to the Licensed Material to the 253 | extent reasonably practicable; 254 | 255 | b. indicate if You modified the Licensed Material and 256 | retain an indication of any previous modifications; and 257 | 258 | c. indicate the Licensed Material is licensed under this 259 | Public License, and include the text of, or the URI or 260 | hyperlink to, this Public License. 261 | 262 | 2. You may satisfy the conditions in Section 3(a)(1) in any 263 | reasonable manner based on the medium, means, and context in 264 | which You Share the Licensed Material. For example, it may be 265 | reasonable to satisfy the conditions by providing a URI or 266 | hyperlink to a resource that includes the required 267 | information. 268 | 269 | 3. If requested by the Licensor, You must remove any of the 270 | information required by Section 3(a)(1)(A) to the extent 271 | reasonably practicable. 272 | 273 | b. ShareAlike. 274 | 275 | In addition to the conditions in Section 3(a), if You Share 276 | Adapted Material You produce, the following conditions also apply. 277 | 278 | 1. The Adapter's License You apply must be a Creative Commons 279 | license with the same License Elements, this version or 280 | later, or a BY-SA Compatible License. 281 | 282 | 2. You must include the text of, or the URI or hyperlink to, the 283 | Adapter's License You apply. You may satisfy this condition 284 | in any reasonable manner based on the medium, means, and 285 | context in which You Share Adapted Material. 286 | 287 | 3. You may not offer or impose any additional or different terms 288 | or conditions on, or apply any Effective Technological 289 | Measures to, Adapted Material that restrict exercise of the 290 | rights granted under the Adapter's License You apply. 291 | 292 | 293 | Section 4 -- Sui Generis Database Rights. 294 | 295 | Where the Licensed Rights include Sui Generis Database Rights that 296 | apply to Your use of the Licensed Material: 297 | 298 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 299 | to extract, reuse, reproduce, and Share all or a substantial 300 | portion of the contents of the database; 301 | 302 | b. if You include all or a substantial portion of the database 303 | contents in a database in which You have Sui Generis Database 304 | Rights, then the database in which You have Sui Generis Database 305 | Rights (but not its individual contents) is Adapted Material, 306 | including for purposes of Section 3(b); and 307 | 308 | c. You must comply with the conditions in Section 3(a) if You Share 309 | all or a substantial portion of the contents of the database. 310 | 311 | For the avoidance of doubt, this Section 4 supplements and does not 312 | replace Your obligations under this Public License where the Licensed 313 | Rights include other Copyright and Similar Rights. 314 | 315 | 316 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 317 | 318 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 319 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 320 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 321 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 322 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 323 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 324 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 325 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 326 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 327 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 328 | 329 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 330 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 331 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 332 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 333 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 334 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 335 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 336 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 337 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 338 | 339 | c. The disclaimer of warranties and limitation of liability provided 340 | above shall be interpreted in a manner that, to the extent 341 | possible, most closely approximates an absolute disclaimer and 342 | waiver of all liability. 343 | 344 | 345 | Section 6 -- Term and Termination. 346 | 347 | a. This Public License applies for the term of the Copyright and 348 | Similar Rights licensed here. However, if You fail to comply with 349 | this Public License, then Your rights under this Public License 350 | terminate automatically. 351 | 352 | b. Where Your right to use the Licensed Material has terminated under 353 | Section 6(a), it reinstates: 354 | 355 | 1. automatically as of the date the violation is cured, provided 356 | it is cured within 30 days of Your discovery of the 357 | violation; or 358 | 359 | 2. upon express reinstatement by the Licensor. 360 | 361 | For the avoidance of doubt, this Section 6(b) does not affect any 362 | right the Licensor may have to seek remedies for Your violations 363 | of this Public License. 364 | 365 | c. For the avoidance of doubt, the Licensor may also offer the 366 | Licensed Material under separate terms or conditions or stop 367 | distributing the Licensed Material at any time; however, doing so 368 | will not terminate this Public License. 369 | 370 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 371 | License. 372 | 373 | 374 | Section 7 -- Other Terms and Conditions. 375 | 376 | a. The Licensor shall not be bound by any additional or different 377 | terms or conditions communicated by You unless expressly agreed. 378 | 379 | b. Any arrangements, understandings, or agreements regarding the 380 | Licensed Material not stated herein are separate from and 381 | independent of the terms and conditions of this Public License. 382 | 383 | 384 | Section 8 -- Interpretation. 385 | 386 | a. For the avoidance of doubt, this Public License does not, and 387 | shall not be interpreted to, reduce, limit, restrict, or impose 388 | conditions on any use of the Licensed Material that could lawfully 389 | be made without permission under this Public License. 390 | 391 | b. To the extent possible, if any provision of this Public License is 392 | deemed unenforceable, it shall be automatically reformed to the 393 | minimum extent necessary to make it enforceable. If the provision 394 | cannot be reformed, it shall be severed from this Public License 395 | without affecting the enforceability of the remaining terms and 396 | conditions. 397 | 398 | c. No term or condition of this Public License will be waived and no 399 | failure to comply consented to unless expressly agreed to by the 400 | Licensor. 401 | 402 | d. Nothing in this Public License constitutes or may be interpreted 403 | as a limitation upon, or waiver of, any privileges and immunities 404 | that apply to the Licensor or You, including from the legal 405 | processes of any jurisdiction or authority. 406 | 407 | 408 | ======================================================================= 409 | 410 | Creative Commons is not a party to its public licenses. 411 | Notwithstanding, Creative Commons may elect to apply one of its public 412 | licenses to material it publishes and in those instances will be 413 | considered the “Licensor.” The text of the Creative Commons public 414 | licenses is dedicated to the public domain under the CC0 Public Domain 415 | Dedication. Except for the limited purpose of indicating that material 416 | is shared under a Creative Commons public license or as otherwise 417 | permitted by the Creative Commons policies published at 418 | creativecommons.org/policies, Creative Commons does not authorize the 419 | use of the trademark "Creative Commons" or any other trademark or logo 420 | of Creative Commons without its prior written consent including, 421 | without limitation, in connection with any unauthorized modifications 422 | to any of its public licenses or any other arrangements, 423 | understandings, or agreements concerning use of licensed material. For 424 | the avoidance of doubt, this paragraph does not form part of the public 425 | licenses. 426 | 427 | Creative Commons may be contacted at creativecommons.org. 428 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | This set of sample files started out as a direct clone of [the work by FWSquatch](https://github.com/FWSquatch/do180-practice). 3 | 4 | Their last update to the project was in March of 2021, with the sample exam environment based on ContOS 7. 5 | 6 | In this fork, I am updating the environment to match todays RHEL8-based EX188 exam. 7 | 8 | 9 | ## License 10 | 11 | The original repository for the project did not include a license statement. 12 | 13 | For my fork of the project, I have taken the liberty of applying CC-BY-SA-4.0, for the time being. The original author [agreed that CC-BY-SA-4.0 is fine](https://github.com/FWSquatch/do180-practice/issues/1). 14 | 15 | 16 | # EX180 and EX188 Automated Practice Deployment 17 | _Powered by Ansible and Vagrant_ 18 | 19 | Using the files in this project, you can quickly build a lab environment to learn with [this EX180 Practice Exam](./Assignments/Original.md) 20 | 21 | Once you have finished those tasks, [continue with my own extra assignments](./Assignments/Extras.md)! 22 | 23 | 24 | ## Installation 25 | 1. Install vagrant and virtualbox. 26 | 2. Clone this repo: `git clone https://github.com/Unixerius/EX188-practice` 27 | 3. Change into the newly created directory: `cd EX188-practice` 28 | 4. Fire up the VMs: `vagrant up` 29 | 30 | Both VMs will take 1024MB of RAM, so make sure you have (at least) 2GB of RAM to spare. 31 | 32 | 33 | ## Other Useful Information: 34 | - `vagrant up` - Boots and provisions the environment 35 | - `vagrant destroy -f` - Shuts down and **destroys** the environment 36 | - `vagrant halt` - Shuts down the environment VMs (can be booted again with `vagrant up`) 37 | 38 | The first time you run the "vagrant up" command, it will download the OS images for later use. In other words, it will take longest the first time around but will be faster when it is deployed again. You can run `vagrant destroy -f` to destroy your environment at anytime. **This will erase everything**. 39 | 40 | 41 | ## Included systems: 42 | - registry.do180.lab 43 | - workstation.do180.lab 44 | 45 | 46 | ## System Details: 47 | > workstation 48 | - 192.168.88.4 49 | - Gateway - 192.168.88.1 50 | - DNS - 8.8.8.8 51 | > registry 52 | - 192.168.88.5 53 | - Gateway - 192.168.88.1 54 | - DNS - 8.8.8.8 55 | 56 | 57 | ## Accessing the systems 58 | 59 | You can work with both VMs through SSH: 60 | 61 | 1. Open a terminal window on your host OS. 62 | 2. "cd" into this Git repository. 63 | 3. Type "vagrant up" and wait for the VMs to be ready. 64 | 3. Type "vagrant ssh registry", or "vagrant ssh workstation" to login to the VM. 65 | -------------------------------------------------------------------------------- /Solutions/task10.compose: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | redis: 4 | image: redis 5 | networks: 6 | - back-end 7 | db: 8 | image: postgres:9.4 9 | networks: 10 | - back-end 11 | environment: 12 | - POSTGRES_USER=postgres 13 | - POSTGRES_PASSWORD=postgres 14 | volumes: 15 | - db-data:/var/postgres 16 | vote: 17 | image: dockersamples/examplevotingapp_vote 18 | networks: 19 | - front-end 20 | - back-end 21 | depends_on: 22 | - redis 23 | ports: 24 | - "5000:80" 25 | result: 26 | image: dockersamples/examplevotingapp_result 27 | networks: 28 | - front-end 29 | - back-end 30 | depends_on: 31 | - db 32 | ports: 33 | - "5001:80" 34 | worker: 35 | image: dockersamples/examplevotingapp_worker 36 | networks: 37 | - back-end 38 | depends_on: 39 | - db 40 | - redis 41 | networks: 42 | front-end: 43 | driver: bridge 44 | back-end: 45 | internal: true 46 | volumes: 47 | db-data: 48 | driver: local -------------------------------------------------------------------------------- /Solutions/task2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sudo podman pull registry.do180.lab:5000/httpd 4 | 5 | sudo podman run -d \ 6 | --name reg-httpd \ 7 | -p 8080:80 \ 8 | -v /web:/usr/local/apache2/htdocs \ 9 | registry.do180.lab:5000/httpd 10 | 11 | sudo semanage fcontext -a -t container_file_t /web 12 | sudo semanage fcontext -a -t container_file_t /web/index.html 13 | sudo restorecon /web 14 | sudo restorecon /web/index.html 15 | 16 | sudo podman generate systemd reg-httpd | sudo tee -a /usr/lib/systemd/system/reg-httpd.service 17 | 18 | sudo systemctl daemon-reload 19 | sudo systemctl restart reg-httpd -------------------------------------------------------------------------------- /Solutions/task3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | podman pull registry.do180.lab:5000/mariadb 4 | 5 | podman run -d \ 6 | --name testql \ 7 | -p 3306:3306 \ 8 | -e MYSQL_USER=duffman \ 9 | -e MYSQL_PASSWORD=saysoyeah \ 10 | -e MYSQL_ROOT_PASSWORD=SQLp4ss \ 11 | -e MYSQL_DATABASE=beer \ 12 | registry.do180.lab:5000/mariadb 13 | 14 | echo "show databases;" | mysql -uduffman -h 192.168.88.4 -psaysoyeah 15 | 16 | mysql -uroot -h 192.168.88.4 -pSQLp4ss < /sql/beer.sql 17 | -------------------------------------------------------------------------------- /Solutions/task4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # I can't be arsed to figure out the JQ syntax during an exam. :D 4 | # Basically just grabbing the first tag, that is not "latest". 5 | 6 | TAG=$(skopeo list-tags docker://registry.do180.lab:5000/httpd | \ 7 | jq ".Tags[1]" | tr -d \") 8 | 9 | echo "Found tag: ${TAG}." 10 | 11 | podman run -d --name alp-httpd \ 12 | -p 8008:80 \ 13 | registry.do180.lab:5000/httpd:${TAG} 14 | -------------------------------------------------------------------------------- /Solutions/task5.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | podman exec -ti alp-httpd /bin/sh << EOF 4 | echo "Before:" 5 | cat /usr/local/apache2/htdocs/index.html 6 | sed -i 's/It works!/It Twerks!/' /usr/local/apache2/htdocs/index.html 7 | echo "After:" 8 | cat /usr/local/apache2/htdocs/index.html 9 | exit 10 | EOF 11 | 12 | curl http://localhost:8008 13 | 14 | read -p "Did it work? Shall we continue? Press enter." ANSWER 15 | 16 | podman commit -a Tess alp-httpd registry.do180.lab:5000/httpd:twerks 17 | 18 | podman push registry.do180.lab:5000/httpd:twerks 19 | 20 | podman kill alp-httpd 21 | 22 | podman run -d --name tw-httpd \ 23 | -p 8008:80 \ 24 | registry.do180.lab:5000/httpd:twerks 25 | -------------------------------------------------------------------------------- /Solutions/task6.Dockerfile: -------------------------------------------------------------------------------- 1 | # Edit this file to create an nginx webserver 2 | # Pull from centos:8 3 | FROM centos:8 4 | 5 | # Extra fix needed, because the base URL for CentOS has changed. 6 | RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* 7 | RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* 8 | 9 | # Install nginx 10 | RUN dnf clean all && dnf install -y nginx 11 | 12 | # Publish port 80 to the outside world 13 | EXPOSE 80 14 | 15 | # Copy index.html and duffman.png into /usr/share/nginx/html directory 16 | COPY index.html /usr/share/nginx/html/index.html 17 | COPY duffman.png /usr/share/nginx/html/duffman.png 18 | 19 | # Run the command 'nginx -g daemon off;' 20 | ENTRYPOINT ["/usr/sbin/nginx"] 21 | CMD ["-g", "daemon off;"] -------------------------------------------------------------------------------- /Solutions/task6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cp /dockerfiles/nginx/* . 4 | 5 | cat > ./task6.dockerfile << EOF 6 | # Edit this file to create an nginx webserver 7 | # Pull from centos:8 8 | FROM centos:8 9 | 10 | # Extra fix needed, because the base URL for CentOS has changed. 11 | RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* 12 | RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* 13 | 14 | # Install nginx 15 | RUN dnf clean all && dnf install -y nginx 16 | 17 | # Publish port 80 to the outside world 18 | EXPOSE 80 19 | 20 | # Copy index.html and duffman.png into /usr/share/nginx/html directory 21 | COPY index.html /usr/share/nginx/html/index.html 22 | COPY duffman.png /usr/share/nginx/html/duffman.png 23 | 24 | # Run the command 'nginx -g daemon off;' 25 | ENTRYPOINT ["/usr/sbin/nginx"] 26 | CMD ["-g", "daemon off;"] 27 | EOF 28 | 29 | podman build -f ./task6.dockerfile -t registry.do180.lab:5000/duff-nginx:1.0 . 30 | 31 | rm Dockerfile index.html duffman.png 32 | 33 | podman push registry.do180.lab:5000/duff-nginx:1.0 34 | 35 | podman run -d --name duffman \ 36 | -p 8989:80 \ 37 | registry.do180.lab:5000/duff-nginx:1.0 38 | 39 | curl http://localhost:8989 40 | -------------------------------------------------------------------------------- /Solutions/task7.Dockerfile: -------------------------------------------------------------------------------- 1 | # Use the centos 7 base image 2 | FROM centos:7 3 | 4 | # Add your maintainer info 5 | MAINTAINER Tess Sluijter-Stek spam@spam.spam 6 | 7 | # Create a user named duffman 8 | RUN useradd -m duffman 9 | 10 | # Install epel-release and mosquitto (epel-release must be installed first) 11 | RUN yum install -y epel-release && yum install -y mosquitto 12 | 13 | # Create the colors directory from colors.tar 14 | ADD colors.tar / 15 | 16 | # Move skeeter.sh over to /skeeter.sh 17 | COPY skeeter.sh /skeeter.sh 18 | 19 | # Make skeeter.sh executable 20 | RUN chmod 755 /skeeter.sh 21 | 22 | # Allow connections to port 1883 23 | EXPOSE 1883 24 | 25 | # Switch to the duffman user 26 | USER duffman 27 | 28 | # Run the skeeter.sh script 29 | ENTRYPOINT ["/skeeter.sh"] -------------------------------------------------------------------------------- /Solutions/task7.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cp /dockerfiles/mosquitto/colors.tar . 4 | cp /dockerfiles/mosquitto/skeeter.sh . 5 | 6 | cat > ./task7.dockerfile << EOF 7 | # Use the centos 7 base image 8 | FROM centos:7 9 | 10 | # Add your maintainer info 11 | MAINTAINER Tess Sluijter-Stek spam@spam.spam 12 | 13 | # Create a user named duffman 14 | RUN useradd -m duffman 15 | 16 | # Install epel-release and mosquitto (epel-release must be installed first) 17 | RUN yum install -y epel-release && yum install -y mosquitto 18 | 19 | # Create the colors directory from colors.tar 20 | ADD colors.tar / 21 | 22 | # Move skeeter.sh over to /skeeter.sh 23 | COPY skeeter.sh /skeeter.sh 24 | 25 | # Make skeeter.sh executable 26 | RUN chmod 755 /skeeter.sh 27 | 28 | # Allow connections to port 1883 29 | EXPOSE 1883 30 | 31 | # Switch to the duffman user 32 | USER duffman 33 | 34 | # Run the skeeter.sh script 35 | ENTRYPOINT ["/skeeter.sh"] 36 | EOF 37 | 38 | podman build -t skeeter:1.0 -f ./task7.dockerfile . 39 | 40 | rm colors.tar skeeter.sh 41 | 42 | podman run -d --name mosquitto-1 \ 43 | -p 11883:1883 \ 44 | skeeter:1.0 45 | 46 | echo "Now starting test...Stop with ctrl-C." 47 | 48 | mosquitto_sub -h 127.0.0.1 -p 11883 -t "#" -------------------------------------------------------------------------------- /Solutions/task8.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo -n "duffman" > ~/mysql_user 4 | echo -n "saysoyeah" > ~/mysql_password 5 | echo -n "SQLp4ss" > ~/mysql_root_password 6 | echo -n "beer" > ~/mysql_database 7 | 8 | podman secret create -d=file mysql_user ~/mysql_user 9 | podman secret create -d=file mysql_password ~/mysql_password 10 | podman secret create -d=file mysql_root_password ~/mysql_root_password 11 | podman secret create -d=file mysql_database ~/mysql_database 12 | 13 | podman run -d --name secretsdb \ 14 | -p 3307:3306 \ 15 | --secret mysql_user,type=env,target=MYSQL_USER \ 16 | --secret mysql_password,type=env,target=MYSQL_PASSWORD \ 17 | --secret mysql_root_password,type=env,target=MYSQL_ROOT_PASSWORD \ 18 | --secret mysql_database,type=env,target=MYSQL_DATABASE \ 19 | registry:5000/mariadb -------------------------------------------------------------------------------- /Solutions/task9.dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | 3 | ARG buildname 4 | ENV buildname=${buildname:-joe} 5 | 6 | RUN useradd -m $buildname 7 | USER $buildname 8 | 9 | CMD ["whoami"] -------------------------------------------------------------------------------- /Solutions/task9.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat > task9.dockerfile << EOF 4 | FROM centos:7 5 | 6 | ARG buildname 7 | ENV buildname=\${buildname:-joe} 8 | 9 | RUN useradd -m \$buildname 10 | USER \$buildname 11 | 12 | CMD ["whoami"] 13 | EOF 14 | 15 | podman build -t hello-joe:1.0 -f task9.dockerfile . 16 | 17 | podman build --build-arg buildname=lisa -t hello-lisa:1.0 -f task9.dockerfile . 18 | 19 | podman run -ti --name joe hello-joe:1.0 20 | podman run -ti --name lisa hello-lisa:1.0 21 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | config.ssh.insert_key = false 3 | config.vm.box_check_update = false 4 | 5 | # Image Registry 6 | config.vm.define "registry" do |registry| 7 | registry.vm.box = "almalinux/8" 8 | registry.vm.hostname = "registry.do180.lab" 9 | registry.vm.network :private_network, ip: "192.168.88.5" 10 | registry.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: ".git/" 11 | 12 | registry.vm.provision :shell, :inline => "sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config; sudo systemctl restart sshd;" 13 | registry.vm.provision :shell, :inline => "yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y; sudo yum install -y sshpass ansible" 14 | 15 | end 16 | 17 | # Workstation 18 | config.vm.define "workstation" do |workstation| 19 | workstation.vm.box = "almalinux/8" 20 | workstation.vm.hostname = "workstation.do180.lab" 21 | workstation.vm.network :private_network, ip: "192.168.88.4" 22 | workstation.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: ".git/" 23 | 24 | workstation.vm.provision :shell, :inline => "sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config; sudo systemctl restart sshd;" 25 | workstation.vm.provision :shell, :inline => "yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y; sudo yum install -y sshpass ansible" 26 | 27 | workstation.vm.provision :ansible_local do |ansible| 28 | ansible.playbook = "/vagrant/playbooks/master.yml" 29 | ansible.install = false 30 | ansible.compatibility_mode = "2.0" 31 | ansible.inventory_path = "/vagrant/inventory" 32 | ansible.config_file = "/vagrant/ansible.cfg" 33 | ansible.limit = "all" 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | host_key_checking = false 3 | inventory = ./inventory 4 | deprecation_warnings = false 5 | scp_if_ssh = true 6 | system_warnings = false 7 | command_warnings = false 8 | remote_tmp = /tmp 9 | #callback_whitelist = profile_tasks 10 | stdout_callback = yaml 11 | forks = 10 12 | timeout = 30 13 | [ssh_connection] 14 | pipelining = True 15 | [privilege_escalation] 16 | become= True 17 | become_method = sudo 18 | become_user = root 19 | become_ask_pass = False -------------------------------------------------------------------------------- /inventory: -------------------------------------------------------------------------------- 1 | [registry] 2 | registry.do180.lab ansible_host=192.168.88.5 ansible_user=vagrant ansible_ssh_pass=vagrant 3 | 4 | [workstation] 5 | workstation.do180.lab ansible_host=192.168.88.4 ansible_user=vagrant ansible_ssh_pass=vagrant -------------------------------------------------------------------------------- /playbooks/files/beer.sql: -------------------------------------------------------------------------------- 1 | USE beer; 2 | CREATE TABLE IF NOT EXISTS types(name varchar(10), rating varchar(10)); 3 | INSERT INTO types(name,rating) VALUES("stout","good"); 4 | INSERT INTO types(name,rating) VALUES("porter","better"); 5 | INSERT INTO types(name,rating) VALUES("free","best"); 6 | -------------------------------------------------------------------------------- /playbooks/files/create_webpage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | index="/var/www/html/index.html" 4 | declare -a images 5 | 6 | images=$(ls -l /var/lib/registry/docker/registry/v2/repositories/ | grep -v total | awk '{print $NF}') 7 | 8 | echo -e " 9 | DO180 Registry 10 | " > $index 11 | 12 | echo -e "

Welcome to the DO180 Practice Registry

13 |

The following images are available of this server:

21 | 22 | " >> $index 23 | -------------------------------------------------------------------------------- /playbooks/files/dockerfiles/mosquitto/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use the centos 7 base image 2 | 3 | # Add your maintainer info 4 | 5 | # Create a user named duffman 6 | 7 | # Install epel-release and mosquitto (epel-release must be installed first) 8 | 9 | # Create the colors directory from colors.tar 10 | 11 | # Move skeeter.sh over to /skeeter.sh 12 | 13 | # Make skeeter.sh executable 14 | 15 | # Allow connections to port 1883 16 | 17 | # Switch to the duffman user 18 | 19 | # Run the skeeter.sh script 20 | -------------------------------------------------------------------------------- /playbooks/files/dockerfiles/mosquitto/colors.tar: -------------------------------------------------------------------------------- 1 | colors/0000775000175000017500000000000014025134642012250 5ustar vagrantvagrantcolors/10000664000175000017500000000000414025132626012325 0ustar vagrantvagrantred 2 | colors/20000664000175000017500000000000514025132632012324 0ustar vagrantvagrantblue 3 | colors/30000664000175000017500000000000614025132636012332 0ustar vagrantvagrantgreen 4 | colors/40000664000175000017500000000000714025132641012330 0ustar vagrantvagrantorange 5 | colors/50000664000175000017500000000000714025134605012333 0ustar vagrantvagrantyellow 6 | colors/60000664000175000017500000000000614025134612012331 0ustar vagrantvagrantbrown 7 | colors/70000664000175000017500000000000714025134616012337 0ustar vagrantvagrantpurple 8 | colors/80000664000175000017500000000000614025134626012340 0ustar vagrantvagrantwhite 9 | colors/90000664000175000017500000000000514025134633012336 0ustar vagrantvagrantgray 10 | colors/100000664000175000017500000000000614025134636012412 0ustar vagrantvagrantblack 11 | colors/110000664000175000017500000000000514025134642012407 0ustar vagrantvagrantpink 12 | -------------------------------------------------------------------------------- /playbooks/files/dockerfiles/mosquitto/skeeter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mosquitto -d 4 | 5 | while true; do 6 | sleep 10 7 | color=$(ls /colors | sort -R | tail -1 | while read file; do cat /colors/$file ; done) 8 | now=$(date) 9 | dude=$(whoami) 10 | mosquitto_pub -h localhost -t "timecheck" -m "$now" 11 | mosquitto_pub -h localhost -t "randomcolor" -m "$color" 12 | mosquitto_pub -h localhost -t "dude" -m "$dude" 13 | 14 | 15 | done 16 | -------------------------------------------------------------------------------- /playbooks/files/dockerfiles/nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | # Edit this file to create an nginx webserver 2 | # Pull from centos:8 3 | 4 | # Install nginx 5 | 6 | # Publish port 80 to the outside world 7 | 8 | # Copy index.html and duffman.png into /usr/share/nginx/html directory 9 | 10 | # Run the command 'nginx -g daemon off;' 11 | -------------------------------------------------------------------------------- /playbooks/files/dockerfiles/nginx/duffman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FWSquatch/do180-practice/129ec02eac252b2e7fc3b7c008163f5d6d16b2b0/playbooks/files/dockerfiles/nginx/duffman.png -------------------------------------------------------------------------------- /playbooks/files/dockerfiles/nginx/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Nginx Practice Website 4 | 5 | 6 |
7 |

Welcome to DO180 Practice Website

8 |

This is a simple nginx page

9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /playbooks/files/dockerfiles/voting/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | 4 | # Create a service called "redis", with image "redis", in network "back-end". 5 | 6 | 7 | # Create a service called "db", with image "postgres:9.4", in network "back-end". 8 | # It needs a volume "db-data" on "/var/posgres". It also needs to environment variables: 9 | # POSTGRES_USER=postgres and POSTGRES_PASSWORD=postgres 10 | 11 | 12 | 13 | # Create a service called "vote" with the image "dockersamples/examplevotingapp_vote". 14 | # It should be in both "front-end" and "back-end" networks and depends on "redis". 15 | # Expose port 5000 on port 5000. 16 | 17 | 18 | 19 | # Create a service called "result" with the image "dockersamples/examplevotingapp_result". 20 | # It should be in both "front-end" and "back-end" networks and depends on "db". 21 | # Expose port 5001 on port 5001. 22 | 23 | 24 | 25 | # Create a service called "worker" with the image "dockersamples/examplevotingapp_worker". 26 | # It should be in network "back-end" and depends on both "db" and "redis". 27 | 28 | 29 | 30 | networks: 31 | 32 | # Create two networks, "front-end" and "back-end". 33 | 34 | 35 | volumes: 36 | 37 | # Create a volume called "db-data". -------------------------------------------------------------------------------- /playbooks/files/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | DO180 Practice Website 4 | 5 | 6 |
7 |

Welcome to DO180 Practice Website

8 |

This is a simple example page

9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /playbooks/master.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - import_playbook: registry.yml 3 | - import_playbook: workstation.yml 4 | - import_playbook: welcome.yml 5 | ... 6 | -------------------------------------------------------------------------------- /playbooks/registry.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Setting up Registry Server 3 | hosts: registry 4 | strategy: free 5 | ignore_errors: true 6 | become: true 7 | vars: 8 | registry_machine: registry.do180.lab 9 | insecure_reg: true 10 | images: 11 | - hello-world 12 | - httpd 13 | - httpd:2.4-alpine 14 | - mariadb 15 | tasks: 16 | - name: Configuring network 17 | shell: > 18 | nmcli con mod "System enp0s8" 19 | ipv4.addresses "192.168.88.5/24" 20 | ipv4.gateway "192.168.88.1" 21 | ipv4.dns "8.8.8.8" 22 | ipv4.method manual 23 | 24 | - name: Building Host File 25 | copy: 26 | dest: /etc/hosts 27 | content: | 28 | 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 29 | :1 localhost localhost.localdomain localhost6 localhost6.localdomain6 30 | 192.168.88.5 registry.do180.lab registry 31 | 192.168.88.4 workstation.do180.lab workstation 32 | force: yes 33 | 34 | - name: Enabling IPV6 35 | shell: sysctl net.ipv6.conf.lo.disable_ipv6=0 ; sysctl net.ipv6.conf.all.disable_ipv6=0 36 | 37 | - name: Install packages 38 | yum: 39 | name: "{{ item }}" 40 | state: latest 41 | loop: 42 | - podman 43 | - httpd 44 | - vim 45 | - bash-completion 46 | 47 | - name: Create image dir 48 | file: 49 | path: /var/lib/registry 50 | state: directory 51 | 52 | - block: 53 | - name: Set up INSECURE registries 54 | copy: 55 | content: | 56 | unqualified-search-registries = ["{{ansible_fqdn}}:5000", "registry.redhat.io", "quay.io", "docker.io"] 57 | 58 | [[registry]] 59 | location = "{{ansible_fqdn}}:5000" 60 | insecure = true 61 | dest: /etc/containers/registries.conf 62 | when: insecure_reg == true 63 | 64 | - name: Run registry container 65 | shell: "podman run -d --name registry -p 5000:5000 -v /var/lib/registry:/var/lib/registry:z registry:2" 66 | 67 | - name: Create service for registry container 68 | shell: "podman generate systemd registry > /etc/systemd/system/reg-container.service" 69 | 70 | - name: Reload daemons 71 | shell: systemctl daemon-reload 72 | 73 | - name: Starting services 74 | service: 75 | name: "{{ item }}" 76 | state: started 77 | enabled: yes 78 | with_items: 79 | - firewalld 80 | - httpd 81 | - reg-container 82 | 83 | - name: Enabling Firewall Services 84 | firewalld: 85 | port: "{{ item }}" 86 | immediate: yes 87 | permanent: yes 88 | state: enabled 89 | with_items: 90 | - 80/tcp 91 | - 443/tcp 92 | - 5000/tcp 93 | 94 | - name: Restarting registry container 95 | service: 96 | name: reg-container 97 | state: restarted 98 | 99 | - name: Pull images 100 | shell: "podman pull docker.io/library/{{ item }}" 101 | loop: "{{ images }}" 102 | 103 | - name: Tag images 104 | shell: "podman tag docker.io/library/{{ item }} {{ registry_machine }}:5000/{{ item }}" 105 | loop: "{{ images }}" 106 | 107 | - name: Push images 108 | shell: "podman push {{ registry_machine }}:5000/{{ item }}" 109 | loop: "{{ images }}" 110 | 111 | - name: Copy create_webpage.sh 112 | copy: 113 | src: create_webpage.sh 114 | dest: /opt/create_webpage.sh 115 | mode: "0755" 116 | 117 | - name: Create registry container cronjob 118 | cron: 119 | name: Hacky hack to make the registry container restart after boot 120 | user: root 121 | special_time: reboot 122 | job: "sleep 60 && systemctl restart reg-container.service" 123 | 124 | - name: Create webpage cronjob 125 | cron: 126 | name: webpage builder 127 | user: root 128 | job: "/bin/bash /opt/create_webpage.sh" 129 | 130 | - name: Creating Welcome Message 131 | file: 132 | path: /etc/profile.d/welcome.sh 133 | state: touch 134 | mode: 0755 135 | 136 | - name: Fixing SELinux Contexts 137 | shell: restorecon -Rv /var/www/html 138 | 139 | - name: Building Welcome Message 140 | blockinfile: 141 | dest: /etc/profile.d/welcome.sh 142 | block: | 143 | #!/bin/bash 144 | # 145 | echo -e ' 146 | +-------------------------+ 147 | | Welcome to the Registry | 148 | | Happy Studying! | 149 | +-------------------------+ 150 | '" 151 | Why are you here? You should be working on the system hosts... 152 | Anyway, try not to reboot me or bad stuff can happen. 153 | 154 | You are logged into \"`hostname`\" as the \"`whoami`\" account. 155 | This system is running `cat /etc/redhat-release` 156 | 157 | There is a container registry available at registry.do180.lab:5000 158 | and repositories at http://registry.do180.lab/BaseOS and /AppStream 159 | " 160 | -------------------------------------------------------------------------------- /playbooks/reset.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Resetting Server 1 3 | hosts: server1 4 | strategy: free 5 | ignore_errors: true 6 | gather_facts: false 7 | tasks: 8 | - name: Resetting Python 9 | file: 10 | src: /usr/bin/python3.6 11 | path: /usr/bin/python 12 | state: link 13 | - name: Resetting Hostname 14 | hostname: name=server1.eight.example.com 15 | - name: Resetting network config 16 | shell: nmcli con mod "System eth1" ipv4.addresses 192.168.55.150/24 ipv4.gateway 192.168.55.1 ipv4.dns 8.8.8.8 ipv4.dns-search eight.example.com ipv4.method manual 17 | - name: Reloading Network 18 | service: 19 | name: NetworkManager 20 | state: restarted 21 | - name: Rebuilding Host File 22 | copy: 23 | dest: /etc/hosts 24 | content: "127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4\n:1 localhost localhost.localdomain localhost6 localhost6.localdomain6\n192.168.55.149 repo.eight.example.com repo\n192.168.55.150 server1.eight.example.com server1" 25 | force: yes 26 | - name: Removing Routing 27 | sysctl: 28 | name: net.ipv4.ip_forward 29 | value: '0' 30 | sysctl_set: yes 31 | - name: Resetting Timezone 32 | timezone: 33 | name: America/Los_Angeles 34 | - name: Erasing Repos 35 | file: 36 | path: /etc/yum.repos.d/* 37 | state: absent 38 | - name: Erasing Web Server Configuration 39 | file: 40 | path: /var/www/html/* 41 | state: absent 42 | - name: Erasing Shell Script (if present) 43 | file: 44 | path: /awesome.sh 45 | state: absent 46 | - name: Removing users 47 | user: 48 | name: "{{ item }}" 49 | state: absent 50 | remove: yes 51 | with_items: 52 | - phil 53 | - laura 54 | - stewart 55 | - kevin 56 | - name: Removing Added Directories 57 | file: 58 | path: /"{{ item }}" 59 | state: absent 60 | with_items: 61 | - accounting 62 | - marketing 63 | - name: Removing Temporary Files 64 | file: 65 | path: /"{{ item }}" 66 | state: absent 67 | with_items: 68 | - tmp 69 | - find 70 | - name: Readjusting Grub File 71 | lineinfile: 72 | state: present 73 | dest: /etc/default/grub 74 | insertafter: 'true' 75 | regexp: '^(GRUB_CMDLINE_LINUX=(?!.* audit)\"[^\"]+)(\".*)' 76 | line: 'GRUB_CMDLINE_LINUX="no_timer_check crashkernel=auto resume=/dev/mapper/rhel_rhel8-swap rd.lvm.lv=rhel_rhel8/root rd.lvm.lv=rhel_rhel8/swap biosdevname=0 net.ifnames=0 rhgb quiet"' 77 | - name: Starting services 78 | service: 79 | name: "{{ item }}" 80 | state: restarted 81 | enabled: yes 82 | with_items: 83 | - firewalld 84 | - httpd 85 | - name: Enabling Firewall Services 86 | firewalld: 87 | service: "{{ item }}" 88 | immediate: yes 89 | permanent: yes 90 | state: enabled 91 | with_items: 92 | - http 93 | - https 94 | - ntp 95 | - dns 96 | - ftp 97 | - name: Reloading Firewall 98 | service: name=firewalld state=restarted 99 | - name: Enabling IPV6 100 | sysctl: 101 | name: "{{ item }}" 102 | value: '0' 103 | sysctl_set: yes 104 | with_items: 105 | - net.ipv6.conf.lo.disable_ipv6 106 | - net.ipv6.conf.all.disable_ipv6 107 | - name: Changing User Password 108 | shell: echo vagrant | sudo passwd vagrant --stdin 109 | - name: Changing Root Password 110 | shell: echo password | sudo passwd root --stdin 111 | - name: Recreating Welcome Message 112 | file: 113 | path: /etc/profile.d/welcome.sh 114 | state: touch 115 | mode: 0755 116 | - name: Building Welcome Message then rebooting 117 | blockinfile: 118 | dest: /etc/profile.d/welcome.sh 119 | block: | 120 | #!/bin/bash 121 | # 122 | echo -e ' 123 | # _ _ _ _ _ _ _ _ _ 124 | # / /\ /\ \ /\_\ / /\ /\ \ /\ \ /\_\/\_\ _ / /\ 125 | # / / \ \ \ \ / / / / / \ \_\ \ / \ \ / / / / //\_\/ / \ 126 | # / / /\ \_\ \ \_/ / / / / /\ \__ /\__ \ / /\ \ \ /\ \/ \ \/ / /_/ /\ \ 127 | # / / /\ \___\ \___/ / / / /\ \___\/ /_ \ \ / / /\ \_\ / \____\__/ /\_\/\ \ \ 128 | # \ \ \ \/___/\ \ \_/ \ \ \ \/___/ / /\ \ \/ /_/_ \/_// /\/________/ \ \ \ 129 | # \ \ \ \ \ \ \ \ \ / / / \/_/ /____/\ / / /\/_// / / \ \ \ 130 | # _ \ \ \ \ \ \ _ \ \ \ / / / / /\____\/ / / / / / / \ \ \ 131 | # /_/\__/ / / \ \ \/_/\__/ / / / / / / / /______/ / / / / / __\ \ \___ 132 | # \ \/___/ / \ \_\ \/___/ / /_/ / / / /_______\/_/ / / / /___\_\/__/\ 133 | # \_____\/ \/_/\_____\/ \_\/ \/__________/ \/_/ \_________\/ 134 | # 135 | '"# 136 | # You are logged into \"`hostname`\" as the \"`whoami`\" account. 137 | # This system is running `cat /etc/redhat-release` 138 | # 139 | # For root - use \`sudo\` or \`sudo su -\` 140 | # 141 | # Repo/AppStream 142 | # Available to use from http://repo.eight.example.com/BaseOS 143 | # and http://repo.eight.example.com/AppStream 144 | " 145 | - name: Adjusting Services and Rebooting 146 | selinux: 147 | state: permissive 148 | policy: targeted 149 | - name: Rebooting Host 150 | reboot: 151 | # ---------------------------------------------------------------------- 152 | - name: Environment Reset Complete 153 | debug: 154 | msg: 155 | - ' Server 1 and Server 2 have been reset successfully!' 156 | - '------------------------------------------------------------------------' 157 | - ' Server 2 is rebooting. If you are unable to access it right away,' 158 | - ' wait a couple moments, then try again.' 159 | - '------------------------------------------------------------------------' 160 | - ' Accessing The Systems:' 161 | - '- Server 1 - 192.168.55.150' 162 | - '- Server 2 - 192.168.55.151' 163 | - '- Username/Password - vagrant/vagrant or root/password' 164 | - '- Access example - `ssh vagrant@192.168.55.150` or `vagrant ssh system1`' 165 | - ' -----------------------------------------------------------------------' 166 | - '- Two Additional interfaces and an additional drive are on Server 2.' 167 | - '- Happy Studying!' 168 | -------------------------------------------------------------------------------- /playbooks/welcome.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Creating Welcome Message 3 | hosts: workstation 4 | strategy: free 5 | gather_facts: False 6 | become: true 7 | tasks: 8 | - name: Welcome to the EX180 Exam Study Environment 9 | debug: 10 | msg: 11 | - ' The registry server and workstation have been set up successfully!' 12 | - '------------------------------------------------------------------------' 13 | - ' Workstation is rebooting. If you are unable to access it right away,' 14 | - ' wait a couple moments, then try again.' 15 | - '------------------------------------------------------------------------' 16 | - ' Accessing The Systems:' 17 | - '- workstation - 192.168.88.4' 18 | - '- Username/Password - vagrant/vagrant or root/password' 19 | - '- Access example - `ssh root@192.168.88.4` or `vagrant ssh workstation`' 20 | - ' -----------------------------------------------------------------------' 21 | - '- Happy Studying!' 22 | -------------------------------------------------------------------------------- /playbooks/workstation.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Setting Up Workstation 3 | hosts: workstation 4 | strategy: free 5 | ignore_errors: true 6 | gather_facts: false 7 | tasks: 8 | - name: Configuring network 9 | shell: > 10 | nmcli con mod "System enp0s8" 11 | ipv4.addresses "192.168.88.4/24" 12 | ipv4.gateway " 192.168.88.1" 13 | ipv4.dns "8.8.8.8" 14 | ipv4.dns-search do180.lab ipv4.method manual 15 | 16 | - name: Reloading Network 17 | service: 18 | name: NetworkManager 19 | state: restarted 20 | 21 | - name: Building Host File 22 | copy: 23 | dest: /etc/hosts 24 | content: | 25 | 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 26 | :1 localhost localhost.localdomain localhost6 localhost6.localdomain6 27 | 192.168.88.5 registry.do180.lab registry 28 | 192.168.88.4 workstation.do180.lab workstation 29 | force: true 30 | 31 | - name: Install a few packages 32 | yum: 33 | name: [ 'bash-completion', 'vim', 'mariadb', 'skopeo', 'mosquitto' ] 34 | state: latest 35 | 36 | - name: Create some directories 37 | file: 38 | path: "{{ item }}" 39 | state: directory 40 | owner: root 41 | group: root 42 | mode: "0755" 43 | loop: 44 | - /web 45 | - /sql 46 | 47 | - name: Copying /web 48 | copy: 49 | src: "{{ item }}" 50 | dest: "/web/{{ item }}" 51 | loop: 52 | - index.html 53 | 54 | - name: Copying /sql/beer.sql 55 | copy: 56 | src: files/beer.sql 57 | dest: /sql/beer.sql 58 | 59 | - name: Copying /dockerfiles 60 | copy: 61 | src: files/dockerfiles 62 | dest: / 63 | 64 | - name: Starting services 65 | service: 66 | name: "{{ item }}" 67 | state: started 68 | enabled: true 69 | with_items: 70 | - firewalld 71 | 72 | - name: Reloading Firewall 73 | service: name=firewalld state=restarted 74 | 75 | - name: Enabling IPV6 76 | sysctl: 77 | name: "{{ item }}" 78 | value: '0' 79 | sysctl_set: true 80 | with_items: 81 | - net.ipv6.conf.lo.disable_ipv6 82 | - net.ipv6.conf.all.disable_ipv6 83 | 84 | - name: Changing User Password 85 | shell: echo vagrant | sudo passwd vagrant --stdin 86 | 87 | - name: Changing Root Password 88 | shell: echo password | sudo passwd root --stdin 89 | 90 | - name: Creating Welcome Message 91 | file: 92 | path: /etc/profile.d/welcome.sh 93 | state: touch 94 | mode: 0755 95 | 96 | - name: Building Welcome Message then rebooting 97 | blockinfile: 98 | dest: /etc/profile.d/welcome.sh 99 | block: | 100 | #!/bin/bash 101 | # 102 | echo -e ' 103 | +------------------------+ 104 | | Welcome to Workstation | 105 | | Happy Studying! | 106 | +------------------------+ 107 | '" 108 | You are logged into \"`hostname`\" as the \"`whoami`\" account. 109 | This system is running `cat /etc/redhat-release` 110 | 111 | For root - use \`sudo\` or \`sudo su -\` 112 | 113 | Image Registry available at registry.do180.lab:5000 114 | Check http://registry.do180.lab to see the latest images. 115 | " 116 | 117 | --------------------------------------------------------------------------------