├── .gitignore ├── LICENSE ├── README.md ├── Vagrantfile ├── arch_scripts ├── get_vagrant_ips.sh └── ips_from_hosts.sh ├── docs ├── 00_jaba.md ├── 01_configuracao_do_ambiente.md ├── 02_o_basico_necessario_sobre_vagrant.md ├── 03_ansible_basico.md ├── 04_configuracao_do_ansible.md ├── 05_playbooks.md ├── 06_tasks.md ├── 07_ansible_galaxy.md ├── 99_problemas_comuns.md ├── images │ ├── ansible_arch.png │ ├── ansible_logo.png │ ├── console.png │ ├── emacs_00.png │ ├── emacs_01.png │ ├── galaxy.png │ ├── ursula.jpg │ ├── vagrant_cloud.png │ ├── virtualbox_01.png │ ├── virtualbox_02.png │ └── virtualbox_03.png ├── index.md ├── overrides │ └── main.html ├── referencias.md └── stylesheets │ └── extra.css ├── images ├── console.png ├── virtualbox_01.png ├── virtualbox_02.png └── virtualbox_03.png ├── mkdocs.yml ├── playbooks ├── arch_base_packages.yml ├── config_python.yml ├── emacs.yml ├── pipx_httpie.yml ├── play_tasks.yml ├── requirements.yml ├── tasks │ ├── dev_env.yml │ ├── py_311.yml │ └── pyenv.yml ├── variaveis.yml └── web_server.yml ├── poetry.lock ├── pyproject.toml └── stuff ├── TODO.md ├── draws └── ansible_arch.odg ├── env_up.sh ├── resposta_ubuntu_setup.txt └── vagrant.md /.gitignore: -------------------------------------------------------------------------------- 1 | # stuff 2 | .vagrant/ 3 | ansible_hosts 4 | 5 | # Byte-compiled / optimized / DLL files 6 | __pycache__/ 7 | *.py[cod] 8 | *$py.class 9 | 10 | # C extensions 11 | *.so 12 | 13 | # Distribution / packaging 14 | .Python 15 | build/ 16 | develop-eggs/ 17 | dist/ 18 | downloads/ 19 | eggs/ 20 | .eggs/ 21 | lib/ 22 | lib64/ 23 | parts/ 24 | sdist/ 25 | var/ 26 | wheels/ 27 | pip-wheel-metadata/ 28 | share/python-wheels/ 29 | *.egg-info/ 30 | .installed.cfg 31 | *.egg 32 | MANIFEST 33 | 34 | # PyInstaller 35 | # Usually these files are written by a python script from a template 36 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 37 | *.manifest 38 | *.spec 39 | 40 | # Installer logs 41 | pip-log.txt 42 | pip-delete-this-directory.txt 43 | 44 | # Unit test / coverage reports 45 | htmlcov/ 46 | .tox/ 47 | .nox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *.cover 54 | *.py,cover 55 | .hypothesis/ 56 | .pytest_cache/ 57 | 58 | # Translations 59 | *.mo 60 | *.pot 61 | 62 | # Django stuff: 63 | *.log 64 | local_settings.py 65 | db.sqlite3 66 | db.sqlite3-journal 67 | 68 | # Flask stuff: 69 | instance/ 70 | .webassets-cache 71 | 72 | # Scrapy stuff: 73 | .scrapy 74 | 75 | # Sphinx documentation 76 | docs/_build/ 77 | 78 | # PyBuilder 79 | target/ 80 | 81 | # Jupyter Notebook 82 | .ipynb_checkpoints 83 | 84 | # IPython 85 | profile_default/ 86 | ipython_config.py 87 | 88 | # pyenv 89 | .python-version 90 | 91 | # pipenv 92 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 93 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 94 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 95 | # install all needed dependencies. 96 | #Pipfile.lock 97 | 98 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 99 | __pypackages__/ 100 | 101 | # Celery stuff 102 | celerybeat-schedule 103 | celerybeat.pid 104 | 105 | # SageMath parsed files 106 | *.sage.py 107 | 108 | # Environments 109 | .env 110 | .venv 111 | env/ 112 | venv/ 113 | ENV/ 114 | env.bak/ 115 | venv.bak/ 116 | 117 | # Spyder project settings 118 | .spyderproject 119 | .spyproject 120 | 121 | # Rope project settings 122 | .ropeproject 123 | 124 | # mkdocs documentation 125 | /site 126 | 127 | # mypy 128 | .mypy_cache/ 129 | .dmypy.json 130 | dmypy.json 131 | 132 | # Pyre type checker 133 | .pyre/ 134 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laboratório para Live de Python sobre Ansible :snake: 2 | 3 | O objetivo desse repositório é ajudar você a construir um laboratório para aprender Ansible. Aqui você vai encontrar dicas e passos para configurar suas máquinas virtuais para construir seu ambiente. 4 | 5 | A minha ideia principal com essa live é não depender de nenhum serviço de nuvem. Nem todas as pessoas podem pagar ou tem cartão de crédito para poder inserir mesmo nos planos gratuitos. 6 | 7 | Para não depender de serviços externos, vamos usar máquinas virtuais com [virtualbox](https://www.virtualbox.org/) e vamos configurá-las usando [Vagrant](https://www.vagrantup.com/). 8 | 9 | > Para melhor leitura acesse: https://ansible.dunossauro.live/ 10 | 11 | ## Sumário 12 | 13 | - [01 - Configuração do ambiente](#configuração-do-ambiente) 14 | - [02 - O básico necessário sobre Vagrant](#básico-necessário-sobre-vagrant) 15 | - [03 - Configuração do ansible](#configuração-do-ansible) 16 | - [04 - Ansible básico](#ansible-básico) 17 | 18 | # Configuração do ambiente 19 | 20 | A primeira coisa que precisamos fazer é configurar o nosso host para instalação das máquinas virtuais. Para isso, precisamos instalar o `virtualbox` e o `vagrant`. 21 | 22 | 23 | ## Instalação do virtualbox 24 | 25 | [Virtualbox](https://www.virtualbox.org/) é um software para criação de máquinas virtuais. E ele pode ser instalado em qualquer plataforma comum do mercado. Como Windows, Linux e MacOS. 26 | 27 | > Caso você use o windows, as instalações podem ser feitas via [chocolatey](https://chocolatey.org/install#individual) 28 | 29 | Você pode fazer o [download](https://www.virtualbox.org/wiki/Downloads) e instalar ou instalar usando o seu gerenciador de pacotes usando seu terminal preferido: 30 | 31 | ```bash 32 | paru -S virtualbox # Arch 33 | choco install virtualbox # Windows 34 | sudo apt-get install virtualbox # Ubuntu 35 | ``` 36 | 37 | ## Instalação do vagrant 38 | 39 | [Vagrant](https://www.vagrantup.com/) é um software de código aberto, escrito em [Ruby](https://www.ruby-lang.org/pt/) para construir ambientes de desenvolvimento usando um arquivo de configuração. Que pode ser reproduzido por qualquer pessoa que tenha acesso ao arquivo. 40 | 41 | Abra seu terminal preferido e faça a instalação: 42 | 43 | ```bash 44 | paru -S vagrant # Arch 45 | choco install vagrant # Windows 46 | sudo apt install vagrant # Ubuntu 47 | ``` 48 | 49 | # Básico necessário sobre Vagrant 50 | 51 | Vagrant é uma ferramenta para provisionamento de máquinas virtuais. Dizendo de forma simples, ele cria e configura máquinas virtuais usando um arquivo de configuração chamado `Vagrantfile`. Nesse arquivo podemos descrever como nossas vms serão configuradas. 52 | 53 | Exemplo de um arquivo do Vagrant: 54 | 55 | ```ruby title="Vagrantfile" linenums="1" hl_lines="2" 56 | Vagrant.configure("2") do |config| 57 | config.vm.box = "archlinux/archlinux" 58 | end 59 | ``` 60 | A linha destacada é referente a um box do Vagrant. 61 | 62 | ## Vagrant boxes 63 | 64 | Um box do vagrant no nosso contexto é uma máquina virtual pré-fabricada por uma pessoa. Existem milhares delas e elas podem ser acessadas no [Vagrant Cloud](https://app.vagrantup.com/boxes/search?provider=virtualbox) 65 | 66 | ![](/images/vagrant_cloud.png) 67 | 68 | Eu optei por usar máquina do [arch linux](https://archlinux.org/) para iniciarmos nossa configuração. 69 | 70 | ## Criando uma máquina virtual 71 | 72 | Nosso primeiro passado é copiar o seguinte `Vagrantfile`: 73 | 74 | ```ruby title="Vagrantfile" linenums="1" 75 | Vagrant.configure("2") do |config| 76 | config.vm.box = "archlinux/archlinux" 77 | end 78 | ``` 79 | 80 | e colocar no diretório do nosso projeto. Que vamos inicialmente chamar de `ansible-lab`. 81 | 82 | Dessa forma podemos criar nossa máquina virtual usando um simples comando: 83 | 84 | ```bash title="$ Execução no terminal" 85 | vagrant up 86 | ``` 87 | 88 | O resultado deve ser algo parecido com isso: 89 | 90 | ```bash 91 | Bringing machine 'default' up with 'virtualbox' provider... 92 | ==> default: Importing base box 'archlinux/archlinux'... 93 | ==> default: Matching MAC address for NAT networking... 94 | ==> default: Checking if box 'archlinux/archlinux' version '20221101.99038' is up to date... 95 | ==> default: Setting the name of the VM: ansible_lab_default_1668393945684_70462 96 | ==> default: Clearing any previously set network interfaces... 97 | ==> default: Preparing network interfaces based on configuration... 98 | default: Adapter 1: nat 99 | ==> default: Forwarding ports... 100 | default: 22 (guest) => 2222 (host) (adapter 1) 101 | ==> default: Booting VM... 102 | ==> default: Waiting for machine to boot. This may take a few minutes... 103 | default: SSH address: 127.0.0.1:2222 104 | default: SSH username: vagrant 105 | default: SSH auth method: private key 106 | default: Warning: Connection reset. Retrying... 107 | default: Warning: Remote connection disconnect. Retrying... 108 | default: 109 | default: Vagrant insecure key detected. Vagrant will automatically replace 110 | default: this with a newly generated keypair for better security. 111 | default: 112 | default: Inserting generated public key within guest... 113 | default: Removing insecure key from the guest if it's present... 114 | default: Key inserted! Disconnecting and reconnecting using new SSH key... 115 | ==> default: Machine booted and ready! 116 | ==> default: Checking for guest additions in VM... 117 | ==> default: Mounting shared folders... 118 | default: /vagrant => /home/z4r4tu5tr4/ansible_lab 119 | ``` 120 | 121 | E ele criará uma máquina virtual com archlinux no nosso virtualbox. 122 | 123 | OBS: Esse comando pode demorar um pouco pois ele vai baixar um hd virtual do archlinux e instalar no seu virtualbox. 124 | 125 | ![](./images/virtualbox_01.png) 126 | 127 | Agora que temos uma máquina virtual podemos partir para o segundo passo. Que é criar dois nós para trabalhar com ansible. 128 | 129 | ## Destruindo a máquina criada 130 | 131 | Caso você tenha problemas ou queira simplesmente destruir a máquina virutal. O vagrant pode destruir de forma simples a vm e é isso que faremos agora. 132 | 133 | ```bash 134 | vagrant destroy 135 | ``` 136 | 137 | Com isso podemos ter nosso ambiente limpo outra vez: 138 | ![](./images/virtualbox_02.png) 139 | 140 | ## Configurando mais de uma máquina virtual 141 | 142 | Agora que entendemos a dinâmica de criação de vms do vagrant, podemos configurar duas máquinas para o ansible. Uma que vamos chamar de `main` que será de onde chamaremos o ansible e uma que será controlada por ele. Que se chamará somente `arch`. 143 | 144 | Para isso, só precisamos alterar nosso `Vagrantfile`: 145 | 146 | ```ruby 147 | Vagrant.configure("2") do |config| 148 | 149 | config.vm.define "main" do |main| 150 | main.vm.box = "archlinux/archlinux" 151 | end 152 | 153 | config.vm.define "arch" do |arch| 154 | arch.vm.box = "archlinux/archlinux" 155 | end 156 | 157 | end 158 | ``` 159 | 160 | Agora temos duas máquinas virtuais. Ambas configuradas com archlinux. Porém cada uma tem uma função diferente na nossa rede. 161 | 162 | O vagrant pode subir uma única vm ou as duas de uma vez: 163 | 164 | ```bash hl_lines="3" 165 | vagrant up # Inicia as duas vms 166 | vagrant up arch # Somente a máquina arch 167 | vagrant up main # Somente a máquina main (vamos escolher essa opção) 168 | ``` 169 | 170 | 171 | # Configuração do ansible 172 | 173 | ### Instalação do ansible 174 | 175 | Agora que temos duas máquinas virtuais criadas. Podemos começar a instalação do ansible. A primeira coisa que devemos fazer é acessar a máquina controladora. Para isso podemos usar o `vagrant` para nos ajudar: 176 | 177 | ```bash 178 | vagrant up main # Iniciar a máquina controladora 179 | vagrant ssh main # Acessar o console da máquina controladora via ssh 180 | ``` 181 | 182 | E isso deve retornar o console dá maquina controladora no usuário `vagrant`: 183 | 184 | ![](./images/console.png) 185 | 186 | O ansible tem seus pacotes nos repositórios de quase todas as distribuições linux. Então você pode instalar no seu sistema como quiser. 187 | 188 | > Caso tenha dúvidas, o [link da documentação](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) 189 | 190 | Formas de instalar em diversos sistemas. 191 | 192 | ```bash 193 | sudo pacman -S ansible # Arch 194 | sudo apt install ansible # Ubuntu 195 | sudo dnf ansible # Familia Redhat 196 | ``` 197 | 198 | O ansible também pode ser instalado via `pip`, porém a instalação é bastante trabalhosa. 199 | 200 | 201 | Como eu escolhi que a máquina `main` fosse um archlinux, vamos seguir a configuração com ele. O primeiro passo que devemos fazer é atualizar a máquina para garantir que tudo funcione como o esperado: 202 | 203 | ```bash 204 | sudo pacman -Syu # Atualiza o sistema 205 | ``` 206 | 207 | Caso a senha senha perguntada. A senha padrão criada pelas máquinas virtuais do vagrant é `vagrant`. 208 | 209 | Agora podemos rodar o comando para instalar o ansible: 210 | 211 | ```bash 212 | sudo pacman -S ansible 213 | ``` 214 | 215 | Se tudo ocorrer como o esperado, podemos perguntar a versão do ansible ao sistema: 216 | 217 | ```bash 218 | [vagrant@archlinux ~]$ ansible --version 219 | ansible [core 2.14.0] 220 | config file = /etc/ansible/ansible.cfg 221 | configured module search path = ['/home/vagrant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] 222 | ansible python module location = /usr/lib/python3.10/site-packages/ansible 223 | ansible collection location = /home/vagrant/.ansible/collections:/usr/share/ansible/collections 224 | executable location = /usr/bin/ansible 225 | python version = 3.10.8 (main, Nov 1 2022, 14:18:21) [GCC 12.2.0] (/usr/bin/python) 226 | jinja version = 3.1.2 227 | libyaml = True 228 | ``` 229 | 230 | Ele nos disse que está na versão `3.10.8` 231 | 232 | ### Instalação de um editor de textos 233 | 234 | Recomendo fortemente que instale um editor de textos. Para facilitar a manutenção do sistema. Você pode usar o que quiser, porém, usarei o `nano` nesse tutorial. E para começarmos com pé direito no ansible, vamos fazer essa instalação usando-o e já partirmos para o nosso primeiro comando: 235 | 236 | ```bash 237 | ansible localhost -a "sudo pacman -S nano --noconfirm" 238 | ``` 239 | 240 | E iremos receber esse resultado: 241 | 242 | ```bash 243 | [WARNING]: No inventory was parsed, only implicit localhost is available 244 | localhost | CHANGED | rc=0 >> 245 | resolving dependencies... 246 | looking for conflicting packages... 247 | 248 | Packages (1) nano-6.4-1 249 | 250 | Total Installed Size: 2.49 MiB 251 | 252 | :: Proceed with installation? [Y/n] 253 | checking keyring... 254 | checking package integrity... 255 | loading package files... 256 | checking for file conflicts... 257 | checking available disk space... 258 | :: Processing package changes... 259 | installing nano... 260 | :: Running post-transaction hooks... 261 | (1/1) Arming ConditionNeedsUpdate... 262 | ``` 263 | 264 | O que significa que conseguimos fazer uma instalação na máquina local usando ansible. Isso é de mais. 265 | 266 | #### Entendendo esse comando 267 | 268 | Precisamos entender o básico do comando que executamos com ansible agora: 269 | 270 | ```bash 271 | ansible localhost -a "sudo pacman -S nano --noconfirm" 272 | ``` 273 | 274 | Podemos dividi-lo em quatro partes: 275 | 276 | - ansible: chama o ansible 277 | - localhost: diz que a ação será executada no localhost 278 | - -a: Argumentos que passaremos para o comando 279 | - "sudo pacman -S nano --noconfirm": Os argumentos do comando 280 | 281 | Quando só dizemos o nome do host `localhost` e colocamos os argumentos `-a` significa que ansible executará os argumentos como um comando de shell. Nesse caso `"sudo pacman -S nano --noconfirm"` é um comando de shell que serve para instalar o `nano`. 282 | 283 | 284 | ### Arquivo de inventário 285 | 286 | Por padrão o arquivo de inventário das máquinas ficam no `/etc/ansible/hosts`. Vamos criar esse arquivo agora. 287 | 288 | ```bash 289 | sudo nano /etc/ansible/hosts 290 | ``` 291 | É nesse arquivo que colocamos os endereços dos nós que serão controlados pelo ansible. O arquivo tem o seguinte formato: 292 | 293 | ```txt 294 | [] 295 | 296 | ``` 297 | 298 | Por exemplo, vamos cadastrar nossa outra vm `arch` que será controlado pelo `main`. Para isso, precisamos iniciar essa máquina virtual. Antes disso, temos que sair do ssh em `main`: 299 | 300 | ```bash 301 | exit 302 | 303 | logout 304 | ``` 305 | 306 | Agora voltamos a maquina principal. A máquina onde as máquinas virtuais foram instaladas. Para super o `arch`: 307 | 308 | ```bash 309 | vagrant up arch 310 | ``` 311 | 312 | Com isso, agora devemos ter duas máquinas no nosso virtual box: 313 | 314 | ![](./images/virtualbox_03.png) 315 | 316 | Com nossa vm já de pé, podemos enviar um comando para o vagrant nos dizer o endereço ip da máquina `arch`: 317 | 318 | ```bash 319 | vagrant ssh arch -c "ip addr" 320 | 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 321 | link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 322 | inet 127.0.0.1/8 scope host lo 323 | valid_lft forever preferred_lft forever 324 | inet6 ::1/128 scope host 325 | valid_lft forever preferred_lft forever 326 | 2: eth0: mtu 1500 qdisc fq_codel state UP group default qlen 1000 327 | link/ether 08:00:27:fa:60:9b brd ff:ff:ff:ff:ff:ff 328 | altname enp0s3 329 | inet 10.0.2.15/24 metric 1024 brd 10.0.2.255 scope global dynamic eth0 330 | valid_lft 86241sec preferred_lft 86241sec 331 | inet6 fe80::a00:27ff:fefa:609b/64 scope link 332 | valid_lft forever preferred_lft forever 333 | ``` 334 | 335 | Podemos ver que o IP associado a `arch` é `10.0.2.15`. Que é o endereço que colocaremos no nosso inventário. 336 | 337 | Agora vamos voltar a nossa máquina `main` via ssh: 338 | 339 | ```bash 340 | vagrant ssh main 341 | ``` 342 | 343 | E vamos alterar nosso arquivo `/etc/ansible/hosts` dessa forma e com o comando `sudo nano /etc/ansible/hosts`: 344 | 345 | ```txt 346 | [arch] 347 | 10.0.2.15 348 | ``` 349 | 350 | Dessa forma dissemos ao ansible que existe um grupo chamado `arch`, uma dessas máquinas tem o ip `10.0.2.15`. Assim, podemos enviar comandos para o grupo `arch`. 351 | 352 | ### Primeiro comando remoto 353 | 354 | E podemos checar enviando um `ping` para a vm `arch` usando o seguinte comando `ansible arch -m ping`: 355 | 356 | ```bash 357 | ansible arch -m ping 358 | 359 | The authenticity of host '10.0.2.15 (10.0.2.15)' can't be established. 360 | ED25519 key fingerprint is SHA256:FyOy2yTlOHSLJXVF+lmYjPywdfmQprApMWrsQ7KxUlI. 361 | This host key is known by the following other names/addresses: 362 | ~/.ssh/known_hosts:1: localhost 363 | Are you sure you want to continue connecting (yes/no/[fingerprint])? yes 364 | 10.0.2.15 | UNREACHABLE! => { 365 | "changed": false, 366 | "msg": "Failed to connect to the host via ssh: Warning: Permanently added '10.0.2.15' (ED25519) to the list of known hosts.\r\nvagrant@10.0.2.15: Permission denied (publickey,password).", 367 | "unreachable": true 368 | } 369 | ``` 370 | 371 | Um erro ocorreu por conta da segurança. O SSH da vm `arch` não permitiu que o ansible fizesse a conexão. Para isso precisamos trocar chaves entre os hosts para que aconteça de maneira segura. 372 | 373 | ## Troca de chaves SSH 374 | 375 | Vamos voltar ao shell e digitar os seguintes comandos: 376 | 377 | ```bash 378 | ssh-keygen # para gerar uma chave ssh para nossa vm `main` 379 | ssh-copy-id vagrant@10.0.2.15 # Para copiar a chave de `main` para `arch` 380 | ``` 381 | 382 | Se executarmos o ping novamente obteremos sucesso: 383 | 384 | ```bash 385 | ansible arch -m ping 386 | 387 | 10.0.2.15 | SUCCESS => { 388 | "ansible_facts": { 389 | "discovered_interpreter_python": "/usr/bin/python3.10" 390 | }, 391 | "changed": false, 392 | "ping": "pong" 393 | } 394 | 395 | ``` 396 | 397 | Isso significa que a comunicação com os dois nós está acontecendo de maneira correta. Mas, faltou entender o que o comando `ansible arch -m ping` significa: 398 | 399 | - ansible: Chama o ansible 400 | - arch: O nome do grupo do inventário 401 | - -m: Significa que vamos chamar um módulo 402 | - ping: Módulo para checar se o grupo está respondendo 403 | 404 | # Ansible básico 405 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | 3 | config.vm.define "ansible_main" do |main| 4 | 5 | main.vm.box = "archlinux/archlinux" 6 | main.vm.network "public_network", use_dhcp_assigned_default_route: true#, bridge: "wlp2s0" 7 | 8 | main.vm.provider "virtualbox" do |vb| 9 | vb.memory = "1024" 10 | vb.name = "ansible_main" 11 | end 12 | 13 | end 14 | 15 | config.vm.define "arch" do |arch| 16 | arch.vm.box = "archlinux/archlinux" 17 | arch.disksize.size = "30GB" 18 | arch.vm.network "public_network", use_dhcp_assigned_default_route: true#, bridge: "wlp2s0" 19 | 20 | arch.vm.provider "virtualbox" do |vb| 21 | vb.memory = "1024" 22 | end 23 | 24 | arch.vm.provision "shell", inline: <<-SHELL 25 | sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config 26 | systemctl restart sshd 27 | pacman -Syu --noconfirm 28 | SHELL 29 | end 30 | 31 | config.vm.define "ubuntu" do |ubuntu| 32 | ubuntu.vm.box = "ubuntu/focal64" 33 | ubuntu.vm.network "public_network", use_dhcp_assigned_default_route: true#, bridge: "wlp2s0" 34 | 35 | ubuntu.vm.provider "virtualbox" do |vb| 36 | vb.memory = "1024" 37 | end 38 | 39 | ubuntu.vm.provision "shell", inline: <<-SHELL 40 | sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config 41 | systemctl restart sshd 42 | apt-get update 43 | apt-get upgrade -y 44 | SHELL 45 | 46 | end 47 | 48 | config.vm.define "centos" do |centos| 49 | centos.vm.box = "centos/stream8" 50 | centos.vm.network "public_network", use_dhcp_assigned_default_route: true#, bridge: "wlp2s0" 51 | 52 | centos.vm.provider "virtualbox" do |vb| 53 | vb.memory = "1024" 54 | end 55 | 56 | centos.vm.provision "shell", inline: <<-SHELL 57 | sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config 58 | systemctl restart sshd 59 | dnf update -y 60 | SHELL 61 | 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /arch_scripts/get_vagrant_ips.sh: -------------------------------------------------------------------------------- 1 | # Get vagrant machines ips 2 | machines=('arch' 'ubuntu' 'centos') 3 | 4 | ips=() 5 | 6 | echo '# Seu inventario (/etc/ansible/hosts)' 7 | 8 | for machine in "${machines[@]}" 9 | do 10 | ip=$(vagrant ssh $machine -c "ip -4 -brief address show" | awk '{print $3}'| cut -d'/' -f 1 | tail -n 1) 11 | echo [$machine] 12 | echo $ip ansible_user=vagrant 13 | echo 14 | ips+=($ip) 15 | done 16 | 17 | echo [linux] 18 | 19 | for ip in "${ips[@]}" 20 | do 21 | echo $ip ansible_user=vagrant 22 | done 23 | -------------------------------------------------------------------------------- /arch_scripts/ips_from_hosts.sh: -------------------------------------------------------------------------------- 1 | # sync ssh from ansible hosts 2 | ips=$(cat /etc/ansible/hosts | tail -n 3 | cut -f 1 -d' ') 3 | 4 | echo "* Limpando know hosts" 5 | rm -rf ~/.ssh/known_hosts 6 | 7 | for ip in $ips 8 | do 9 | ssh-copy-id vagrant@$ip 10 | done 11 | 12 | ansible linux -m ping 13 | -------------------------------------------------------------------------------- /docs/00_jaba.md: -------------------------------------------------------------------------------- 1 | # Jabá 2 | 3 | Como todo início de live que não tem slides eu esqueço de fazer o Jaba. Todo esse projeto só existe porque é financiado por pessoas de bom coração nas companhas de financiamento coletivo. 4 | 5 | Temos várias iniciativas para o financiamento coletivo do projeto 6 | 7 | - [Apoia.se](https://apoia.se/livedepython): Financiamento recorrente que usamos a mais tempo, 13% do valor fica com a plataforma 8 | - [PicPay](https://app.picpay.com/user/dunossauro): Financiamento recorrente que estamos valorizando recentemente, 2% do valor fica com a plataforma 9 | - [Patreon](http://patreon.com/dunossauro): Financiamento recorrente para pessoas fora do Brasil 10 | 11 | Financiamento **recorrente** é a palavra que usamos para quando você deseja doar mensalmente uma quantia fixa. Por exemplo, você pode doar 5 reais todos os meses, isso garante que o projeto continue vivo e ativo por mais tempo. Assim, tenho o planejamento financeiro. 12 | 13 | ### Opções não recorrentes: 14 | 15 | - [PicPay](http://picpay.me/livedepython): Aqui você pode doar o valor que desejar uma única vez, sem se preocupar com recorrência 16 | - Pix: Caso você tenha interesse em fazer uma transferência via PIX 17 | > email: pix.dunossauro@gmail.com 18 | 19 | ou 20 | 21 | > chave aleatória: 5363bcfa-aacd-4a87-84c3-917305af4a65 22 | 23 | ## Nossa comunidade 24 | 25 | Você pode nos encontrar por meio de vários canais, o geral onde conversamos e tiramos dúvidas sobre as lives e python de maneira geral é no [Telegram](hhttps://t.me/livepython). 26 | 27 | Porém você pode nos encontrar em outras redes: [https://dunossauro.com/](https://dunossauro.com/) 28 | -------------------------------------------------------------------------------- /docs/01_configuracao_do_ambiente.md: -------------------------------------------------------------------------------- 1 | # Configuração do ambiente 2 | 3 | A minha ideia principal com esse tutorial é não depender de nenhum serviço de nuvem. Nem todas as pessoas podem pagar ou tem cartão de crédito para poder inserir mesmo nos planos gratuitos. 4 | 5 | Para não depender de serviços externos, vamos usar máquinas virtuais com [virtualbox](https://www.virtualbox.org/) e vamos configurá-las usando [Vagrant](https://www.vagrantup.com/). 6 | 7 | 8 | Logo, a primeira coisa que precisamos fazer é configurar o nosso host para instalação das máquinas virtuais. Para isso, precisamos instalar o `virtualbox` e o `vagrant`. 9 | 10 | 11 | ## Instalação do virtualbox 12 | 13 | [Virtualbox](https://www.virtualbox.org/) é um software para criação de máquinas virtuais. E ele pode ser instalado em qualquer plataforma comum do mercado. Como Windows, Linux e MacOS. 14 | 15 | > Caso você use o windows, as instalações podem ser feitas via [chocolatey](https://chocolatey.org/install#individual) 16 | 17 | Você pode fazer o [download](https://www.virtualbox.org/wiki/Downloads) e instalar ou instalar usando o seu gerenciador de pacotes usando seu terminal preferido: 18 | 19 | ```bash 20 | paru -S virtualbox # Arch 21 | choco install virtualbox # Windows 22 | sudo apt-get install virtualbox # Ubuntu 23 | ``` 24 | 25 | ## Instalação do vagrant 26 | 27 | [Vagrant](https://www.vagrantup.com/) é um software de código aberto, escrito em [Ruby](https://www.ruby-lang.org/pt/) para construir ambientes de desenvolvimento usando um arquivo de configuração. Que pode ser reproduzido por qualquer pessoa que tenha acesso ao arquivo. 28 | 29 | Abra seu terminal preferido e faça a instalação: 30 | 31 | ```bash 32 | paru -S vagrant # Arch 33 | choco install vagrant # Windows 34 | sudo apt install vagrant # Ubuntu 35 | ``` 36 | -------------------------------------------------------------------------------- /docs/02_o_basico_necessario_sobre_vagrant.md: -------------------------------------------------------------------------------- 1 | # Básico necessário sobre Vagrant 2 | 3 | Vagrant é uma ferramenta para provisionamento de máquinas virtuais. Dizendo de forma simples, ele cria e configura máquinas virtuais usando um arquivo de configuração chamado `Vagrantfile`. Nesse arquivo podemos descrever como nossas vms serão configuradas. 4 | 5 | Exemplo de um arquivo do Vagrant: 6 | 7 | ```ruby title="Vagrantfile" linenums="1" hl_lines="2" 8 | Vagrant.configure("2") do |config| 9 | config.vm.box = "archlinux/archlinux" 10 | end 11 | ``` 12 | A linha destacada é referente a um box do Vagrant. 13 | 14 | ## Vagrant boxes 15 | 16 | Um box do vagrant no nosso contexto é uma máquina virtual pré-fabricada por uma pessoa. Existem milhares delas e elas podem ser acessadas no [Vagrant Cloud](https://app.vagrantup.com/boxes/search?provider=virtualbox) 17 | 18 | ![](/images/vagrant_cloud.png) 19 | 20 | Eu optei por usar máquina do [arch linux](https://archlinux.org/) para iniciarmos nossa configuração. 21 | 22 | ## Criando uma máquina virtual 23 | 24 | Nosso primeiro passado é copiar o seguinte `Vagrantfile`: 25 | 26 | ```ruby title="Vagrantfile" linenums="1" 27 | Vagrant.configure("2") do |config| 28 | config.vm.box = "archlinux/archlinux" 29 | end 30 | ``` 31 | 32 | e colocar no diretório do nosso projeto. Que vamos inicialmente chamar de `ansible-lab`. 33 | 34 | Dessa forma podemos criar nossa máquina virtual usando um simples comando: 35 | 36 | ```bash title="$ Execução no terminal" 37 | vagrant up 38 | ``` 39 | 40 | O resultado deve ser algo parecido com isso: 41 | 42 | ```bash 43 | Bringing machine 'default' up with 'virtualbox' provider... 44 | ==> default: Importing base box 'archlinux/archlinux'... 45 | ==> default: Matching MAC address for NAT networking... 46 | ==> default: Checking if box 'archlinux/archlinux' version '20221101.99038' is up to date... 47 | ==> default: Setting the name of the VM: ansible_lab_default_1668393945684_70462 48 | ==> default: Clearing any previously set network interfaces... 49 | ==> default: Preparing network interfaces based on configuration... 50 | default: Adapter 1: nat 51 | ==> default: Forwarding ports... 52 | default: 22 (guest) => 2222 (host) (adapter 1) 53 | ==> default: Booting VM... 54 | ==> default: Waiting for machine to boot. This may take a few minutes... 55 | default: SSH address: 127.0.0.1:2222 56 | default: SSH username: vagrant 57 | default: SSH auth method: private key 58 | default: Warning: Connection reset. Retrying... 59 | default: Warning: Remote connection disconnect. Retrying... 60 | default: 61 | default: Vagrant insecure key detected. Vagrant will automatically replace 62 | default: this with a newly generated keypair for better security. 63 | default: 64 | default: Inserting generated public key within guest... 65 | default: Removing insecure key from the guest if it's present... 66 | default: Key inserted! Disconnecting and reconnecting using new SSH key... 67 | ==> default: Machine booted and ready! 68 | ==> default: Checking for guest additions in VM... 69 | ==> default: Mounting shared folders... 70 | default: /vagrant => /home/z4r4tu5tr4/ansible_lab 71 | ``` 72 | 73 | E ele criará uma máquina virtual com archlinux no nosso virtualbox. 74 | 75 | OBS: Esse comando pode demorar um pouco, pois ele vai baixar um hd virtual do archlinux e instalar no seu virtualbox. 76 | 77 | ![](./images/virtualbox_01.png) 78 | 79 | Agora que temos uma máquina virtual podemos partir para o segundo passo. Que é criar dois nós para trabalhar com ansible. 80 | 81 | ## Destruindo a máquina criada 82 | 83 | Caso você tenha problemas ou queira simplesmente destruir a máquina virutal. O vagrant pode destruir de forma simples a vm e é isso que faremos agora. 84 | 85 | ```bash 86 | vagrant destroy 87 | ``` 88 | 89 | Com isso podemos ter nosso ambiente limpo outra vez: 90 | ![](./images/virtualbox_02.png) 91 | 92 | ## Configurando mais de uma máquina virtual 93 | 94 | Agora que entendemos a dinâmica de criação de vms do vagrant, podemos configurar duas máquinas para o ansible. Uma que vamos chamar de `main` que será de onde chamaremos o ansible e uma que será controlada por ele. Que se chamará somente `arch`. 95 | 96 | Para isso, só precisamos alterar nosso `Vagrantfile`: 97 | 98 | ```ruby 99 | Vagrant.configure("2") do |config| 100 | 101 | config.vm.define "main" do |main| 102 | main.vm.box = "archlinux/archlinux" 103 | end 104 | 105 | config.vm.define "ubuntu" do |ubuntu| 106 | ubuntu.vm.box = "ubuntu/focal64" 107 | end 108 | 109 | end 110 | ``` 111 | 112 | Agora temos duas máquinas virtuais. Uma configurada com Archlinux e uma com Ubuntu Linux. Porém, cada uma tem uma função diferente na nossa rede. 113 | 114 | O vagrant pode subir uma única vm ou as duas de uma vez: 115 | 116 | ```bash hl_lines="3" 117 | vagrant up # Inicia as duas vms 118 | vagrant up ubuntu # Somente a máquina ubuntu 119 | vagrant up main # Somente a máquina main (vamos escolher essa opção) 120 | ``` 121 | -------------------------------------------------------------------------------- /docs/03_ansible_basico.md: -------------------------------------------------------------------------------- 1 | # Ansible básico 2 | 3 | [Ansible](https://www.ansible.com/) é um grupo de ferramentas de código aberto construídas em python. O objetivo do Ansible é automatizar tarefas de diversas naturezas. Foi originalmente escrito por Michael DeHaan em 2012 e foi comprado pela Red Hat em 2015. 4 | 5 | !!! tipo "curiosidade" 6 | A palavra Ansible foi cunhada por `Ursula K. Le Guin` no livro `O mundo de Rocannon` 7 | 8 | ![](./images/ursula.jpg){ width="100" } 9 | 10 | No livro existem diversos mundos e viajantes navegam na velocidade da luz. Ansible é um dispositivo que de comunicação instantânea pelo universo. 11 | 12 | ## Automações 13 | 14 | Quando falamos sobre Ansible, estamos falando sobre qualquer tipo de automação em máquinas. Alguns exemplos comuns são: 15 | 16 | - Provisionamento de ambientes 17 | - Gerenciamento de configuração 18 | - Implantação de aplicativos 19 | 20 | Entre outras coisas que podemos fazer com o ferramental 21 | 22 | ### Provisionamento 23 | 24 | Provisionamento é o processo de preparar um dispositivo para que ele possa entrar em produção. Não só exatamente a respeito do hardware, mas a preparação do sistema operacional, a escolha dos aplicativos instalados e etc... 25 | 26 | Vimos nesse pequeno tutorial outra ferramenta de provisionamento, o Vagrant, que consegue montar a máquina virtual, fornecer a instalação do sistema operacional. A parte que envolve o ansible é mais referente a configuração dos pacotes instalados, a instalação dos softwares necessários para colocar uma máquina, geralmente um servidor, em funcionamento. 27 | 28 | ### Gerenciamento de configuração 29 | 30 | O gerenciamento de configuração é uma das partes do provisionamento, porém com foco e configurar as aplicações instaladas no sistema operacional para que ele se comporte como esperado em produção. 31 | 32 | ### Implantação de aplicativos 33 | 34 | Após toda a fase de instalação e configuração do ambiente e do sistema operacional, podemos colocar nossos aplicativos para serem executados nessas máquinas. 35 | 36 | ### Um exemplo 37 | 38 | Vamos pensar que fizemos uma aplicação web com Python. Para que essa aplicação seja usada em um servidor o servidor tem que atender diversos requisitos para executar a nossa aplicação. Independentemente da opção que você escolha para fazer o deploy dela. 39 | 40 | De forma simples, temos que instalar o python na versão correta, fazer a instalação das bibliotecas necessárias, configurar um banco de dados. Fazer com que a aplicação e o banco de dados conversem. 41 | 42 | Para que isso ocorra na nuvem, por exemplo, alguém deve ter provisionado um sistema base, como um [ubuntu linux](https://ubuntu.com/), geralmente usando algum sistema de virtualização. Como fizemos aqui com VirtualBox, porém em uma escala muito maior. Essa máquina tem que ter ao menos um serviço de [SSH](https://pt.wikipedia.org/wiki/Secure_Shell) configurado para que possamos acessar esse computador do conforto da nossa casa. 43 | 44 | É nesse contexto que o Ansible entra. Pegamos um sistema operacional limpo e iniciamos as nossas configurações e instalações para que nossa aplicação possa ser executada nesse servidor. 45 | 46 | ## Instalação do ansible 47 | 48 | Agora que temos duas máquinas virtuais criadas. Podemos começar a instalação do ansible. A primeira coisa que devemos fazer é acessar a máquina controladora. Para isso podemos usar o `vagrant` para nos ajudar: 49 | 50 | ```bash title="$ Execução no terminal" 51 | vagrant up main # Iniciar a máquina controladora 52 | vagrant ssh main # Acessar o console da máquina controladora via ssh 53 | ``` 54 | 55 | E isso deve retornar o console dá maquina controladora no usuário `vagrant`: 56 | 57 | ![](./images/console.png){ width="500" } 58 | 59 | O ansible tem seus pacotes nos repositórios de quase todas as distribuições linux. Então você pode instalar no seu sistema como quiser. 60 | 61 | > Caso tenha dúvidas, o [link da documentação](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) 62 | 63 | Formas de instalar em diversos sistemas. 64 | 65 | ```bash title="$ Execução no terminal" 66 | sudo pacman -S ansible # Arch 67 | sudo apt install ansible # Ubuntu 68 | sudo dnf ansible # Familia Redhat 69 | ``` 70 | 71 | O ansible também pode ser instalado via `pip`, porém a instalação é bastante trabalhosa. 72 | 73 | 74 | Como eu escolhi que a máquina `main` fosse um archlinux, vamos seguir a configuração com ele. O primeiro passo que devemos fazer é atualizar a máquina para garantir que tudo funcione como o esperado: 75 | 76 | ```bash 77 | sudo pacman -Syu # Atualiza o sistema 78 | ``` 79 | 80 | Caso a senha perguntada. A senha padrão criada pelas máquinas virtuais do vagrant é `vagrant`. 81 | 82 | Agora podemos rodar o comando para instalar o ansible: 83 | 84 | ```bash title="$ Execução no terminal" 85 | sudo pacman -S ansible 86 | ``` 87 | 88 | Se tudo ocorrer como o esperado, podemos perguntar a versão do ansible ao sistema: 89 | 90 | ```bash title="$ Execução no terminal" 91 | [vagrant@archlinux ~]$ ansible --version 92 | ansible [core 2.14.0] 93 | config file = /etc/ansible/ansible.cfg 94 | configured module search path = ['/home/vagrant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] 95 | ansible python module location = /usr/lib/python3.10/site-packages/ansible 96 | ansible collection location = /home/vagrant/.ansible/collections:/usr/share/ansible/collections 97 | executable location = /usr/bin/ansible 98 | python version = 3.10.8 (main, Nov 1 2022, 14:18:21) [GCC 12.2.0] (/usr/bin/python) 99 | jinja version = 3.1.2 100 | libyaml = True 101 | ``` 102 | 103 | Ele nos disse que está na versão `3.10.8` 104 | 105 | ## Um pouco de ansible na prática 106 | 107 | O ansible foi pensado para que pudéssemos automatizar uma tarefa de qualquer natureza. Para isso basta ter o ansible instalado na sua máquina e chamá-lo via linha de comando. 108 | 109 | ### Instalação de um pacote 110 | 111 | Por exemplo, vamos supor que no nosso ambiente é imprescindível que o editor de texto [GNU/Emacs](https://www.gnu.org/software/emacs/) esteja instalado (para mim costuma ser). Então podemos usar o ansible para instalar o Emacs no nosso computador pessoal: 112 | 113 | 114 | ```bash title="$ Execução no terminal" 115 | ansible localhost -m package -a "name=emacs state=present" -b 116 | ``` 117 | 118 | Com esse simples comando, temos o GNU/Emacs instalado nesse computador. Mas, o que realmente aconteceu aqui? 119 | 120 | | Fragmento do comando | O que faz? | 121 | | -------------------- | ---------- | 122 | | ansible | Invoca o ansible | 123 | | localhost | Diz qual máquina será afetada pelo comando | 124 | | -m | Diz que vamos chamar um módulo | 125 | | package | `package` é o nome do módulo que vamos chamar | 126 | | -a | Indica que vamos passar argumentos para o módulo | 127 | | "name=emacs state=present" | Argumentos do módulo | 128 | | -b | Diz ao Ansible que o comando será executado como `root` | 129 | 130 | O módulo [package](https://docs.ansible.com/ansible/2.9/modules/package_module.html#package-module) é um dos muitos módulos ofertados pelo Ansible. Você pode ver uma lista completa aqui nesse [link](https://docs.ansible.com/ansible/2.9/modules/list_of_all_modules.html). O que dissemos, porém, é: "Modulo `package` garanta que o pacote `emacs` esteja `presente` no sistema em que for executado". 131 | 132 | Podemos checar no terminal: 133 | 134 | ```bash title="$ Execução no terminal" 135 | emacs 136 | ``` 137 | 138 | ![](./images/emacs_00.png){ width="500" } 139 | 140 | !!! error "Caso tenha ficado preso" 141 | Para sair do emacs tecle Alt+x e em seguida digite `kill-emacs` e você terá saído do emacs :heart: 142 | 143 | ### Configuração do pacote 144 | 145 | Embora o GNU/Emacs esteja instalado no meu sistema. Ele ainda não foi configurado da maneira que eu gostaria. Não tem as minhas cores, os meus atalhos e para isso precisamos baixar meu arquivo de configuração que está no [github.com/dunossauro/dotfiles](https://github.com/dunossauro/dotfiles). 146 | 147 | Para isso, podemos contar com outro módulo disponível no Ansible, o [git](https://docs.ansible.com/ansible/2.9/modules/git_module.html#git-module). Então, vamos baixar as minhas configurações: 148 | 149 | ```bash title="$ Execução no terminal" 150 | ansible localhost -m git \ 151 | -a "repo=https://github.com/dunossauro/dotfiles.git dest=config_files" 152 | ``` 153 | 154 | E com isso, obtivemos um erro: 155 | 156 | ```bash title="Resposta do terminal" 157 | localhost | FAILED! => { 158 | "changed": false, 159 | "msg": "Failed to find required executable \"git\" in paths: /usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/usr/sbin" 160 | } 161 | ``` 162 | 163 | O ansible não conseguiu achar o `git` no nosso sistema, ele precisa ser instalado. Como já conhecemos o módulo package, será fácil. Só dizer ao módulo `package` que `git` deve estar `present`: 164 | 165 | ```bash title="$ Execução no terminal" 166 | ansible localhost -m package -a "name=git state=present" -b 167 | ``` 168 | 169 | Após instalar o git, podemos testar nosso módulo de git outra vez: 170 | 171 | ```bash title="$ Execução no terminal" 172 | ansible localhost -m git \ 173 | -a "repo=https://github.com/dunossauro/dotfiles.git dest=config_files" 174 | ``` 175 | 176 | ```bash title="Resposta do terminal" 177 | localhost | CHANGED => { 178 | "after": "8ff42a43ede85403b6b85c0bab9a1a4fe0d73544", 179 | "before": null, 180 | "changed": true 181 | } 182 | ``` 183 | 184 | `CHANGED`, significa que uma ação foi executada e agora temos os arquivos no nosso computador na pasta `dest` que passamos como argumento. 185 | 186 | ```bash title="$ Execução no terminal" 187 | ls config_files/.emacs.d 188 | init.el 189 | ``` 190 | 191 | Agora só falta colocar a nossa configuração no lugar certo. O diretório `~/.emacs.d/`. Para isso podemos contar com outro módulo do [copy](https://docs.ansible.com/ansible/2.9/modules/copy_module.html#copy-module): 192 | 193 | ```bash title="$ Execução no terminal" 194 | ansible localhost -m copy -a "dest='/home/vagrant/' src='/home/vagrant/config_files/.emacs.d'" 195 | ``` 196 | Após isso, podemos abrir o emacs novamente: 197 | 198 | ```bash title="$ Execução no terminal" 199 | emacs 200 | ``` 201 | 202 | > Pode demorar um pouco para as configurações serem baixadas e instaladas da internet. 203 | 204 | E temos o emacs com as minhas configurações: 205 | 206 | ![](./images/emacs_01.png){ width="500" } 207 | 208 | !!! error "Caso tenha ficado preso OUTRA VEZ" 209 | Para sair do emacs tecle Alt+x e em seguida digite `kill-emacs` e você terá saído do emacs :heart: 210 | -------------------------------------------------------------------------------- /docs/04_configuracao_do_ansible.md: -------------------------------------------------------------------------------- 1 | # Entendendo a estrutura do ansible 2 | 3 | Embora até o momento executamos o ansible somente em uma máquina local. E confesso que já pode ser bastante útil para padronizar suas configurações após uma formatação, por exemplo. O Ansible brilha quando estamos falando de rede. 4 | 5 | ## Arquitetura de uso do ansible 6 | 7 | O Ansible distingue as máquinas em duas categorias. O nó de controle, onde o ansible está instalado e os nós controlados. Que máquinas em que o ansible pode se comunicar via SSH e executar os comandos: 8 | 9 | ![](./images/ansible_arch.png){: .center .shadow-png} 10 | 11 | Dessa forma podemos partir do nó de {==Controle==} e enviar rotinas de automação para todos os nós {==Controlados==}. 12 | 13 | Para isso o ansible conta com um arquivo de inventário. Um lugar onde todas as máquinas que serão controladas pelo controlador devem ser registradas. 14 | 15 | ### Arquivo de inventário 16 | 17 | Por padrão o arquivo de inventário das máquinas ficam no `/etc/ansible/hosts`. Vamos criar esse arquivo agora. 18 | 19 | ```bash title="$ Execução no terminal" 20 | # instalação do Nano, não vou obrigar ninguém a usar o Emacs ;) 21 | ansible localhost -m package -a "name=emacs state=present" -b 22 | 23 | sudo nano /etc/ansible/hosts 24 | ``` 25 | 26 | É nesse arquivo que colocamos os endereços dos nós que serão controlados pelo ansible. O arquivo tem o seguinte formato: 27 | 28 | ```txt 29 | [] 30 | 31 | ``` 32 | 33 | Por exemplo, vamos cadastrar nossa outra vm `arch` que será controlado pelo `main`. Para isso, precisamos iniciar essa máquina virtual. Antes disso, temos que sair do ssh em `main`: 34 | 35 | ```bash title="$ Execução no terminal" 36 | exit 37 | ``` 38 | 39 | Agora voltamos a máquina principal. A máquina onde as máquinas virtuais foram instaladas. Vamos iniciar nossa outra máquina. O `ubuntu`: 40 | 41 | ```bash 42 | vagrant up ubuntu 43 | ``` 44 | 45 | Com isso, agora devemos ter duas máquinas no nosso virtual box: 46 | 47 | [AA] - Mudar essa imagem 48 | 49 | ![](./images/virtualbox_03.png) 50 | 51 | Com nossa vm já de pé, podemos enviar um comando para o vagrant nos dizer o endereço ip da máquina `ubuntu`: 52 | 53 | ```bash title="$ Execução no terminal" 54 | vagrant ssh ubuntu -c "ip addr" 55 | 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 56 | link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 57 | inet 127.0.0.1/8 scope host lo 58 | valid_lft forever preferred_lft forever 59 | inet6 ::1/128 scope host 60 | valid_lft forever preferred_lft forever 61 | 2: eth0: mtu 1500 qdisc fq_codel state UP group default qlen 1000 62 | link/ether 08:00:27:fa:60:9b brd ff:ff:ff:ff:ff:ff 63 | altname enp0s3 64 | inet {==10.0.2.15==}/24 metric 1024 brd 10.0.2.255 scope global dynamic eth0 65 | valid_lft 86241sec preferred_lft 86241sec 66 | inet6 fe80::a00:27ff:fefa:609b/64 scope link 67 | valid_lft forever preferred_lft forever 68 | ``` 69 | 70 | Podemos ver que o IP associado a `ubuntu` é `10.0.2.15`. Que é o endereço que colocaremos no nosso inventário. 71 | 72 | Agora vamos voltar a nossa máquina `main` via ssh: 73 | 74 | ```bash title="$ Execução no terminal" 75 | vagrant ssh main 76 | ``` 77 | 78 | E vamos alterar nosso arquivo `/etc/ansible/hosts` dessa forma e com o comando `sudo nano /etc/ansible/hosts`: 79 | 80 | ```txt title="/etc/ansible/hosts" linenums="1" 81 | [ubuntu] 82 | 10.0.2.15 83 | ``` 84 | 85 | Dessa forma dissemos ao ansible que existe um grupo chamado `ubuntu`, uma dessas máquinas tem o ip `10.0.2.15`. Assim, podemos enviar comandos para o grupo `ubuntu`. 86 | 87 | ### Primeiro comando remoto 88 | 89 | E podemos checar enviando um `ping` para a vm `ubuntu` usando o seguinte comando `ansible ubuntu -m ping`: 90 | 91 | ```bash title="$ Execução no terminal" 92 | ansible ubuntu -m ping 93 | 94 | The authenticity of host '10.0.2.15 (10.0.2.15)' can't be established. 95 | ED25519 key fingerprint is SHA256:FyOy2yTlOHSLJXVF+lmYjPywdfmQprApMWrsQ7KxUlI. 96 | This host key is known by the following other names/addresses: 97 | ~/.ssh/known_hosts:1: localhost 98 | Are you sure you want to continue connecting (yes/no/[fingerprint])? yes 99 | 10.0.2.15 | UNREACHABLE! => { 100 | "changed": false, 101 | "msg": "Failed to connect to the host via ssh: Warning: Permanently added '10.0.2.15' (ED25519) to the list of known hosts.\r\nvagrant@10.0.2.15: Permission denied (publickey,password).", 102 | "unreachable": true 103 | } 104 | ``` 105 | 106 | Um erro ocorreu por conta da segurança. O SSH da vm `ubuntu` não permitiu que o ansible fizesse a conexão. Para isso precisamos trocar chaves entre os hosts para que aconteça de maneira segura. 107 | 108 | ## Troca de chaves SSH 109 | 110 | Vamos voltar ao shell e digitar os seguintes comandos: 111 | 112 | ```bash title="$ Execução no terminal" 113 | ssh-keygen # para gerar uma chave ssh para nossa vm `main` 114 | ssh-copy-id vagrant@10.0.2.15 # Para copiar a chave de `main` para `ubuntu` 115 | ``` 116 | 117 | Se executarmos o ping novamente obteremos sucesso: 118 | 119 | ```bash title="$ Execução no terminal" 120 | ansible arch -m ping 121 | 122 | 10.0.2.15 | SUCCESS => { 123 | "ansible_facts": { 124 | "discovered_interpreter_python": "/usr/bin/python3.10" 125 | }, 126 | "changed": false, 127 | "ping": "pong" 128 | } 129 | ``` 130 | 131 | Isso significa que a comunicação com os dois nós está acontecendo de maneira correta. Mas, faltou entender o que o comando `ansible ubuntu -m ping` significa: 132 | 133 | - ansible: Chama o ansible 134 | - ubuntu: O nome do grupo do inventário 135 | - -m: Significa que vamos chamar um módulo 136 | - ping: Módulo para checar se o grupo está respondendo 137 | 138 | ## Repetindo o processo para mais uma máquina 139 | 140 | Agora que já entendemos o que temos que fazer. Podemos adicionar mais uma máquina virtual ao nosso ambiente. Vamos criar mais um `arch` para que seja controlado pelo ansible: 141 | 142 | ```ruby title="Vagrantfile" linenums="1" 143 | Vagrant.configure("2") do |config| 144 | 145 | config.vm.define "main" do |main| 146 | main.vm.box = "archlinux/archlinux" 147 | end 148 | 149 | config.vm.define "ubuntu" do |ubuntu| 150 | ubuntu.vm.box = "ubuntu/focal64" 151 | end 152 | 153 | config.vm.define "arch" do |arch| 154 | arch.vm.box = "archlinux/archlinux" 155 | end 156 | 157 | end 158 | ``` 159 | 160 | Agora podemos dar `up` nessa nova máquina: 161 | 162 | ```bash title="$ Execução no terminal" 163 | exit # caso esteja no conectado no main 164 | 165 | vagrant up arch 166 | ``` 167 | 168 | Pegamos o endereço de ip: 169 | 170 | ```bash title="$ Execução no terminal" 171 | vagrant ssh arch -c "ip addr" 172 | 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 173 | link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 174 | inet 127.0.0.1/8 scope host lo 175 | valid_lft forever preferred_lft forever 176 | inet6 ::1/128 scope host 177 | valid_lft forever preferred_lft forever 178 | 2: eth0: mtu 1500 qdisc fq_codel state UP group default qlen 1000 179 | link/ether 08:00:27:fa:60:9b brd ff:ff:ff:ff:ff:ff 180 | altname enp0s3 181 | inet {==10.0.2.16==}/24 metric 1024 brd 10.0.2.255 scope global dynamic eth0 182 | valid_lft 86241sec preferred_lft 86241sec 183 | inet6 fe80::a00:27ff:fefa:609b/64 scope link 184 | valid_lft forever preferred_lft forever 185 | ``` 186 | 187 | Adicionamos esse ip no inventário da máquina controladora: 188 | 189 | ```text title="/etc/ansible/hosts" hl_lines="4 5" linenums="1" 190 | [ubuntu] 191 | 10.0.2.15 192 | 193 | [arch] 194 | 10.0.2.16 195 | ``` 196 | 197 | Fazemos a troca de chaves SSH, para que o Controlador se comunique de forma segura com o `arch`: 198 | 199 | ```bash title="$ Execução no terminal" 200 | ssh-copy-id vagrant@10.0.2.16 # Para copiar a chave de `main` para `arch` 201 | ``` 202 | 203 | Com isso temos dois grupos no nó de controle. O `ubuntu` e o `arch`. Podemos criar um grupo novo também para juntar todos os linux e disparar comandos que funcionem nas duas máquinas ao mesmo tempo: 204 | 205 | 206 | ```text title="/etc/ansible/hosts" hl_lines="7 8 9" linenums="1" 207 | [ubuntu] 208 | 10.0.2.15 209 | 210 | [arch] 211 | 10.0.2.16 212 | 213 | [linux] 214 | 10.0.2.15 215 | 10.0.2.16 216 | ``` 217 | 218 | Dessa forma, podemos chamar o módulo `ping` para todos os nós em um grupo só: 219 | 220 | ```bash title="$ Execução no terminal" 221 | ansible linux -m ping 222 | ``` 223 | 224 | Caso tudo esteja configurado corretamente. Iremos obter sucesso em ambos os pings. O que significa que o comando foi executado com sucesso nas duas máquinas. 225 | 226 | ## Instalando um pacote em dois nós ao mesmo tempo 227 | 228 | Vamos iniciar uma configuração simples e que já rodamos no nó controlador. Meu objetivo, porém, é mostrar a vocês o poder do ansible de forma simples: 229 | 230 | 231 | ```bash title="$ Execução no terminal" 232 | ansible linux -m package -a "name=nginx state=present" -b 233 | ``` 234 | 235 | Dessa forma acabamos de instalar o servidor web [Nginx](https://nginx.org/) nas nossas duas máquinas virtuais ao mesmo tempo. Uma coisa importante de notar e que diferencia de uma forma simplória de instalação. É que não foi preciso dizer nem ao menos qual o gerenciador de pacotes que é usado em cada distribuição. O módulo `package` entende isso por padrão e usa o gerenciador da distribuição por baixo dos panos. 236 | 237 | 238 | Com isso, podemos conhecer outro módulo. O módulo do [systemd](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/systemd_module.html) e com ele podemos dizer que queremos dar start no processo do Nginx: 239 | 240 | 241 | ```bash title="$ Execução no terminal" 242 | ansible linux -m systemd -a "name=nginx state=started" -b 243 | ``` 244 | 245 | E volá, instalamos o Nginx em duas máquinas e subimos o server somente usando comandos simples e sem a preocupação de ter de entender coisas específicas de sistema. 246 | 247 | Vamos ver se o serviço subiu da forma correta? Para isso vou me aproveitar do ansible para instalar o httpie no sistema para fazer essa requisição no nó controlador. Porém, não quero fazer essa instalação sujando o ambiente. Então, vamos instalar o `pipx` 248 | 249 | 250 | ```bash title="$ Execução no terminal" 251 | ansible localhost -m package -a "name=python-pipx state=present" -b 252 | ``` 253 | 254 | Agora com o `pipx` instalado, podemos usar ele via módulo `shell` para instalar o httpie: 255 | 256 | ```bash title="$ Execução no terminal" 257 | ansible localhost -m shell -a "pipx install httpie" 258 | ``` 259 | 260 | E agora, finalmente, podemos checar se ambos os serviços foram startados corretamente pelo ansible: 261 | 262 | ```bash title="$ Execução no terminal" 263 | http 10.0.2.15 264 | http 10.0.2.16 265 | ``` 266 | 267 | Embora tudo tenha sido executado de forma incrível. Ainda considero chato de mais ficar chamando o ansible no terminal o tempo todo. Então, precisamos de uma forma de melhorar isso. 268 | -------------------------------------------------------------------------------- /docs/05_playbooks.md: -------------------------------------------------------------------------------- 1 | # Playbooks 2 | 3 | Tudo que executamos até agora foram comandos no terminal com ansible. Você deve estar se perguntando se não seria mais fácil criar um script com todos esses comandos, para evitar ter que digitar todas às vezes. Para isso existem os playbooks. Você cria um arquivo no formato [yaml](https://yaml.org/) descrevendo todas as suas tarefas e executa de uma única vez. 4 | 5 | !!! tip "O nome Playbook" 6 | Playbook é uma palavra que se refere a scripts de teatro. Por exemplo, quando alguém entra em cena, as falas de cada personagem, etc. 7 | 8 | No mundo dos esportes, playbook é usado muito no beisebol e no basquete. São listas de jogadas que podem ser feitas durante um jogo. 9 | 10 | ## Arquivos YAML 11 | 12 | Arquivos YAML são arquivos geralmente usados para configurações. Se pensarmos em Python, eles formam estruturas equivalentes a de dicionários. Uma comparação básica para você entender o formato: 13 | 14 | === "YAML" 15 | 16 | ```yaml linenums="1" 17 | --- 18 | chave: valor # valor é uma string 19 | chave_int: 1 # valor é uma int 20 | chave_bool: true # valor é uma bool 21 | 22 | uma_lista: 23 | - item_0 24 | - item_1 25 | - item_2 26 | 27 | um_dict: 28 | nome: eduardo 29 | idade: 29 30 | 31 | # Comentários 32 | 33 | lista_inline: ['item_0', 'item_1', 'item_2'] 34 | 35 | dict_inline: {'nome': 'eduardo', 'idade': 29} 36 | ``` 37 | 38 | === "Python" 39 | 40 | ```python linenums="1" 41 | { 42 | "chave": "valor", 43 | "chave_int": 1, 44 | "chave_bool": true, 45 | "uma_lista": [ 46 | "item_0", 47 | "item_1", 48 | "item_2" 49 | ], 50 | "um_dict": { 51 | "nome": "eduardo", 52 | "idade": 29 53 | }, 54 | "lista_inline": [ 55 | "item_0", 56 | "item_1", 57 | "item_2" 58 | ], 59 | "dict_inline": { 60 | "nome": "eduardo", 61 | "idade": 29 62 | } 63 | } 64 | ``` 65 | 66 | ## Nosso primeiro playbook 67 | 68 | Vamos reproduzir a instalação e configuração do Ngix que fizemos via comandos `ad-hoc` no terminal: 69 | 70 | ```yaml linenums="1" title="web_server.yml" 71 | --- 72 | - name: Instalação do nginx 73 | hosts: linux # Grupo de hosts do inventário 74 | become: yes # Diz que vai escalonar privilégios. Equivalente ao {==-b==} 75 | 76 | tasks: # Descrição das tarefas que serão executadas 77 | 78 | - name: Instalação do nginx # Nome da tarefa 79 | package: # Nome do módulo 80 | # Argumentos do módulo 81 | state: present 82 | name: nginx 83 | 84 | - name: Inicialização do nginx 85 | systemd: 86 | state: started 87 | name: nginx 88 | ``` 89 | 90 | Dessa forma, no lugar de executar um único comando por vez, podemos disparar um playbook que executa diversas tarefas por vez: 91 | 92 | ```bash title="$ Execução no terminal" 93 | ansible-playbook web_server.yml 94 | ``` 95 | 96 | Você deve ver uma grande resposta como essa: 97 | 98 | ```bash title="resposta do terminal" 99 | ansible-playbook web_server.yml 100 | 101 | PLAY [Instalação do nginx] ***************************************************** 102 | 103 | TASK [Gathering Facts] ********************************************************* 104 | ok: [10.0.2.15] 105 | ok: [10.0.2.16] 106 | 107 | TASK [Instalação do nginx] ***************************************************** 108 | ok: [10.0.2.15] 109 | ok: [10.0.2.16] 110 | 111 | TASK [Inicialização do nginx] ************************************************** 112 | ok: [10.0.2.15] 113 | ok: [10.0.2.16] 114 | 115 | PLAY RECAP ********************************************************************* 116 | 10.0.2.15 : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 117 | 10.0.2.16 : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 118 | ``` 119 | 120 | O que significa que o ansible conseguiu executar o playbook com sucesso. 121 | 122 | ## Mais um playbook 123 | 124 | Sei que você já deve ter captado a ideia do playbook, mas que tal criarmos mais um? Vamos tentar reproduzir a configuração do emacs no localhost agora. Pois temos outros módulos e outros comandos para aprender: 125 | 126 | ```yaml linenums="1" title="emacs.yml" 127 | --- 128 | - name: Instalação e configuração do emacs 129 | hosts: localhost # Aqui mudamos para o localhost 130 | 131 | tasks: 132 | - name: Instalação do emacs 133 | 134 | become: yes # Diferente da outra config, somente esse passo será como root 135 | 136 | package: 137 | state: present 138 | name: emacs 139 | 140 | - name: Instalação do git 141 | become: yes 142 | package: 143 | name: git 144 | state: present 145 | 146 | - name: Clone do nosso repositório 147 | git: 148 | repo: https://github.com/dunossauro/dotfiles.git 149 | dest: config_files 150 | 151 | - name: Movendo os arquivos de configuração do emacs 152 | copy: 153 | dest: /home/vagrant/ 154 | src: /home/vagrant/config_files/.emacs.d 155 | ``` 156 | 157 | Se executarmos esse playbook podemos ver algumas mensagens diferentes na resposta: 158 | 159 | ```bash title="$ Execução no terminal" 160 | ansible-playbook emacs.yml 161 | ``` 162 | 163 | A resposta: 164 | 165 | ```bash title="resposta do terminal" 166 | PLAY [Instalação e configuração do emacs] ************************************** 167 | 168 | TASK [Gathering Facts] ********************************************************* 169 | ok: [localhost] 170 | 171 | TASK [Instalação do emacs] ***************************************************** 172 | ok: [localhost] 173 | 174 | TASK [Instalação do git] ******************************************************* 175 | ok: [localhost] 176 | 177 | TASK [Clone do nosso repositório] ********************************************** 178 | {==changed==}: [localhost] 179 | 180 | TASK [Movendo os arquivos de configuração do emacs] **************************** 181 | {==changed==}: [localhost] 182 | 183 | PLAY RECAP ********************************************************************* 184 | localhost : ok=5 {==changed=2==} unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 185 | ``` 186 | O status `changed` apareceu. Significa que o resultado desse comando foi diferente da primeira vez que foi executado. O que quer dizer que alguma coisa mudou desde a última execução. 187 | 188 | Provavelmente a resposta do ansible foi diferente, pois o clone não foi feito, o diretório já existia e o move também já tinha sido feito antes. 189 | 190 | ## Condicionais 191 | 192 | Vamos recapitular mais uma coisa que já instalamos no nosso ambiente. O `pipx` e o `httpie`. Não são pacotes tão relevantes para o andamento do tutorial, mas precisamos aprender coisas legais com ansible antes de fazer coisas realmente úteis. 193 | 194 | O pacote do `pipx` existe no repositório do `archlinux` como já vimos. O pacote se chama `python-pipx`. Vamos iniciar um playbook para essa instalação e ver os problemas que vamos encontrar no caminho: 195 | 196 | ```yaml title="pipx_httpie.yml" linenums="1" 197 | --- 198 | - name: Instalação do pipx e httpie 199 | hosts: linux # vale lembrar aqui que um dos linux é o arch e o outro o ubuntu 200 | 201 | tasks: 202 | - name: Instalação do pipx 203 | become: yes 204 | package: 205 | name: python-pipx 206 | state: present 207 | ``` 208 | 209 | Vamos executar para ver o que conseguimos com isso: 210 | 211 | ```bash title="$ Execução no terminal" 212 | ansible-playbook pipx_httpie.yml 213 | ``` 214 | 215 | Obteremos a seguinte resposta: 216 | 217 | ``` 218 | PLAY [Instalação do pipx e httpie] ********************************************* 219 | 220 | TASK [Gathering Facts] ********************************************************* 221 | ok: [10.0.2.15] 222 | ok: [10.0.2.16] 223 | 224 | TASK [Instalação do pipx] ****************************************************** 225 | {==fatal: [10.0.2.15]: FAILED! => {"changed": false, "msg": "No package matching 'python-pipx' is available"}==} 226 | changed: [10.0.2.16] 227 | 228 | PLAY RECAP ********************************************************************* 229 | 10.0.2.15 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0 230 | 10.0.2.16 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 231 | ``` 232 | 233 | Repare na linha destacada. A máquina associada ao ip `10.2.2.15` não tem um pacote no repositório chamado `python-pipx`. Esse foi o motivo da falha. O pacote existe no repositório do arch, porém não existe no repositório do ubuntu. 234 | 235 | Para resolver esse problema precisamos descobrir o nome do pacote no [repositório do ubuntu](https://packages.ubuntu.com/). E para saber isso precisamos saber qual a versão do ubuntu estamos usando. Você deve se lembrar que escrever no Vagrantfile `ubuntu/focal64`. Então, sabemos que a versão é a `focal`. Porém, se não soubéssemos essa informação. Como o ansible poderia nos ajudar a descobrir? 236 | 237 | ### O módulo setup 238 | 239 | O Ansible conta com um módulo chamado [setup](https://docs.ansible.com/ansible/2.7/modules/setup_module.html#setup-module). Esse módulo pode ser chamado via ad-hoc, mas também é a base para algumas variáveis nos playbooks. Primeiro vamos executar via ad-hoc: 240 | 241 | ```bash title="$ Execução no terminal" 242 | ansible ubuntu -m setup 243 | ``` 244 | 245 | Esse comando nos retornará uma resposta MUITO extensa. Que acabei deixando em um arquivo separado. Você pode acessar [aqui](https://github.com/dunossauro/ansible-lab/blob/main/stuff/resposta_ubuntu_setup.txt). Vamos destacar somente algumas coisas que fazem sentido para nosso passo atual: 246 | 247 | ```json linenums="344" 248 | "ansible_distribution": "Ubuntu", 249 | "ansible_distribution_file_parsed": true, 250 | "ansible_distribution_file_path": "/etc/os-release", 251 | "ansible_distribution_file_variety": "Debian", 252 | "ansible_distribution_major_version": "20", 253 | "ansible_distribution_release": "focal", 254 | "ansible_distribution_version": "20.04", 255 | ``` 256 | 257 | Podemos ver que o ansible sabe qual a distribuição que está sendo usada `Ubuntu`, qual a versão do sistema `20.04` e a release que está sendo executada `focal`. O `setup` consegue mostrar diversos outros dados. Sobre as interfaces de rede, sobre memória, etc. 258 | 259 | Aproveitando que já estamos vendo o módulo `setup`, podemos usar a função de filtro do módulo para exibir somente as informações que precisamos. Qualquer coisa que comece com `ansible_distribution`: 260 | 261 | 262 | ```bash title="$ Execução no terminal" 263 | ansible ubuntu -m setup -a "filter=ansible_distribution*" 264 | ``` 265 | 266 | Que nos retornará os mesmos dados que destaquei: 267 | 268 | ``` 269 | 10.0.2.15 | SUCCESS => { 270 | "ansible_facts": { 271 | "ansible_distribution": "Ubuntu", 272 | "ansible_distribution_file_parsed": true, 273 | "ansible_distribution_file_path": "/etc/os-release", 274 | "ansible_distribution_file_variety": "Debian", 275 | "ansible_distribution_major_version": "20", 276 | "ansible_distribution_release": "focal", 277 | "ansible_distribution_version": "20.04", 278 | "discovered_interpreter_python": "/usr/bin/python3" 279 | }, 280 | "changed": false 281 | } 282 | ``` 283 | 284 | Agora que sabemos que é o Ubuntu Focal, podemos voltar ao repositório. O pacote existe, porém, com outro nome [pipx](https://packages.ubuntu.com/focal/python/pipx). 285 | 286 | ### A clausula `when` 287 | 288 | Como disse, as variáveis do setup podem ser invocadas dentro do playbook. Dessa forma podemos criar validações condicionais no nosso playbook. Vamos criar uma restrição para que a task seja executada somente no arch linux: 289 | 290 | ```yaml title="pipx_httpie.yml" linenums="1" 291 | --- 292 | - name: Instalação do pipx e httpie 293 | hosts: linux # vale lembrar aqui que um dos linux é o arch e o outro o ubuntu 294 | 295 | tasks: 296 | - name: Instalação do pipx {++no Arch++} 297 | become: yes 298 | package: 299 | name: python-pipx 300 | state: present 301 | {++when++}: {++ansible_distribution == Archlinux'++} 302 | ``` 303 | 304 | > As linhas destacadas mostra somente as alterações que fizemos no playbook. 305 | 306 | Dessa forma, a task `Instalação do pipx no Arch` só será executada quando a distribuição for `Archlinux`. Vamos testar: 307 | 308 | ```bash title="$ Execução no terminal" 309 | ansible-playbook pipx_httpie.yml 310 | ``` 311 | 312 | ```bash title="Resultado do shell" 313 | 314 | PLAY [Instalação do pipx e httpie] ******************************************************** 315 | 316 | TASK [Gathering Facts] ******************************************************************** 317 | ok: [10.0.2.15] 318 | ok: [10.0.2.16] 319 | 320 | TASK [Instalação do pipx no Arch] ********************************************************* 321 | {==skipping: [10.0.2.15]==} 322 | ok: [10.0.2.16] 323 | 324 | PLAY RECAP ******************************************************************************** 325 | 10.0.2.16 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 326 | 10.0.2.15 : ok=1 changed=0 unreachable=0 failed=0 {==skipped=1==} rescued=0 ignored=0 327 | ``` 328 | 329 | Com isso, podemos ver o status `skipped`. Isso quer dizer que o passo de instalar no arch, quando passou pela instalação no ubuntu "pulou" esse passo. Sabendo disso, podemos criar uma nova task específica para o ubuntu que pule no arch também: 330 | 331 | ```yaml title="pipx_httpie.yml" linenums="13" 332 | - name: Instalação do pipx no Ubuntu 333 | become: yes 334 | package: 335 | name: pipx 336 | state: present 337 | when: ansible_distribution == 'Ubuntu' 338 | ``` 339 | 340 | Dessa forma, quando executarmos o playbook teremos certeza que a execução vai acontecer nos dois nós. Mesmo que em tasks diferentes. 341 | 342 | ```bash title="$ Execução no terminal e a parte importante do resultado" 343 | ansible-playbook pipx_httpie.yml 344 | 345 | TASK [Instalação do pipx no Arch] ********************************************************* 346 | skipping: [10.0.2.15] 347 | ok: [10.0.2.16] 348 | 349 | TASK [Instalação do pipx no Ubuntu] ******************************************************* 350 | skipping: [10.0.2.16] 351 | ok: [10.0.2.15] 352 | ``` 353 | 354 | Desta forma não precisamos mais nos preocupar com os pacotes específicos de cada sistema, podemos criar uma task para cada sistema. Em casos extremos isso pode ser necessário. Mas será que não existe uma forma mais simples de resolver esse problema? 355 | 356 | ## Expressões e variáveis 357 | 358 | Quando chamamos o setup, vimos que o ansible consegue carregar diversas variáveis durante a execução. Mas será que nesse caso não conseguiríamos criar uma variável nossa? Aí poderíamos validar antes e evitar escrever duas tasks. 359 | 360 | ### Expressões 361 | 362 | O Ansible usa um motor de templates chamado [Jinja](https://palletsprojects.com/p/jinja/). O jinja fornece uma forma de chamar expressões de código Python dentro de templates. Assim, quando o ansible executa um playbook ele também avalia e executa as expressões do jinja dentro do código. 363 | 364 | As expressões no jinja são feitas usando duas chaves delimitador `{{ minha_expressão }}`. E dentre dessa expressão, qualquer código python pode ser inserido. Por exemplo, podemos fazer um `if` para resolver nosso caso e ter uma única task. Por exemplo: 365 | 366 | ```yaml title="pipx_httpie.yml" linenums="5" 367 | tasks: 368 | - name: Instalação do pipx 369 | become: yes 370 | package: 371 | name: {++"{{ 'pipx' if ansible_distribution == 'Ubuntu' else 'python-pipx'}}"++} 372 | state: present 373 | ``` 374 | 375 | !!! note "Nota sobre expressões no Asnbile" 376 | Embora para o jinja somente precise ser usado `{{ expressão }}`. O Ansible exige que esses blocos estejam também entre aspas. Ficando `'{{ expressão }}'`. 377 | 378 | Desta forma acabamos resolvendo o problema que tínhamos em ter duas tasks para executar a mesma tarefa em sistemas diferentes. Vamos ver o resultado: 379 | 380 | ```bash title="$ Execução no terminal e a parte importante do resultado" 381 | ansible-playbook pipx_httpie.yml 382 | 383 | TASK [Instalação do pipx no Arch] ********************************************************* 384 | ok: [10.0.2.15] 385 | ok: [10.0.2.16] 386 | ``` 387 | 388 | Assim podemos ser mais eficientes em criar regras. Já o que template pode estender código python. 389 | 390 | ### As variáveis no ansible 391 | 392 | Da mesma forma que podemos criar expressões complexas no jinja. Também podemos chamar somente variáveis. Por exemplo, `"{{ variavel }}"`. Assim podemos declarar as expressões em um lugar específico do playbook para deixar mais limpo ou passar as mesmas via linha de comando. 393 | 394 | ### Variáveis no playbook 395 | 396 | Para isso, podemos trocar o nome do pacote do pipx no playbook para uma variável: 397 | 398 | ```yaml title="pipx_httpie.yml" linenums="1" 399 | --- 400 | - name: Instalação do pipx e httpie 401 | hosts: linux 402 | 403 | {++vars++}: 404 | {++pipx++}: {++"{{ 'pipx' if ansible_distribution == 'Ubuntu' else 'python-pipx'}}"++} 405 | 406 | tasks: 407 | - name: Instalação do pipx 408 | become: yes 409 | package: 410 | name: {++'{{ pipx }}'++} 411 | state: present 412 | ``` 413 | 414 | Assim temos um playbook mais limpo. Pois todo o código complicado do jinja fica em um lugar específico e no topo do arquivo para ficar fácil a consulta. 415 | 416 | > Não vou executar esse playbook agora, pois teremos o mesmo resultado da execução anterior. 417 | 418 | ### Variáveis via linha de comando 419 | 420 | Outra funcionalidade importante do ansible é conseguir sobrescrever as variáveis de um playbook usando a linha de comando como base. Chamar via linha de comando tem uma ordem de precedência maior que as variáveis definidas no playbook. Então, quando o ansible for chamado, as variáveis definidas no campo `vars` serão substituídas pelas variáveis que forem passadas na linha de comando: 421 | 422 | ```bash title="$ Execução no terminal e a parte importante do resultado" 423 | ansible-playbook pipx_httpie.yml --extra-vars "pipx=pipx" 424 | 425 | TASK [Instalação do pipx] ***************************************************************** 426 | ok: [10.0.2.15] 427 | fatal: [10.0.2.16]: FAILED! => {=={"changed": false, "cmd": ["/usr/bin/pacman", "--upgrade", "--print-format", "%n", "pipx"], "msg": "Failed to list package pipx", "rc": 1, "stderr": "error: 'pipx': could not find or read package\n", "stderr_lines": ["error: 'pipx': could not find or read package"], "stdout": "loading packages...\n", "stdout_lines": ["loading packages..."]}==} 428 | ``` 429 | 430 | Como era de se esperar, o pacote `pipx` não existe no arch, seu nome é `python-pipx` por conta disso, o comando não foi executado com sucesso. Nosso objetivo, porém, era explorar a chamada de variáveis via linha de comando. 431 | 432 | ### Arquivos de variáveis 433 | 434 | Uma forma de evitar expressões do jinja e também chamar variáveis por linha de comando é criar um arquivo só para as variáveis. Dessa forma, caso tenha alguma variável que não possa ser exposta, como endereço de um banco de dados. Esses valores ficam de fora da configuração. 435 | 436 | 437 | ```yaml title="variaveis.yml" linenums="1" 438 | --- 439 | pipx: "{{ 'pipx' if ansible_distribution == 'Ubuntu' else 'python-pipx'}}" 440 | ``` 441 | 442 | Dessa forma podemos limpar o nosso arquivo `pipx_httpie.yml`: 443 | 444 | ```yaml title="pipx_httpie.yml" linenums="1" hl_lines="9" 445 | --- 446 | - name: Instalação do pipx e httpie 447 | hosts: linux 448 | 449 | tasks: 450 | - name: Instalação do pipx 451 | become: yes 452 | package: 453 | name: '{{ pipx }}' 454 | state: present 455 | ``` 456 | 457 | E quando formos executar o playbook, só precisamos passar o arquivo de configuração para as variáveis: 458 | 459 | ```bash title="$ Execução no terminal e a parte importante do resultado" 460 | ansible-playbook pipx_httpie.yml -e @variaveis.yml 461 | 462 | TASK [Instalação do pipx] ***************************************************************** 463 | ok: [10.0.2.15] 464 | ok: [10.0.2.16] 465 | ``` 466 | 467 | Assim demos uma limpada no nosso arquivo de playbook e claro, podemos definir diversas outras variáveis no arquivo. Mas, você pode tentar depois :heart: 468 | 469 | 470 | ### Arquivos de variáveis por grupo 471 | 472 | Outra coisa que pode facilitar na hora de usar as variáveis é criar variáveis específicas para grupos. O ansible tem um caminho específico para onde esses arquivos de variáveis devem ser colocados: `/etc/ansible/group_vars/`. 473 | 474 | Para resolver isso, vamos criar um grupo de variáveis para o ubuntu: 475 | 476 | ```yaml title="/etc/ansible/group_vars/ubuntu.yml" linenums="1" 477 | --- 478 | pipx: pipx 479 | ``` 480 | 481 | e um arquivo para o arch: 482 | ```yaml title="/etc/ansible/group_vars/arch.yml" linenums="1" 483 | --- 484 | pipx: python-pipx 485 | ``` 486 | 487 | Dessa forma, quando formos executar o playbook não precisamos mais especificar as variáveis comuns. Cada sistema tem sua versão de `pipx` conforme os grupos do inventário: 488 | 489 | 490 | ```bash title="$ Execução no terminal e a parte importante do resultado" 491 | ansible-playbook pipx_httpie.yml 492 | 493 | TASK [Instalação do pipx] ***************************************************************** 494 | ok: [10.0.2.15] 495 | ok: [10.0.2.16] 496 | ``` 497 | -------------------------------------------------------------------------------- /docs/06_tasks.md: -------------------------------------------------------------------------------- 1 | # Tasks 2 | 3 | Embora tenhamos usados tasks em praticamente tudo até aqui. Acredito que valha um momento específico para falar sobre elas. Pois nem sempre as coisas dão certo e às vezes precisamos debugar as tarefas no Ansible. Então nessa parte vamos falar um pouco sobre tasks, um pouco sobre debug e um pouco sobre agrupamento de tasks. 4 | 5 | 6 | ## Uma task qualquer 7 | 8 | Para exemplificar uma task, quero fazer com vocês a instalação do pyenv. Costuma dar bastante problema, pois o SSH usado pelo Ansible não consegue reconhecer o `.bashrc` 9 | 10 | Para começar, vamos instalar o git e fazer o clone do pyenv: 11 | 12 | ```yaml title="config_python.yml" linenums="1" 13 | --- 14 | - name: Configuração do ambiente python 15 | hosts: linux 16 | 17 | tasks: 18 | - name: Install git 19 | become: yes 20 | package: 21 | name: git 22 | state: present 23 | 24 | - name: Clone Pyenv 25 | git: 26 | repo: https://github.com/pyenv/pyenv.git 27 | dest: ~/.pyenv 28 | ``` 29 | 30 | Porém, a configuração do pyenv depende de que o arquivo `./bashrc` seja modificado para que o pyenv funcione de fato. Então agora vamos aprender mais um módulo. O módulo [blockinfile](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/blockinfile_module.html). Ele permite que adicionemos um bloco de texto em um arquivo qualquer: 31 | 32 | ```yaml title="config_python.yml" linenums="17" 33 | - name: config pyenv 34 | blockinfile: 35 | dest: ~/.bashrc 36 | block: | 37 | echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc 38 | echo 'eval "$(pyenv init -)"' >>~/.bashrc 39 | echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc 40 | echo 'PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc 41 | ``` 42 | 43 | ## Register 44 | 45 | Vamos supor que queremos checar o que está escrito dentro do arquivo `.bashrc` para saber se ele está escrito da maneira correta. Para isso vamos criar mais uma task. Para isso vamos usar o módulo `shell` e também a funcionalidade de registro em variáveis do ansible: 46 | 47 | ```yaml title="config_python.yml" linenums="27" 48 | - name: Show bashrc 49 | shell: cat ~/.bashrc 50 | register: bashrc 51 | ``` 52 | 53 | Dessa forma, por termos chamado `register` o ansible vai armazenar o resultado da tarefa `Show bashrc` na variável `bashrc`. E podemos acessar ela usando o módulo de `debug`: 54 | 55 | ```yaml title="config_python.yml" linenums="30" 56 | - name: Checking bashrc 57 | debug: 58 | msg: "{{ bashrc.stdout.split('\n') }}" 59 | ``` 60 | 61 | Quando o playbook for executado, nos mostrará de maneira formatada o `stdout` da tarefa `Show bashrc`: 62 | 63 | ```bash title="$ Execução no terminal e a parte importante do resultado" 64 | ansible-playbook config_python.yml 65 | 66 | TASK [Show bashrc] ******************************************************************************* 67 | changed: [IP] 68 | 69 | TASK [Checking bashrc] ******************************************************************** 70 | ok: [IP] => { 71 | "msg": [ 72 | "#", 73 | "# ~/.bashrc", 74 | "#", 75 | "", 76 | "# If not running interactively, don't do anything", 77 | "[[ $- != *i* ]] && return", 78 | "", 79 | "alias ls='ls --color=auto'", 80 | "PS1='[\\u@\\h \\W]\\$ '", 81 | "# BEGIN ANSIBLE MANAGED BLOCK", 82 | "echo 'export PATH=\"$HOME/.pyenv/bin:$PATH\"' >> ~/.bashrc", 83 | "echo 'eval \"$(pyenv init -)\"' >>~/.bashrc", 84 | "echo 'eval \"$(pyenv virtualenv-init -)\"' >> ~/.bashrc", 85 | "echo 'PATH=\"$HOME/.local/bin:$PATH\"' >> ~/.bashrc", 86 | "# END ANSIBLE MANAGED BLOCK" 87 | ] 88 | } 89 | ``` 90 | 91 | O que significa que conseguimos chamar o debug. Porém, em alguns momentos as tasks podem e vão dar errado. Então precisamos entender como prosseguir, caso isso aconteça. 92 | 93 | ## Debug de tasks 94 | 95 | Vamos executar uma ação que tenho certeza que vai dar erro por conta das configurações que fizemos até agora para entender como podemos checar as mensagens de erro. 96 | 97 | Em teoria, se temos o pyenv instalado, podemos pedir para que ele instale a versão `3.11` do python: 98 | 99 | ```yaml title="config_python.yml" linenums="34" 100 | {==- block==}: 101 | - name: install python3.11 102 | shell: pyenv install -s 3.11:latest 103 | register: pyenv_result 104 | ``` 105 | 106 | Note que inseri um bloco no playbook chamado `block`. Ele nos ajuda a executar uma tarefa na sequência caso uma delas dê erro. E para isso vamos adicionar um parâmetro para esse bloco chamado `rescue`. Ficando com esse bloco: 107 | 108 | ```yaml title="config_python.yml" linenums="34" 109 | - block: 110 | - name: install python3.11 111 | shell: pyenv install -s 3.11:latest 112 | register: pyenv_result 113 | rescue: 114 | - name: Debug pyenv fail 115 | debug: 116 | msg: "{{pyenv_result.stderr.split('\n') }}" 117 | when: pyenv_result.failed 118 | ``` 119 | 120 | > `rescue` pode ser traduzido como resgatar ou salvar. 121 | 122 | Dessa forma, caso alguma de nossas instalações do python 3.11 dê erro. Ele vai nos mostrar de forma formatada e simples o que aconteceu nessa execução: 123 | 124 | ```bash title="$ Execução no terminal e a parte importante do resultado" 125 | ansible-playbook config_python.yml 126 | 127 | TASK [install python3.11] ***************************************************************** 128 | fatal: [IP ARCH]: FAILED! => {"changed": true, "cmd": "~/.pyenv/bin/pyenv install -s 3.11:latest", "delta": "0:00:03.326569", "end": "2022-11-16 16:03:38.101843", "msg": "non-zero return code", "rc": 1, "start": "2022-11-16 16:03:34.775274", "stderr": "Downloading Python-3.11.0.tar.xz...\n-> https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tar.xz\nInstalling Python-3.11.0...\n\nBUILD FAILED (Ubuntu 20.04 using python-build 2.3.6-13-g4c261e6e)\n\nInspect or clean up the working tree at /tmp/python-build.20221116160334.6412\nResults logged to /tmp/python-build.20221116160334.6412.log\n\nLast 10 log lines:\nchecking for pkg-config... no\nchecking for --enable-universalsdk... no\nchecking for --with-universal-archs... no\nchecking MACHDEP... \"linux\"\nchecking for gcc... no\nchecking for cc... no\nchecking for cl.exe... no\nconfigure: error: in `/tmp/python-build.20221116160334.6412/Python-3.11.0':\nconfigure: error: no acceptable C compiler found in $PATH\nSee `config.log' for more details", "stderr_lines": ["Downloading Python-3.11.0.tar.xz...", "-> https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tar.xz", "Installing Python-3.11.0...", "", "BUILD FAILED (Ubuntu 20.04 using python-build 2.3.6-13-g4c261e6e)", "", "Inspect or clean up the working tree at /tmp/python-build.20221116160334.6412", "Results logged to /tmp/python-build.20221116160334.6412.log", "", "Last 10 log lines:", "checking for pkg-config... no", "checking for --enable-universalsdk... no", "checking for --with-universal-archs... no", "checking MACHDEP... \"linux\"", "checking for gcc... no", "checking for cc... no", "checking for cl.exe... no", "configure: error: in `/tmp/python-build.20221116160334.6412/Python-3.11.0':", "configure: error: no acceptable C compiler found in $PATH", "See `config.log' for more details"], "stdout": "", "stdout_lines": []} 129 | fatal: [IP UBUNTU]: FAILED! => {"changed": true, "cmd": "~/.pyenv/bin/pyenv install -s 3.11:latest", "delta": "0:00:04.143002", "end": "2022-11-16 16:03:38.885921", "msg": "non-zero return code", "rc": 1, "start": "2022-11-16 16:03:34.742919", "stderr": "Downloading Python-3.11.0.tar.xz...\n-> https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tar.xz\nInstalling Python-3.11.0...\n\nBUILD FAILED (Arch Linux using python-build 2.3.6-13-g4c261e6e)\n\nInspect or clean up the working tree at /tmp/python-build.20221116160335.2683\nResults logged to /tmp/python-build.20221116160335.2683.log\n\nLast 10 log lines:\nchecking for pkg-config... no\nchecking for --enable-universalsdk... no\nchecking for --with-universal-archs... no\nchecking MACHDEP... \"linux\"\nchecking for gcc... no\nchecking for cc... no\nchecking for cl.exe... no\nconfigure: error: in `/tmp/python-build.20221116160335.2683/Python-3.11.0':\nconfigure: error: no acceptable C compiler found in $PATH\nSee `config.log' for more details", "stderr_lines": ["Downloading Python-3.11.0.tar.xz...", "-> https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tar.xz", "Installing Python-3.11.0...", "", "BUILD FAILED (Arch Linux using python-build 2.3.6-13-g4c261e6e)", "", "Inspect or clean up the working tree at /tmp/python-build.20221116160335.2683", "Results logged to /tmp/python-build.20221116160335.2683.log", "", "Last 10 log lines:", "checking for pkg-config... no", "checking for --enable-universalsdk... no", "checking for --with-universal-archs... no", "checking MACHDEP... \"linux\"", "checking for gcc... no", "checking for cc... no", "checking for cl.exe... no", "configure: error: in `/tmp/python-build.20221116160335.2683/Python-3.11.0':", "configure: error: no acceptable C compiler found in $PATH", "See `config.log' for more details"], "stdout": "", "stdout_lines": []} 130 | 131 | TASK [Debug pyenv fail] ******************************************************************* 132 | ok: [IP ARCH] => { 133 | "msg": [ 134 | "Downloading Python-3.11.0.tar.xz...", 135 | "-> https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tar.xz", 136 | "Installing Python-3.11.0...", 137 | "", 138 | "BUILD FAILED (Arch Linux using python-build 2.3.6-13-g4c261e6e)", 139 | "", 140 | "Inspect or clean up the working tree at /tmp/python-build.20221116160335.2683", 141 | "Results logged to /tmp/python-build.20221116160335.2683.log", 142 | "", 143 | "Last 10 log lines:", 144 | "checking for pkg-config... no", 145 | "checking for --enable-universalsdk... no", 146 | "checking for --with-universal-archs... no", 147 | "checking MACHDEP... \"linux\"", 148 | "checking for gcc... no", 149 | "checking for cc... no", 150 | "checking for cl.exe... no", 151 | "configure: error: in `/tmp/python-build.20221116160335.2683/Python-3.11.0':", 152 | "configure: error: no acceptable C compiler found in $PATH", 153 | "See `config.log' for more details" 154 | ] 155 | } 156 | ok: [IP UBUNTU] => { 157 | "msg": [ 158 | "Downloading Python-3.11.0.tar.xz...", 159 | "-> https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tar.xz", 160 | "Installing Python-3.11.0...", 161 | "", 162 | "BUILD FAILED (Ubuntu 20.04 using python-build 2.3.6-13-g4c261e6e)", 163 | "", 164 | "Inspect or clean up the working tree at /tmp/python-build.20221116160334.6412", 165 | "Results logged to /tmp/python-build.20221116160334.6412.log", 166 | "", 167 | "Last 10 log lines:", 168 | "checking for pkg-config... no", 169 | "checking for --enable-universalsdk... no", 170 | "checking for --with-universal-archs... no", 171 | "checking MACHDEP... \"linux\"", 172 | "checking for gcc... no", 173 | "checking for cc... no", 174 | "checking for cl.exe... no", 175 | "configure: error: in `/tmp/python-build.20221116160334.6412/Python-3.11.0':", 176 | "configure: error: no acceptable C compiler found in $PATH", 177 | "See `config.log' for more details" 178 | ] 179 | } 180 | ``` 181 | 182 | Com isso, conseguimos escapar do erro grande da task `install python3.11` e ficamos com um erro fácil de ser lido na task `Debug pyenv fail`. 183 | 184 | 185 | Nas duas respostas temos o mesmo erro. Não existe um compilador instalado. Então precisamos instalar os pacotes necessários para que o pyenv consiga fazer a compilação. Elas estão listadas [aqui](https://github.com/pyenv/pyenv/wiki#suggested-build-environment) e separadas por sistema operacional. Bora criar mais duas tasks para garantir que tudo funcione. 186 | 187 | Aproveitando que vamos fazer tasks condicionais. Vou aproveitar para usar os gerenciadores específicos das distribuições para simplificar o processo. Para os pacotes do ubuntu, vamos usar o módulo do [apt](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html) e para o arch vamos usar o módulo do [pacman](https://docs.ansible.com/ansible/latest/collections/community/general/pacman_module.html): 188 | 189 | ```yaml title="config_python.yml" linenums="17" 190 | - name: Install build dependencies (ubuntu) 191 | when: ansible_distribution == 'Ubuntu' 192 | become: yes 193 | apt: 194 | update_cache: yes 195 | pkg: 196 | - make 197 | - build-essential 198 | - libssl-dev 199 | - zlib1g-dev 200 | - libbz2-dev 201 | - libreadline-dev 202 | - libsqlite3-dev 203 | - wget 204 | - curl 205 | - llvm 206 | - libncursesw5-dev 207 | - xz-utils 208 | - tk-dev 209 | - libxml2-dev 210 | - libxmlsec1-dev 211 | - libffi-dev 212 | - liblzma-dev 213 | 214 | - name: Install build dependencies (arch) 215 | when: ansible_distribution == 'Archlinux' 216 | become: yes 217 | pacman: 218 | update_cache: yes 219 | name: 220 | - base-devel 221 | - openssl 222 | - zlib 223 | - xz 224 | - tk 225 | ``` 226 | 227 | > Por contar com a instalação de muitos pacotes, pode demorar um pouco 228 | 229 | Você pode checar o arquivo todo [aqui](https://github.com/dunossauro/ansible-lab/blob/main/playbooks/config_python.yml) 230 | 231 | 232 | ``` 233 | TASK [Install build dependencies (ubuntu)] ************************************************ 234 | skipping: [IP ARCH] 235 | changed: [IP UBUNTU] 236 | 237 | TASK [Install build dependencies (arch)] ************************************************** 238 | skipping: [IP UBUNTU] 239 | changed: [IP ARCH] 240 | 241 | TASK [install python3.11] ***************************************************************** 242 | fatal: [IP ARCH]: FAILED! => {"changed": true, "cmd": "~/.pyenv/bin/pyenv install -s 3.11:latest", "delta": "0:00:03.715686", "end": "2022-11-16 16:39:52.892123", "msg": "non-zero return code", "rc": 1, "start": "2022-11-16 16:39:49.176437", "stderr": "Downloading Python-3.11.0.tar.xz...\n-> https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tar.xz\n/home/vagrant/.pyenv/plugins/python-build/bin/python-build: line 245: pushd: write error: No space left on device\nInstalling Python-3.11.0...\n\nBUILD FAILED (Arch Linux using python-build 2.3.6-13-g4c261e6e)\n\nInspect or clean up the working tree at /tmp/python-build.20221116163949.4095\nResults logged to /tmp/python-build.20221116163949.4095.log\n\nLast 10 log lines:\ntar: Python-3.11.0/Lib/test/test___future__.py: Cannot write: No space left on device\ntar: Python-3.11.0/Lib/test/test_genericpath.py: Cannot write: No space left on device\ntar: Python-3.11.0/Lib/test/ssltests.py: Cannot write: No space left on device\ntar: Python-3.11.0/Lib/test/test_random.py: Cannot write: No space left on device\ntar: Python-3.11.0/Lib/test/test_signal.py: Cannot write: No space left on device\ntar: Python-3.11.0/Lib/test/bisect_cmd.py: Cannot write: No space left on device\ntar: Python-3.11.0/Lib/test/test_sysconfig.py: Cannot write: No space left on device\ntar: Python-3.11.0/Lib/test/bad_coding2.py: Cannot write: No space left on device\ntar: Python-3.11.0/Lib/test/test_codecmaps_kr.py: Cannot write: No space left on device\ntar: Pyt", "stderr_lines": ["Downloading Python-3.11.0.tar.xz...", "-> https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tar.xz", "/home/vagrant/.pyenv/plugins/python-build/bin/python-build: line 245: pushd: write error: No space left on device", "Installing Python-3.11.0...", "", "BUILD FAILED (Arch Linux using python-build 2.3.6-13-g4c261e6e)", "", "Inspect or clean up the working tree at /tmp/python-build.20221116163949.4095", "Results logged to /tmp/python-build.20221116163949.4095.log", "", "Last 10 log lines:", "tar: Python-3.11.0/Lib/test/test___future__.py: Cannot write: No space left on device", "tar: Python-3.11.0/Lib/test/test_genericpath.py: Cannot write: No space left on device", "tar: Python-3.11.0/Lib/test/ssltests.py: Cannot write: No space left on device", "tar: Python-3.11.0/Lib/test/test_random.py: Cannot write: No space left on device", "tar: Python-3.11.0/Lib/test/test_signal.py: Cannot write: No space left on device", "tar: Python-3.11.0/Lib/test/bisect_cmd.py: Cannot write: No space left on device", "tar: Python-3.11.0/Lib/test/test_sysconfig.py: Cannot write: No space left on device", "tar: Python-3.11.0/Lib/test/bad_coding2.py: Cannot write: No space left on device", "tar: Python-3.11.0/Lib/test/test_codecmaps_kr.py: Cannot write: No space left on device", "tar: Pyt"], "stdout": "", "stdout_lines": []} 243 | changed: [IP UBUNTU] 244 | 245 | TASK [Debug pyenv fail] ******************************************************************* 246 | ok: [IP ARCH] => { 247 | "msg": [ 248 | "Downloading Python-3.11.0.tar.xz...", 249 | "-> https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tar.xz", 250 | "/home/vagrant/.pyenv/plugins/python-build/bin/python-build: line 245: pushd: write error: No space left on device", 251 | "Installing Python-3.11.0...", 252 | "", 253 | "BUILD FAILED (Arch Linux using python-build 2.3.6-13-g4c261e6e)", 254 | "", 255 | "Inspect or clean up the working tree at /tmp/python-build.20221116163949.4095", 256 | "Results logged to /tmp/python-build.20221116163949.4095.log", 257 | "", 258 | "Last 10 log lines:", 259 | "tar: Python-3.11.0/Lib/test/test___future__.py: Cannot write: No space left on device", 260 | "tar: Python-3.11.0/Lib/test/test_genericpath.py: Cannot write: No space left on device", 261 | "tar: Python-3.11.0/Lib/test/ssltests.py: Cannot write: No space left on device", 262 | "tar: Python-3.11.0/Lib/test/test_random.py: Cannot write: No space left on device", 263 | "tar: Python-3.11.0/Lib/test/test_signal.py: Cannot write: No space left on device", 264 | "tar: Python-3.11.0/Lib/test/bisect_cmd.py: Cannot write: No space left on device", 265 | "tar: Python-3.11.0/Lib/test/test_sysconfig.py: Cannot write: No space left on device", 266 | "tar: Python-3.11.0/Lib/test/bad_coding2.py: Cannot write: No space left on device", 267 | "tar: Python-3.11.0/Lib/test/test_codecmaps_kr.py: Cannot write: No space left on device", 268 | "tar: Pyt" 269 | ] 270 | } 271 | ``` 272 | 273 | Temos um erro por não ter espaço em disco para compilar o 3.11 no arch. Para resolver essa questão [clique aqui](/99_problemas_comuns) 274 | 275 | ## Agrupamento de tasks 276 | 277 | Agora que fizemos muitas tasks para uma instalação relativamente simples. Uma coisa que podemos fazer para organizar tudo é dividir as tasks em arquivos menores e usar o módulo [import_task](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/import_tasks_module.html). 278 | 279 | Assim podemos quebrar nosso arquivão para a configuração do pyenv em arquivos bem menores. Vamos criar um novo playbook chamado `play_tasks.yaml` e separar por blocos: 280 | 281 | ```yaml title="play_tasks.yaml" 282 | --- 283 | - name: Configura o ambiente de desenvolvimento 284 | hosts: linux 285 | gather_facts: true 286 | 287 | - name: Dependências de desenvolvimento 288 | become: true 289 | import_tasks: tasks/dev_env.yml 290 | 291 | - name: Pyenv install 292 | import_tasks: tasks/pyenv.yml 293 | 294 | - name: Install python 3.11 295 | import_tasks: tasks/py_311.yml 296 | ``` 297 | 298 | E com isso podemos quebrar nosso grande playbook em arquivos de task: 299 | 300 | > Para ver [todos os arquivos](https://github.com/dunossauro/ansible-lab/tree/main/playbooks/tasks) 301 | 302 | === "tasks/dev_env.yml" 303 | ```yaml 304 | - name: Install git 305 | become: yes 306 | package: 307 | name: git 308 | state: present 309 | 310 | - name: Install build dependencies (ubuntu) 311 | when: ansible_distribution == 'Ubuntu' 312 | become: yes 313 | apt: 314 | update_cache: yes 315 | pkg: 316 | - make 317 | - build-essential 318 | - libssl-dev 319 | - zlib1g-dev 320 | - libbz2-dev 321 | - libreadline-dev 322 | - libsqlite3-dev 323 | - wget 324 | - curl 325 | - llvm 326 | - libncursesw5-dev 327 | - xz-utils 328 | - tk-dev 329 | - libxml2-dev 330 | - libxmlsec1-dev 331 | - libffi-dev 332 | - liblzma-dev 333 | 334 | - name: Install build dependencies (arch) 335 | when: ansible_distribution == 'Archlinux' 336 | become: yes 337 | pacman: 338 | update_cache: yes 339 | name: 340 | - base-devel 341 | - openssl 342 | - zlib 343 | - xz 344 | - tk 345 | ``` 346 | 347 | === "tasks/pyenv.yml" 348 | ```yaml 349 | - name: Clone Pyenv 350 | git: 351 | repo: https://github.com/pyenv/pyenv.git 352 | dest: ~/.pyenv 353 | 354 | - name: Config pyenv 355 | blockinfile: 356 | dest: ~/.bashrc 357 | block: | 358 | echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc 359 | echo 'eval "$(pyenv init -)"' >>~/.bashrc 360 | echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc 361 | echo 'PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc 362 | ``` 363 | 364 | === "tasks/py_311.yml" 365 | ```yaml 366 | - block: 367 | - name: install python3.11 368 | shell: ~/.pyenv/bin/pyenv install -s 3.11:latest 369 | register: pyenv_result 370 | rescue: 371 | - name: Debug pyenv fail 372 | debug: 373 | msg: "{{pyenv_result.stderr.split('\n') }}" 374 | when: pyenv_result.failed 375 | ``` 376 | 377 | E com isso temos um entendimento um pouco mais profundo de como lidar com tasks. 378 | -------------------------------------------------------------------------------- /docs/07_ansible_galaxy.md: -------------------------------------------------------------------------------- 1 | # Ansible Galaxy 2 | 3 | Como vimos, o nome Ansible vem da história do `mundo de Rocannon` na história de Ursula K. Le Guin. Rocannon é um antropólogo que precisa se comunicar com outros planetas usando o Ansible. 4 | 5 | O Ansible Galaxy é uma forma de compartilhar receitas com outras pessoas usando Ansible. Você pode acessar o Galaxy nesse [link](https://galaxy.ansible.com/) 6 | 7 | ![](./images/galaxy.png) 8 | 9 | Existem diversas receitas e módulos prontos e feitos pela comunidade que podemos explorar e instalar em nosso nó controlador para automatizar tarefas de forma mais eficiente. 10 | 11 | ## Instalando um módulo 12 | 13 | Uma coisa que gosto bastante no meu ambiente pessoal é de instalar diversas versões do python. Isso me ajuda a trabalhar melhor e testar código em diversas versões do python. O Ansible, porém, não conta com um módulo nativo para lidar como o [pyenv](https://github.com/pyenv/pyenv) que é um instalador de versões do python. 14 | 15 | Para isso, podemos contar com o Galaxy. Uma pessoa da comunidade criou um pacote para gerenciar o [pyenv](https://galaxy.ansible.com/staticdev/pyenv). 16 | 17 | Para instalar essa role temos que o usar o comando `ansible-galaxy`: 18 | 19 | ```bash title="$ Execução no terminal" 20 | ansible-galaxy install staticdev.pyenv 21 | ``` 22 | 23 | > `staticdev` é o nome do perfil da pessoa que criou o pacote para o galaxy 24 | 25 | ```bash title="Resposta do terminal" 26 | Starting galaxy role install process 27 | - downloading role 'pyenv', owned by staticdev 28 | - downloading role from https://github.com/staticdev/ansible-role-pyenv/archive/2.6.2.tar.gz 29 | - extracting staticdev.pyenv to /home/vagrant/.ansible/roles/staticdev.pyenv 30 | - staticdev.pyenv (2.6.2) was installed successfully 31 | ``` 32 | 33 | 34 | ## Usando o módulo 35 | 36 | Agora que temos a role do pyenv podemos incorporar ela em nossos playbooks. Vamos reescrever as tasks que instalam e configuram o pyenv. Pois tudo aqui é feito de forma automatizada: 37 | 38 | ```yaml title="play_tasks.yaml" 39 | --- 40 | - name: Configura o ambiente de desenvolvimento 41 | hosts: linux 42 | gather_facts: true 43 | 44 | 45 | tasks: 46 | - name: Dependências de desenvolvimento 47 | become: true 48 | import_tasks: tasks/dev_env.yml 49 | 50 | roles: 51 | - role: staticdev.pyenv 52 | pyenv_env: user 53 | pyenv_global: 54 | - 3.11.0 55 | pyenv_python_versions: 56 | - 3.11.0 57 | ``` 58 | 59 | ### Role vs Task vs Collection! 60 | 61 | - Task: Tasks são implemente tarefas, já vimos muitas por hoje 62 | - Role: Roles podem conter diversas tasks, arquivos, variáveis próprias e diversos outros artefatos 63 | - Collection: Coleções podem conter playbooks, roles, módulos e plugins 64 | 65 | 66 | ## requirements de Collections e Rules 67 | 68 | Também podemos centralizar um arquivo com todas as nossas dependências. Para que seja mais simples o processo de instalação dos pacotes de terceiros do Galaxy. Vou chamar esse arquivo de `requirements.yml`. 69 | 70 | Nele vamos instalar um gerenciador de pacotes para o arch poder baixar pacotes do [repositório AUR](https://aur.archlinux.org/). Que vem em uma coleção chamada `kewlfft.aur` e também vamos deixar a role do pyenv para ficar num arquivo único e centralizado: 71 | 72 | ```yaml title="requirements.yml" 73 | collections: 74 | - name: kewlfft.aur 75 | roles: 76 | - name: staticdev.pyenv 77 | ``` 78 | 79 | Agora com esse arquivo podemos instalar todas as collections de uma vez: 80 | 81 | ```bash title="$ Execução no terminal" 82 | ansible-galaxy collection install -r requirements.yml 83 | ``` 84 | 85 | E também podemos instalar todas as roles de uma vez só: 86 | 87 | ```bash title="$ Execução no terminal" 88 | ansible-galaxy role install -r requirements.yml 89 | ``` 90 | 91 | Dessa forma ficando mais simples de compartilhar nosso ambiente Ansible com outras pessoas :heart: 92 | -------------------------------------------------------------------------------- /docs/99_problemas_comuns.md: -------------------------------------------------------------------------------- 1 | # Alguns problemas que podem acontecer 2 | 3 | ## Sem espaço no disco 4 | 5 | Caso seu disco fique sem espaço, você pode mudar a configuração do Vagrantile para aumentar o tamanho do disco 6 | 7 | ```ruby hl_lines="4" 8 | config.vm.define "arch" do |arch| 9 | arch.vm.box = "archlinux/archlinux" 10 | 11 | arch.disksize.size = "30GB" 12 | 13 | arch.vm.provider "virtualbox" do |vb| 14 | vb.memory = "1024" 15 | end 16 | ``` 17 | 18 | O Vagrant, porém, não consegue executar essa tarefa. Para que isso seja feito, você precisa instalar uma extensão no Vagrant: 19 | 20 | ```bash title="$ Execução no terminal" 21 | vagrant plugin install vagrant-disksize 22 | ``` 23 | 24 | Em seguida, você pode reiniciar a vm: 25 | 26 | ```bash title="$ Execução no terminal" 27 | vagrant reload 28 | ``` 29 | -------------------------------------------------------------------------------- /docs/images/ansible_arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/docs/images/ansible_arch.png -------------------------------------------------------------------------------- /docs/images/ansible_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/docs/images/ansible_logo.png -------------------------------------------------------------------------------- /docs/images/console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/docs/images/console.png -------------------------------------------------------------------------------- /docs/images/emacs_00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/docs/images/emacs_00.png -------------------------------------------------------------------------------- /docs/images/emacs_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/docs/images/emacs_01.png -------------------------------------------------------------------------------- /docs/images/galaxy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/docs/images/galaxy.png -------------------------------------------------------------------------------- /docs/images/ursula.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/docs/images/ursula.jpg -------------------------------------------------------------------------------- /docs/images/vagrant_cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/docs/images/vagrant_cloud.png -------------------------------------------------------------------------------- /docs/images/virtualbox_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/docs/images/virtualbox_01.png -------------------------------------------------------------------------------- /docs/images/virtualbox_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/docs/images/virtualbox_02.png -------------------------------------------------------------------------------- /docs/images/virtualbox_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/docs/images/virtualbox_03.png -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Tutorial introdutório de Ansible :snake: 2 | 3 | [:fontawesome-brands-youtube: Vídeo](https://youtu.be/Rf1GDT8wiFU){ .md-button } 4 | [:fontawesome-solid-code: Repositório](https://github.com/dunossauro/ansible-lab){ .md-button } 5 | 6 | O objetivo desse repositório é ajudar você a construir um laboratório para aprender o básico sobre Ansible. 7 | 8 | Ele foi criado para uma [Live de Python](https://www.youtube.com/@Dunossauro) no Youtube. Mas nada impede que você siga somente pelo texto se assim achar necessário. 9 | 10 | Caso prefira a versão em vídeo, pode assistir por aqui: 11 | 12 | ![type:video](https://www.youtube.com/embed/Rf1GDT8wiFU) 13 | 14 | ## Nosso roteiro 15 | - [00 - Jabá](/00_jaba) 16 | - [01 - Configuração do ambiente](/01_configuracao_do_ambiente) 17 | - [02 - O básico necessário sobre Vagrant](/02_o_basico_necessario_sobre_vagrant) 18 | - [03 - Ansible básico](/03_ansible_basico) 19 | - [04 - Entendendo a estrutura do Ansible](/04_configuracao_do_ansible) 20 | - [05 - Playbooks](/05_playbooks) 21 | - [06 - Taks](/06_tasks) 22 | - [07 - Ansible Galaxy](/07_ansible_galaxy) 23 | 24 | ## O que preciso para acompanhar esse tutorial? 25 | 26 | O básico de Python, pois farei diversas analogias e um computador com pelo menos 8 gigas de memória RAM para subir as máquinas virtuais que vamos configurar durante o tutorial. 27 | 28 | ## Navegação 29 | 30 | Você pode navegar entre as páginas desse tutorial apertando as teclas `.` para ir para próxima página e `,` para voltar para página anterior. 31 | 32 | ## Caso encontre algum problema 33 | 34 | Se encontrar algum problema nesse material, como erros, sinta-se a vontade para enviar correções no [repositório do projeto](https://github.com/dunossauro/ansible-lab). Se precisar me contatar, pode me encontrar [nesse link](https://dunossauro.com){:target="_blank"} 35 | -------------------------------------------------------------------------------- /docs/overrides/main.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block content %} 4 | {{ super() }} 5 | 6 | {% if git_page_authors %} 7 |
8 | 9 | Authors: {{ git_page_authors | default('enable mkdocs-git-authors-plugin') }} 10 | 11 |
12 | {% endif %} 13 | {% endblock %} 14 | -------------------------------------------------------------------------------- /docs/referencias.md: -------------------------------------------------------------------------------- 1 | # Referências 2 | 3 | - [Documentação do Ansible](https://docs.ansible.com/ansible/latest/index.html) 4 | - [Documentação do Pacman](https://wiki.archlinux.org/title/Pacman) 5 | - [Documentação do Vagrant](https://developer.hashicorp.com/vagrant/docs) 6 | - [Pergunta sobre redimensionamento de disco no Vagrant (Stackoverflow)](https://stackoverflow.com/questions/58232223/how-to-increase-disk-space-of-virtual-machine-created-by-vagrant) 7 | -------------------------------------------------------------------------------- /docs/stylesheets/extra.css: -------------------------------------------------------------------------------- 1 | .center { 2 | display: block; 3 | margin-left: auto; 4 | margin-right: auto; 5 | } 6 | 7 | .shadow { 8 | box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); 9 | } 10 | 11 | 12 | .shadow-png { 13 | filter: drop-shadow(3px 3px 3px #222); 14 | } 15 | 16 | 17 | .sbs { 18 | /* side-by-side grid 19 | img | text 20 | or 21 | text | img */ 22 | display: grid; 23 | column-gap: 20px; 24 | grid-template-columns: auto auto; 25 | align-items: center; 26 | } 27 | -------------------------------------------------------------------------------- /images/console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/images/console.png -------------------------------------------------------------------------------- /images/virtualbox_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/images/virtualbox_01.png -------------------------------------------------------------------------------- /images/virtualbox_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/images/virtualbox_02.png -------------------------------------------------------------------------------- /images/virtualbox_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/images/virtualbox_03.png -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: Ansible lab 2 | repo_url: https://github.com/dunossauro/ansible-lab 3 | repo_name: dunossauro/ansible-lab 4 | docs_dir: docs 5 | edit_uri: tree/main/docs 6 | 7 | theme: 8 | name: material 9 | custom_dir: docs/overrides 10 | language: pt 11 | logo: images/ansible_logo.png 12 | favicon: images/ansible_logo.png 13 | features: 14 | - content.tabs.link 15 | icon: 16 | repo: fontawesome/brands/git-alt 17 | palette: 18 | - scheme: default 19 | toggle: 20 | icon: material/brightness-7 21 | name: Switch to dark mode 22 | - scheme: slate 23 | toggle: 24 | icon: material/brightness-4 25 | name: Switch to light mode 26 | 27 | 28 | extra_css: 29 | - stylesheets/extra.css 30 | 31 | markdown_extensions: 32 | - pymdownx.critic 33 | - pymdownx.highlight: 34 | anchor_linenums: true 35 | - pymdownx.inlinehilite 36 | - pymdownx.snippets 37 | - pymdownx.superfences 38 | - pymdownx.details 39 | - footnotes 40 | - admonition 41 | - markdown.extensions.attr_list 42 | - pymdownx.tabbed: 43 | alternate_style: true 44 | - attr_list 45 | - pymdownx.emoji: 46 | emoji_index: !!python/name:materialx.emoji.twemoji 47 | emoji_generator: !!python/name:materialx.emoji.to_svg 48 | - md_in_html 49 | 50 | extra: 51 | social: 52 | - icon: fontawesome/brands/github 53 | link: https://github.com/dunossauro 54 | - icon: fontawesome/brands/twitter 55 | link: https://twitter.com/dunossauro 56 | - icon: fontawesome/brands/youtube 57 | link: https://youtube.com/dunossauro 58 | - icon: fontawesome/brands/instagram 59 | link: https://instagram.com/dunossauro 60 | - icon: fontawesome/brands/tiktok 61 | link: https://www.tiktok.com/@dunossauro 62 | 63 | plugins: 64 | - search: 65 | lang: pt 66 | - git-authors: 67 | show_email_address: false 68 | show_line_count: true 69 | - mkdocs-video 70 | -------------------------------------------------------------------------------- /playbooks/arch_base_packages.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Pacotes de base 3 | hosts: test 4 | become: yes 5 | 6 | tasks: 7 | - name: install build tools 8 | package: 9 | name: base-devel 10 | state: present 11 | 12 | - name: install git 13 | package: 14 | name: git 15 | state: present 16 | -------------------------------------------------------------------------------- /playbooks/config_python.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Configuração do ambiente python 3 | hosts: linux 4 | 5 | tasks: 6 | - name: Install git 7 | become: yes 8 | package: 9 | name: git 10 | state: present 11 | 12 | - name: Clone Pyenv 13 | git: 14 | repo: https://github.com/pyenv/pyenv.git 15 | dest: ~/.pyenv 16 | 17 | - name: Install build dependencies (ubuntu) 18 | when: ansible_distribution == 'Ubuntu' 19 | become: yes 20 | apt: 21 | update_cache: yes 22 | pkg: 23 | - make 24 | - build-essential 25 | - libssl-dev 26 | - zlib1g-dev 27 | - libbz2-dev 28 | - libreadline-dev 29 | - libsqlite3-dev 30 | - wget 31 | - curl 32 | - llvm 33 | - libncursesw5-dev 34 | - xz-utils 35 | - tk-dev 36 | - libxml2-dev 37 | - libxmlsec1-dev 38 | - libffi-dev 39 | - liblzma-dev 40 | 41 | - name: Install build dependencies (arch) 42 | when: ansible_distribution == 'Archlinux' 43 | become: yes 44 | pacman: 45 | update_cache: yes 46 | name: 47 | - base-devel 48 | - openssl 49 | - zlib 50 | - xz 51 | - tk 52 | 53 | - name: Config pyenv 54 | blockinfile: 55 | dest: ~/.bashrc 56 | block: | 57 | echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc 58 | echo 'eval "$(pyenv init -)"' >>~/.bashrc 59 | echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc 60 | echo 'PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc 61 | 62 | - name: Show bashrc 63 | shell: cat ~/.bashrc 64 | register: bashrc 65 | 66 | - name: Checking bashrc 67 | debug: 68 | msg: "{{ bashrc.stdout.split('\n') }}" 69 | 70 | - block: 71 | - name: install python3.11 72 | shell: ~/.pyenv/bin/pyenv install -s 3.11:latest 73 | register: pyenv_result 74 | rescue: 75 | - name: Debug pyenv fail 76 | debug: 77 | msg: "{{pyenv_result.stderr.split('\n') }}" 78 | when: pyenv_result.failed 79 | -------------------------------------------------------------------------------- /playbooks/emacs.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Instalação e configuração do emacs 3 | hosts: localhost # Aqui mudamos para o localhost 4 | 5 | tasks: 6 | - name: Instalação do emacs 7 | 8 | become: yes # Diferente da outra config, somente esse passo será como root 9 | 10 | package: 11 | state: present 12 | name: emacs 13 | 14 | - name: Instalação do git 15 | become: yes 16 | package: 17 | name: git 18 | state: present 19 | 20 | - name: Clone do nosso repositório 21 | git: 22 | repo: https://github.com/dunossauro/dotfiles.git 23 | dest: config_files 24 | 25 | - name: Movendo os arquivos de configuração do emacs 26 | copy: 27 | dest: /home/vagrant/ 28 | src: /home/vagrant/config_files/.emacs.d 29 | 30 | -------------------------------------------------------------------------------- /playbooks/pipx_httpie.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Instalação do pipx e httpie 3 | hosts: linux 4 | 5 | tasks: 6 | - name: Instalação do pipx 7 | become: yes 8 | package: 9 | name: '{{ pipx }}' 10 | state: present 11 | -------------------------------------------------------------------------------- /playbooks/play_tasks.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Configura o ambiente de desenvolvimento 3 | hosts: linux 4 | gather_facts: true 5 | 6 | 7 | tasks: 8 | - name: Dependências de desenvolvimento 9 | become: true 10 | import_tasks: tasks/dev_env.yml 11 | 12 | roles: 13 | - role: staticdev.pyenv 14 | pyenv_env: user 15 | pyenv_global: 16 | - 3.11.0 17 | pyenv_python_versions: 18 | - 3.11.0 19 | -------------------------------------------------------------------------------- /playbooks/requirements.yml: -------------------------------------------------------------------------------- 1 | collections: 2 | - name: kewlfft.aur 3 | roles: 4 | - name: staticdev.pyenv 5 | -------------------------------------------------------------------------------- /playbooks/tasks/dev_env.yml: -------------------------------------------------------------------------------- 1 | - name: Install git 2 | become: yes 3 | package: 4 | name: git 5 | state: present 6 | 7 | - name: Install build dependencies (ubuntu) 8 | when: ansible_distribution == 'Ubuntu' 9 | become: yes 10 | apt: 11 | update_cache: yes 12 | pkg: 13 | - make 14 | - build-essential 15 | - libssl-dev 16 | - zlib1g-dev 17 | - libbz2-dev 18 | - libreadline-dev 19 | - libsqlite3-dev 20 | - wget 21 | - curl 22 | - llvm 23 | - libncursesw5-dev 24 | - xz-utils 25 | - tk-dev 26 | - libxml2-dev 27 | - libxmlsec1-dev 28 | - libffi-dev 29 | - liblzma-dev 30 | 31 | - name: Install build dependencies (arch) 32 | when: ansible_distribution == 'Archlinux' 33 | become: yes 34 | pacman: 35 | update_cache: yes 36 | name: 37 | - base-devel 38 | - openssl 39 | - zlib 40 | - xz 41 | - tk 42 | -------------------------------------------------------------------------------- /playbooks/tasks/py_311.yml: -------------------------------------------------------------------------------- 1 | - block: 2 | - name: install python3.11 3 | shell: ~/.pyenv/bin/pyenv install -s 3.11:latest 4 | register: pyenv_result 5 | rescue: 6 | - name: Debug pyenv fail 7 | debug: 8 | msg: "{{pyenv_result.stderr.split('\n') }}" 9 | when: pyenv_result.failed 10 | -------------------------------------------------------------------------------- /playbooks/tasks/pyenv.yml: -------------------------------------------------------------------------------- 1 | - name: Clone Pyenv 2 | git: 3 | repo: https://github.com/pyenv/pyenv.git 4 | dest: ~/.pyenv 5 | 6 | - name: Config pyenv 7 | blockinfile: 8 | dest: ~/.bashrc 9 | block: | 10 | echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc 11 | echo 'eval "$(pyenv init -)"' >>~/.bashrc 12 | echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc 13 | echo 'PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc 14 | -------------------------------------------------------------------------------- /playbooks/variaveis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | pipx: "{{ 'pipx' if ansible_distribution == 'Ubuntu' else 'python-pipx'}}" 3 | -------------------------------------------------------------------------------- /playbooks/web_server.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Instalação do nginx 3 | hosts: linux # Grupo de hosts do inventário 4 | become: yes # Diz que vai escalonar privilégios. Equivalente ao {==-b==) 5 | 6 | tasks: # Descrição das tarefas que serão executadas 7 | 8 | - name: Instalação do nginx # Nome da tarefa 9 | package: # Nome do módulo 10 | # Argumentos do módulo 11 | state: present 12 | name: nginx 13 | 14 | - name: Inicialização do nginx 15 | systemd: 16 | state: started 17 | name: nginx 18 | -------------------------------------------------------------------------------- /poetry.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. 2 | 3 | [[package]] 4 | name = "certifi" 5 | version = "2022.9.24" 6 | description = "Python package for providing Mozilla's CA Bundle." 7 | optional = false 8 | python-versions = ">=3.6" 9 | files = [ 10 | {file = "certifi-2022.9.24-py3-none-any.whl", hash = "sha256:90c1a32f1d68f940488354e36370f6cca89f0f106db09518524c88d6ed83f382"}, 11 | {file = "certifi-2022.9.24.tar.gz", hash = "sha256:0d9c601124e5a6ba9712dbc60d9c53c21e34f5f641fe83002317394311bdce14"}, 12 | ] 13 | 14 | [[package]] 15 | name = "charset-normalizer" 16 | version = "2.1.1" 17 | description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." 18 | optional = false 19 | python-versions = ">=3.6.0" 20 | files = [ 21 | {file = "charset-normalizer-2.1.1.tar.gz", hash = "sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845"}, 22 | {file = "charset_normalizer-2.1.1-py3-none-any.whl", hash = "sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"}, 23 | ] 24 | 25 | [package.extras] 26 | unicode-backport = ["unicodedata2"] 27 | 28 | [[package]] 29 | name = "click" 30 | version = "8.1.3" 31 | description = "Composable command line interface toolkit" 32 | optional = false 33 | python-versions = ">=3.7" 34 | files = [ 35 | {file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"}, 36 | {file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"}, 37 | ] 38 | 39 | [package.dependencies] 40 | colorama = {version = "*", markers = "platform_system == \"Windows\""} 41 | 42 | [[package]] 43 | name = "colorama" 44 | version = "0.4.6" 45 | description = "Cross-platform colored terminal text." 46 | optional = false 47 | python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" 48 | files = [ 49 | {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, 50 | {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, 51 | ] 52 | 53 | [[package]] 54 | name = "ghp-import" 55 | version = "2.1.0" 56 | description = "Copy your docs directly to the gh-pages branch." 57 | optional = false 58 | python-versions = "*" 59 | files = [ 60 | {file = "ghp-import-2.1.0.tar.gz", hash = "sha256:9c535c4c61193c2df8871222567d7fd7e5014d835f97dc7b7439069e2413d343"}, 61 | {file = "ghp_import-2.1.0-py3-none-any.whl", hash = "sha256:8337dd7b50877f163d4c0289bc1f1c7f127550241988d568c1db512c4324a619"}, 62 | ] 63 | 64 | [package.dependencies] 65 | python-dateutil = ">=2.8.1" 66 | 67 | [package.extras] 68 | dev = ["flake8", "markdown", "twine", "wheel"] 69 | 70 | [[package]] 71 | name = "idna" 72 | version = "3.4" 73 | description = "Internationalized Domain Names in Applications (IDNA)" 74 | optional = false 75 | python-versions = ">=3.5" 76 | files = [ 77 | {file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"}, 78 | {file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"}, 79 | ] 80 | 81 | [[package]] 82 | name = "jinja2" 83 | version = "3.1.2" 84 | description = "A very fast and expressive template engine." 85 | optional = false 86 | python-versions = ">=3.7" 87 | files = [ 88 | {file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"}, 89 | {file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"}, 90 | ] 91 | 92 | [package.dependencies] 93 | MarkupSafe = ">=2.0" 94 | 95 | [package.extras] 96 | i18n = ["Babel (>=2.7)"] 97 | 98 | [[package]] 99 | name = "markdown" 100 | version = "3.3.7" 101 | description = "Python implementation of Markdown." 102 | optional = false 103 | python-versions = ">=3.6" 104 | files = [ 105 | {file = "Markdown-3.3.7-py3-none-any.whl", hash = "sha256:f5da449a6e1c989a4cea2631aa8ee67caa5a2ef855d551c88f9e309f4634c621"}, 106 | {file = "Markdown-3.3.7.tar.gz", hash = "sha256:cbb516f16218e643d8e0a95b309f77eb118cb138d39a4f27851e6a63581db874"}, 107 | ] 108 | 109 | [package.extras] 110 | testing = ["coverage", "pyyaml"] 111 | 112 | [[package]] 113 | name = "markupsafe" 114 | version = "2.1.1" 115 | description = "Safely add untrusted strings to HTML/XML markup." 116 | optional = false 117 | python-versions = ">=3.7" 118 | files = [ 119 | {file = "MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812"}, 120 | {file = "MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a"}, 121 | {file = "MarkupSafe-2.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e"}, 122 | {file = "MarkupSafe-2.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10c1bfff05d95783da83491be968e8fe789263689c02724e0c691933c52994f5"}, 123 | {file = "MarkupSafe-2.1.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b7bd98b796e2b6553da7225aeb61f447f80a1ca64f41d83612e6139ca5213aa4"}, 124 | {file = "MarkupSafe-2.1.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:b09bf97215625a311f669476f44b8b318b075847b49316d3e28c08e41a7a573f"}, 125 | {file = "MarkupSafe-2.1.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:694deca8d702d5db21ec83983ce0bb4b26a578e71fbdbd4fdcd387daa90e4d5e"}, 126 | {file = "MarkupSafe-2.1.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:efc1913fd2ca4f334418481c7e595c00aad186563bbc1ec76067848c7ca0a933"}, 127 | {file = "MarkupSafe-2.1.1-cp310-cp310-win32.whl", hash = "sha256:4a33dea2b688b3190ee12bd7cfa29d39c9ed176bda40bfa11099a3ce5d3a7ac6"}, 128 | {file = "MarkupSafe-2.1.1-cp310-cp310-win_amd64.whl", hash = "sha256:dda30ba7e87fbbb7eab1ec9f58678558fd9a6b8b853530e176eabd064da81417"}, 129 | {file = "MarkupSafe-2.1.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:671cd1187ed5e62818414afe79ed29da836dde67166a9fac6d435873c44fdd02"}, 130 | {file = "MarkupSafe-2.1.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3799351e2336dc91ea70b034983ee71cf2f9533cdff7c14c90ea126bfd95d65a"}, 131 | {file = "MarkupSafe-2.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e72591e9ecd94d7feb70c1cbd7be7b3ebea3f548870aa91e2732960fa4d57a37"}, 132 | {file = "MarkupSafe-2.1.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6fbf47b5d3728c6aea2abb0589b5d30459e369baa772e0f37a0320185e87c980"}, 133 | {file = "MarkupSafe-2.1.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:d5ee4f386140395a2c818d149221149c54849dfcfcb9f1debfe07a8b8bd63f9a"}, 134 | {file = "MarkupSafe-2.1.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:bcb3ed405ed3222f9904899563d6fc492ff75cce56cba05e32eff40e6acbeaa3"}, 135 | {file = "MarkupSafe-2.1.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:e1c0b87e09fa55a220f058d1d49d3fb8df88fbfab58558f1198e08c1e1de842a"}, 136 | {file = "MarkupSafe-2.1.1-cp37-cp37m-win32.whl", hash = "sha256:8dc1c72a69aa7e082593c4a203dcf94ddb74bb5c8a731e4e1eb68d031e8498ff"}, 137 | {file = "MarkupSafe-2.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:97a68e6ada378df82bc9f16b800ab77cbf4b2fada0081794318520138c088e4a"}, 138 | {file = "MarkupSafe-2.1.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:e8c843bbcda3a2f1e3c2ab25913c80a3c5376cd00c6e8c4a86a89a28c8dc5452"}, 139 | {file = "MarkupSafe-2.1.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0212a68688482dc52b2d45013df70d169f542b7394fc744c02a57374a4207003"}, 140 | {file = "MarkupSafe-2.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8e576a51ad59e4bfaac456023a78f6b5e6e7651dcd383bcc3e18d06f9b55d6d1"}, 141 | {file = "MarkupSafe-2.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4b9fe39a2ccc108a4accc2676e77da025ce383c108593d65cc909add5c3bd601"}, 142 | {file = "MarkupSafe-2.1.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:96e37a3dc86e80bf81758c152fe66dbf60ed5eca3d26305edf01892257049925"}, 143 | {file = "MarkupSafe-2.1.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:6d0072fea50feec76a4c418096652f2c3238eaa014b2f94aeb1d56a66b41403f"}, 144 | {file = "MarkupSafe-2.1.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:089cf3dbf0cd6c100f02945abeb18484bd1ee57a079aefd52cffd17fba910b88"}, 145 | {file = "MarkupSafe-2.1.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6a074d34ee7a5ce3effbc526b7083ec9731bb3cbf921bbe1d3005d4d2bdb3a63"}, 146 | {file = "MarkupSafe-2.1.1-cp38-cp38-win32.whl", hash = "sha256:421be9fbf0ffe9ffd7a378aafebbf6f4602d564d34be190fc19a193232fd12b1"}, 147 | {file = "MarkupSafe-2.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:fc7b548b17d238737688817ab67deebb30e8073c95749d55538ed473130ec0c7"}, 148 | {file = "MarkupSafe-2.1.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:e04e26803c9c3851c931eac40c695602c6295b8d432cbe78609649ad9bd2da8a"}, 149 | {file = "MarkupSafe-2.1.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b87db4360013327109564f0e591bd2a3b318547bcef31b468a92ee504d07ae4f"}, 150 | {file = "MarkupSafe-2.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:99a2a507ed3ac881b975a2976d59f38c19386d128e7a9a18b7df6fff1fd4c1d6"}, 151 | {file = "MarkupSafe-2.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:56442863ed2b06d19c37f94d999035e15ee982988920e12a5b4ba29b62ad1f77"}, 152 | {file = "MarkupSafe-2.1.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3ce11ee3f23f79dbd06fb3d63e2f6af7b12db1d46932fe7bd8afa259a5996603"}, 153 | {file = "MarkupSafe-2.1.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:33b74d289bd2f5e527beadcaa3f401e0df0a89927c1559c8566c066fa4248ab7"}, 154 | {file = "MarkupSafe-2.1.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:43093fb83d8343aac0b1baa75516da6092f58f41200907ef92448ecab8825135"}, 155 | {file = "MarkupSafe-2.1.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:8e3dcf21f367459434c18e71b2a9532d96547aef8a871872a5bd69a715c15f96"}, 156 | {file = "MarkupSafe-2.1.1-cp39-cp39-win32.whl", hash = "sha256:d4306c36ca495956b6d568d276ac11fdd9c30a36f1b6eb928070dc5360b22e1c"}, 157 | {file = "MarkupSafe-2.1.1-cp39-cp39-win_amd64.whl", hash = "sha256:46d00d6cfecdde84d40e572d63735ef81423ad31184100411e6e3388d405e247"}, 158 | {file = "MarkupSafe-2.1.1.tar.gz", hash = "sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b"}, 159 | ] 160 | 161 | [[package]] 162 | name = "mergedeep" 163 | version = "1.3.4" 164 | description = "A deep merge function for 🐍." 165 | optional = false 166 | python-versions = ">=3.6" 167 | files = [ 168 | {file = "mergedeep-1.3.4-py3-none-any.whl", hash = "sha256:70775750742b25c0d8f36c55aed03d24c3384d17c951b3175d898bd778ef0307"}, 169 | {file = "mergedeep-1.3.4.tar.gz", hash = "sha256:0096d52e9dad9939c3d975a774666af186eda617e6ca84df4c94dec30004f2a8"}, 170 | ] 171 | 172 | [[package]] 173 | name = "mkdocs" 174 | version = "1.4.2" 175 | description = "Project documentation with Markdown." 176 | optional = false 177 | python-versions = ">=3.7" 178 | files = [ 179 | {file = "mkdocs-1.4.2-py3-none-any.whl", hash = "sha256:c8856a832c1e56702577023cd64cc5f84948280c1c0fcc6af4cd39006ea6aa8c"}, 180 | {file = "mkdocs-1.4.2.tar.gz", hash = "sha256:8947af423a6d0facf41ea1195b8e1e8c85ad94ac95ae307fe11232e0424b11c5"}, 181 | ] 182 | 183 | [package.dependencies] 184 | click = ">=7.0" 185 | colorama = {version = ">=0.4", markers = "platform_system == \"Windows\""} 186 | ghp-import = ">=1.0" 187 | jinja2 = ">=2.11.1" 188 | markdown = ">=3.2.1,<3.4" 189 | mergedeep = ">=1.3.4" 190 | packaging = ">=20.5" 191 | pyyaml = ">=5.1" 192 | pyyaml-env-tag = ">=0.1" 193 | watchdog = ">=2.0" 194 | 195 | [package.extras] 196 | i18n = ["babel (>=2.9.0)"] 197 | min-versions = ["babel (==2.9.0)", "click (==7.0)", "colorama (==0.4)", "ghp-import (==1.0)", "importlib-metadata (==4.3)", "jinja2 (==2.11.1)", "markdown (==3.2.1)", "markupsafe (==2.0.1)", "mergedeep (==1.3.4)", "packaging (==20.5)", "pyyaml (==5.1)", "pyyaml-env-tag (==0.1)", "typing-extensions (==3.10)", "watchdog (==2.0)"] 198 | 199 | [[package]] 200 | name = "mkdocs-git-authors-plugin" 201 | version = "0.7.2" 202 | description = "Mkdocs plugin to display git authors of a page" 203 | optional = false 204 | python-versions = ">=3.7" 205 | files = [ 206 | {file = "mkdocs-git-authors-plugin-0.7.2.tar.gz", hash = "sha256:f541730e4cabdafa0ac758c94d28ba5e8ddca4c859e5de4c89f1226cb6ccd0ad"}, 207 | {file = "mkdocs_git_authors_plugin-0.7.2-py3-none-any.whl", hash = "sha256:c8a2784a867db79ad3b477a96ee96875d17b09192b6d3be71f08df25afff76c4"}, 208 | ] 209 | 210 | [package.dependencies] 211 | mkdocs = ">=1.0" 212 | 213 | [[package]] 214 | name = "mkdocs-material" 215 | version = "8.5.10" 216 | description = "Documentation that simply works" 217 | optional = false 218 | python-versions = ">=3.7" 219 | files = [ 220 | {file = "mkdocs_material-8.5.10-py3-none-any.whl", hash = "sha256:51760fa4c9ee3ca0b3a661ec9f9817ec312961bb84ff19e5b523fdc5256e1d6c"}, 221 | {file = "mkdocs_material-8.5.10.tar.gz", hash = "sha256:7623608f746c6d9ff68a8ef01f13eddf32fa2cae5e15badb251f26d1196bc8f1"}, 222 | ] 223 | 224 | [package.dependencies] 225 | jinja2 = ">=3.0.2" 226 | markdown = ">=3.2" 227 | mkdocs = ">=1.4.0" 228 | mkdocs-material-extensions = ">=1.1" 229 | pygments = ">=2.12" 230 | pymdown-extensions = ">=9.4" 231 | requests = ">=2.26" 232 | 233 | [[package]] 234 | name = "mkdocs-material-extensions" 235 | version = "1.1" 236 | description = "Extension pack for Python Markdown and MkDocs Material." 237 | optional = false 238 | python-versions = ">=3.7" 239 | files = [ 240 | {file = "mkdocs_material_extensions-1.1-py3-none-any.whl", hash = "sha256:bcc2e5fc70c0ec50e59703ee6e639d87c7e664c0c441c014ea84461a90f1e902"}, 241 | {file = "mkdocs_material_extensions-1.1.tar.gz", hash = "sha256:96ca979dae66d65c2099eefe189b49d5ac62f76afb59c38e069ffc7cf3c131ec"}, 242 | ] 243 | 244 | [[package]] 245 | name = "mkdocs-video" 246 | version = "1.3.0" 247 | description = "" 248 | optional = false 249 | python-versions = ">=3.6" 250 | files = [ 251 | {file = "mkdocs-video-1.3.0.tar.gz", hash = "sha256:900a7da60aff6d313d3aec47348bb7c87ec2ad39bad27a1146fa153fafd61e44"}, 252 | {file = "mkdocs_video-1.3.0-py3-none-any.whl", hash = "sha256:6512887d65e65f4fb643b64e3f4cc7e365ce27d0ff4c4b48de8d91b04ea89731"}, 253 | ] 254 | 255 | [package.dependencies] 256 | mkdocs = ">=1.1.0,<2" 257 | 258 | [[package]] 259 | name = "packaging" 260 | version = "21.3" 261 | description = "Core utilities for Python packages" 262 | optional = false 263 | python-versions = ">=3.6" 264 | files = [ 265 | {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, 266 | {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, 267 | ] 268 | 269 | [package.dependencies] 270 | pyparsing = ">=2.0.2,<3.0.5 || >3.0.5" 271 | 272 | [[package]] 273 | name = "pygments" 274 | version = "2.13.0" 275 | description = "Pygments is a syntax highlighting package written in Python." 276 | optional = false 277 | python-versions = ">=3.6" 278 | files = [ 279 | {file = "Pygments-2.13.0-py3-none-any.whl", hash = "sha256:f643f331ab57ba3c9d89212ee4a2dabc6e94f117cf4eefde99a0574720d14c42"}, 280 | {file = "Pygments-2.13.0.tar.gz", hash = "sha256:56a8508ae95f98e2b9bdf93a6be5ae3f7d8af858b43e02c5a2ff083726be40c1"}, 281 | ] 282 | 283 | [package.extras] 284 | plugins = ["importlib-metadata"] 285 | 286 | [[package]] 287 | name = "pymdown-extensions" 288 | version = "9.8" 289 | description = "Extension pack for Python Markdown." 290 | optional = false 291 | python-versions = ">=3.7" 292 | files = [ 293 | {file = "pymdown_extensions-9.8-py3-none-any.whl", hash = "sha256:8e62688a8b1128acd42fa823f3d429d22f4284b5e6dd4d3cd56721559a5a211b"}, 294 | {file = "pymdown_extensions-9.8.tar.gz", hash = "sha256:1bd4a173095ef8c433b831af1f3cb13c10883be0c100ae613560668e594651f7"}, 295 | ] 296 | 297 | [package.dependencies] 298 | markdown = ">=3.2" 299 | 300 | [[package]] 301 | name = "pyparsing" 302 | version = "3.0.9" 303 | description = "pyparsing module - Classes and methods to define and execute parsing grammars" 304 | optional = false 305 | python-versions = ">=3.6.8" 306 | files = [ 307 | {file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"}, 308 | {file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"}, 309 | ] 310 | 311 | [package.extras] 312 | diagrams = ["jinja2", "railroad-diagrams"] 313 | 314 | [[package]] 315 | name = "python-dateutil" 316 | version = "2.8.2" 317 | description = "Extensions to the standard Python datetime module" 318 | optional = false 319 | python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" 320 | files = [ 321 | {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, 322 | {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, 323 | ] 324 | 325 | [package.dependencies] 326 | six = ">=1.5" 327 | 328 | [[package]] 329 | name = "pyyaml" 330 | version = "6.0" 331 | description = "YAML parser and emitter for Python" 332 | optional = false 333 | python-versions = ">=3.6" 334 | files = [ 335 | {file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"}, 336 | {file = "PyYAML-6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c"}, 337 | {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc"}, 338 | {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b"}, 339 | {file = "PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"}, 340 | {file = "PyYAML-6.0-cp310-cp310-win32.whl", hash = "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513"}, 341 | {file = "PyYAML-6.0-cp310-cp310-win_amd64.whl", hash = "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a"}, 342 | {file = "PyYAML-6.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358"}, 343 | {file = "PyYAML-6.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1"}, 344 | {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d"}, 345 | {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f"}, 346 | {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782"}, 347 | {file = "PyYAML-6.0-cp311-cp311-win32.whl", hash = "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7"}, 348 | {file = "PyYAML-6.0-cp311-cp311-win_amd64.whl", hash = "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf"}, 349 | {file = "PyYAML-6.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86"}, 350 | {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f"}, 351 | {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92"}, 352 | {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4"}, 353 | {file = "PyYAML-6.0-cp36-cp36m-win32.whl", hash = "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293"}, 354 | {file = "PyYAML-6.0-cp36-cp36m-win_amd64.whl", hash = "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57"}, 355 | {file = "PyYAML-6.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c"}, 356 | {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0"}, 357 | {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4"}, 358 | {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9"}, 359 | {file = "PyYAML-6.0-cp37-cp37m-win32.whl", hash = "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737"}, 360 | {file = "PyYAML-6.0-cp37-cp37m-win_amd64.whl", hash = "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d"}, 361 | {file = "PyYAML-6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b"}, 362 | {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba"}, 363 | {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34"}, 364 | {file = "PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287"}, 365 | {file = "PyYAML-6.0-cp38-cp38-win32.whl", hash = "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78"}, 366 | {file = "PyYAML-6.0-cp38-cp38-win_amd64.whl", hash = "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07"}, 367 | {file = "PyYAML-6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b"}, 368 | {file = "PyYAML-6.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174"}, 369 | {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803"}, 370 | {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3"}, 371 | {file = "PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0"}, 372 | {file = "PyYAML-6.0-cp39-cp39-win32.whl", hash = "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb"}, 373 | {file = "PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"}, 374 | {file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"}, 375 | ] 376 | 377 | [[package]] 378 | name = "pyyaml-env-tag" 379 | version = "0.1" 380 | description = "A custom YAML tag for referencing environment variables in YAML files. " 381 | optional = false 382 | python-versions = ">=3.6" 383 | files = [ 384 | {file = "pyyaml_env_tag-0.1-py3-none-any.whl", hash = "sha256:af31106dec8a4d68c60207c1886031cbf839b68aa7abccdb19868200532c2069"}, 385 | {file = "pyyaml_env_tag-0.1.tar.gz", hash = "sha256:70092675bda14fdec33b31ba77e7543de9ddc88f2e5b99160396572d11525bdb"}, 386 | ] 387 | 388 | [package.dependencies] 389 | pyyaml = "*" 390 | 391 | [[package]] 392 | name = "requests" 393 | version = "2.28.1" 394 | description = "Python HTTP for Humans." 395 | optional = false 396 | python-versions = ">=3.7, <4" 397 | files = [ 398 | {file = "requests-2.28.1-py3-none-any.whl", hash = "sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349"}, 399 | {file = "requests-2.28.1.tar.gz", hash = "sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983"}, 400 | ] 401 | 402 | [package.dependencies] 403 | certifi = ">=2017.4.17" 404 | charset-normalizer = ">=2,<3" 405 | idna = ">=2.5,<4" 406 | urllib3 = ">=1.21.1,<1.27" 407 | 408 | [package.extras] 409 | socks = ["PySocks (>=1.5.6,!=1.5.7)"] 410 | use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] 411 | 412 | [[package]] 413 | name = "six" 414 | version = "1.16.0" 415 | description = "Python 2 and 3 compatibility utilities" 416 | optional = false 417 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" 418 | files = [ 419 | {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, 420 | {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, 421 | ] 422 | 423 | [[package]] 424 | name = "urllib3" 425 | version = "1.26.12" 426 | description = "HTTP library with thread-safe connection pooling, file post, and more." 427 | optional = false 428 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4" 429 | files = [ 430 | {file = "urllib3-1.26.12-py2.py3-none-any.whl", hash = "sha256:b930dd878d5a8afb066a637fbb35144fe7901e3b209d1cd4f524bd0e9deee997"}, 431 | {file = "urllib3-1.26.12.tar.gz", hash = "sha256:3fa96cf423e6987997fc326ae8df396db2a8b7c667747d47ddd8ecba91f4a74e"}, 432 | ] 433 | 434 | [package.extras] 435 | brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"] 436 | secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)", "urllib3-secure-extra"] 437 | socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] 438 | 439 | [[package]] 440 | name = "watchdog" 441 | version = "2.1.9" 442 | description = "Filesystem events monitoring" 443 | optional = false 444 | python-versions = ">=3.6" 445 | files = [ 446 | {file = "watchdog-2.1.9-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:a735a990a1095f75ca4f36ea2ef2752c99e6ee997c46b0de507ba40a09bf7330"}, 447 | {file = "watchdog-2.1.9-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6b17d302850c8d412784d9246cfe8d7e3af6bcd45f958abb2d08a6f8bedf695d"}, 448 | {file = "watchdog-2.1.9-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ee3e38a6cc050a8830089f79cbec8a3878ec2fe5160cdb2dc8ccb6def8552658"}, 449 | {file = "watchdog-2.1.9-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:64a27aed691408a6abd83394b38503e8176f69031ca25d64131d8d640a307591"}, 450 | {file = "watchdog-2.1.9-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:195fc70c6e41237362ba720e9aaf394f8178bfc7fa68207f112d108edef1af33"}, 451 | {file = "watchdog-2.1.9-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:bfc4d351e6348d6ec51df007432e6fe80adb53fd41183716017026af03427846"}, 452 | {file = "watchdog-2.1.9-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:8250546a98388cbc00c3ee3cc5cf96799b5a595270dfcfa855491a64b86ef8c3"}, 453 | {file = "watchdog-2.1.9-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:117ffc6ec261639a0209a3252546b12800670d4bf5f84fbd355957a0595fe654"}, 454 | {file = "watchdog-2.1.9-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:97f9752208f5154e9e7b76acc8c4f5a58801b338de2af14e7e181ee3b28a5d39"}, 455 | {file = "watchdog-2.1.9-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:247dcf1df956daa24828bfea5a138d0e7a7c98b1a47cf1fa5b0c3c16241fcbb7"}, 456 | {file = "watchdog-2.1.9-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:226b3c6c468ce72051a4c15a4cc2ef317c32590d82ba0b330403cafd98a62cfd"}, 457 | {file = "watchdog-2.1.9-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:d9820fe47c20c13e3c9dd544d3706a2a26c02b2b43c993b62fcd8011bcc0adb3"}, 458 | {file = "watchdog-2.1.9-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:70af927aa1613ded6a68089a9262a009fbdf819f46d09c1a908d4b36e1ba2b2d"}, 459 | {file = "watchdog-2.1.9-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:ed80a1628cee19f5cfc6bb74e173f1b4189eb532e705e2a13e3250312a62e0c9"}, 460 | {file = "watchdog-2.1.9-py3-none-manylinux2014_aarch64.whl", hash = "sha256:9f05a5f7c12452f6a27203f76779ae3f46fa30f1dd833037ea8cbc2887c60213"}, 461 | {file = "watchdog-2.1.9-py3-none-manylinux2014_armv7l.whl", hash = "sha256:255bb5758f7e89b1a13c05a5bceccec2219f8995a3a4c4d6968fe1de6a3b2892"}, 462 | {file = "watchdog-2.1.9-py3-none-manylinux2014_i686.whl", hash = "sha256:d3dda00aca282b26194bdd0adec21e4c21e916956d972369359ba63ade616153"}, 463 | {file = "watchdog-2.1.9-py3-none-manylinux2014_ppc64.whl", hash = "sha256:186f6c55abc5e03872ae14c2f294a153ec7292f807af99f57611acc8caa75306"}, 464 | {file = "watchdog-2.1.9-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:083171652584e1b8829581f965b9b7723ca5f9a2cd7e20271edf264cfd7c1412"}, 465 | {file = "watchdog-2.1.9-py3-none-manylinux2014_s390x.whl", hash = "sha256:b530ae007a5f5d50b7fbba96634c7ee21abec70dc3e7f0233339c81943848dc1"}, 466 | {file = "watchdog-2.1.9-py3-none-manylinux2014_x86_64.whl", hash = "sha256:4f4e1c4aa54fb86316a62a87b3378c025e228178d55481d30d857c6c438897d6"}, 467 | {file = "watchdog-2.1.9-py3-none-win32.whl", hash = "sha256:5952135968519e2447a01875a6f5fc8c03190b24d14ee52b0f4b1682259520b1"}, 468 | {file = "watchdog-2.1.9-py3-none-win_amd64.whl", hash = "sha256:7a833211f49143c3d336729b0020ffd1274078e94b0ae42e22f596999f50279c"}, 469 | {file = "watchdog-2.1.9-py3-none-win_ia64.whl", hash = "sha256:ad576a565260d8f99d97f2e64b0f97a48228317095908568a9d5c786c829d428"}, 470 | {file = "watchdog-2.1.9.tar.gz", hash = "sha256:43ce20ebb36a51f21fa376f76d1d4692452b2527ccd601950d69ed36b9e21609"}, 471 | ] 472 | 473 | [package.extras] 474 | watchmedo = ["PyYAML (>=3.10)"] 475 | 476 | [metadata] 477 | lock-version = "2.0" 478 | python-versions = "^3.11" 479 | content-hash = "1a9a06ed3143d70638372f9d915c27b9a9e1b5ab915d230007a7b862de8a9f6a" 480 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "ansible-lab" 3 | version = "0.1.0" 4 | description = "" 5 | authors = ["dunossauro "] 6 | readme = "README.md" 7 | packages = [{include = "ansible_lab"}] 8 | 9 | [tool.poetry.dependencies] 10 | python = "^3.11" 11 | mkdocs = "^1.4.2" 12 | mkdocs-material = "^8.5.10" 13 | pymdown-extensions = "^9.8" 14 | mkdocs-video = "^1.3.0" 15 | mkdocs-git-authors-plugin = "^0.7.2" 16 | 17 | 18 | [build-system] 19 | requires = ["poetry-core"] 20 | build-backend = "poetry.core.masonry.api" 21 | -------------------------------------------------------------------------------- /stuff/TODO.md: -------------------------------------------------------------------------------- 1 | # Coisas que ainda preciso fazer nesse repo 2 | 3 | 1. Adicionar uma introdução teórica ao Ansible 4 | 2. Explicar o inventário 5 | 3. Comandos ad-hoc 6 | 4. Playbooks 7 | 5. Tasks 8 | 5. Galaxy 9 | 10 | 11 | ## Adicionais 12 | - Explicar o env que tem no `Vagrantfile` do repo (arquivo vagrant.md) 13 | - Passo a passo da configuração do env pelos scripts 14 | -------------------------------------------------------------------------------- /stuff/draws/ansible_arch.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dunossauro/ansible-lab/338eb8f21f461c2c94e7dacd9c7e5fd92600515a/stuff/draws/ansible_arch.odg -------------------------------------------------------------------------------- /stuff/env_up.sh: -------------------------------------------------------------------------------- 1 | vagrant up 2 | bash arch_scripts/get_vagrant_ips.sh > ansible_hosts 3 | vagrant ssh ansible_main -c "sudo pacman -Sy ansible sshpass --noconfirm --needed" 4 | vagrant ssh ansible_main -c "sudo cp /vagrant/ansible_hosts /etc/ansible/hosts" 5 | vagrant ssh ansible_main -c 'ssh-keygen -t rsa -f ~/.ssh/id_rsa -q -P ""' 6 | vagrant ssh ansible_main -c "bash /vagrant/arch_scripts/ips_from_hosts.sh" 7 | -------------------------------------------------------------------------------- /stuff/resposta_ubuntu_setup.txt: -------------------------------------------------------------------------------- 1 | 192.168.15.119 | SUCCESS => { 2 | "ansible_facts": { 3 | "ansible_all_ipv4_addresses": [ 4 | "192.168.15.119", 5 | "10.0.2.15" 6 | ], 7 | "ansible_all_ipv6_addresses": [ 8 | "fe80::a00:27ff:fea0:f6f7", 9 | "fe80::9a:94ff:fec9:30e2" 10 | ], 11 | "ansible_apparmor": { 12 | "status": "enabled" 13 | }, 14 | "ansible_architecture": "x86_64", 15 | "ansible_bios_date": "12/01/2006", 16 | "ansible_bios_vendor": "innotek GmbH", 17 | "ansible_bios_version": "VirtualBox", 18 | "ansible_board_asset_tag": "NA", 19 | "ansible_board_name": "VirtualBox", 20 | "ansible_board_serial": "NA", 21 | "ansible_board_vendor": "Oracle Corporation", 22 | "ansible_board_version": "1.2", 23 | "ansible_chassis_asset_tag": "NA", 24 | "ansible_chassis_serial": "NA", 25 | "ansible_chassis_vendor": "Oracle Corporation", 26 | "ansible_chassis_version": "NA", 27 | "ansible_cmdline": { 28 | "BOOT_IMAGE": "/boot/vmlinuz-5.4.0-131-generic", 29 | "console": "ttyS0", 30 | "ro": true, 31 | "root": "UUID=6bc3f1bb-8d64-4732-b839-77c17626afa8" 32 | }, 33 | "ansible_date_time": { 34 | "date": "2022-11-16", 35 | "day": "16", 36 | "epoch": "1668557587", 37 | "epoch_int": "1668557587", 38 | "hour": "00", 39 | "iso8601": "2022-11-16T00:13:07Z", 40 | "iso8601_basic": "20221116T001307901111", 41 | "iso8601_basic_short": "20221116T001307", 42 | "iso8601_micro": "2022-11-16T00:13:07.901111Z", 43 | "minute": "13", 44 | "month": "11", 45 | "second": "07", 46 | "time": "00:13:07", 47 | "tz": "UTC", 48 | "tz_dst": "UTC", 49 | "tz_offset": "+0000", 50 | "weekday": "Wednesday", 51 | "weekday_number": "3", 52 | "weeknumber": "46", 53 | "year": "2022" 54 | }, 55 | "ansible_default_ipv4": { 56 | "address": "10.0.2.15", 57 | "alias": "enp0s3", 58 | "broadcast": "10.0.2.255", 59 | "gateway": "10.0.2.2", 60 | "interface": "enp0s3", 61 | "macaddress": "02:9a:94:c9:30:e2", 62 | "mtu": 1500, 63 | "netmask": "255.255.255.0", 64 | "network": "10.0.2.0", 65 | "prefix": "24", 66 | "type": "ether" 67 | }, 68 | "ansible_default_ipv6": {}, 69 | "ansible_device_links": { 70 | "ids": {}, 71 | "labels": { 72 | "sda1": [ 73 | "cloudimg-rootfs" 74 | ], 75 | "sdb": [ 76 | "cidata" 77 | ] 78 | }, 79 | "masters": {}, 80 | "uuids": { 81 | "sda1": [ 82 | "6bc3f1bb-8d64-4732-b839-77c17626afa8" 83 | ], 84 | "sdb": [ 85 | "2022-11-07-21-56-22-00" 86 | ] 87 | } 88 | }, 89 | "ansible_devices": { 90 | "loop0": { 91 | "holders": [], 92 | "host": "", 93 | "links": { 94 | "ids": [], 95 | "labels": [], 96 | "masters": [], 97 | "uuids": [] 98 | }, 99 | "model": null, 100 | "partitions": {}, 101 | "removable": "0", 102 | "rotational": "1", 103 | "sas_address": null, 104 | "sas_device_handle": null, 105 | "scheduler_mode": "mq-deadline", 106 | "sectors": "98280", 107 | "sectorsize": "512", 108 | "size": "47.99 MB", 109 | "support_discard": "4096", 110 | "vendor": null, 111 | "virtual": 1 112 | }, 113 | "loop1": { 114 | "holders": [], 115 | "host": "", 116 | "links": { 117 | "ids": [], 118 | "labels": [], 119 | "masters": [], 120 | "uuids": [] 121 | }, 122 | "model": null, 123 | "partitions": {}, 124 | "removable": "0", 125 | "rotational": "1", 126 | "sas_address": null, 127 | "sas_device_handle": null, 128 | "scheduler_mode": "mq-deadline", 129 | "sectors": "138880", 130 | "sectorsize": "512", 131 | "size": "67.81 MB", 132 | "support_discard": "4096", 133 | "vendor": null, 134 | "virtual": 1 135 | }, 136 | "loop2": { 137 | "holders": [], 138 | "host": "", 139 | "links": { 140 | "ids": [], 141 | "labels": [], 142 | "masters": [], 143 | "uuids": [] 144 | }, 145 | "model": null, 146 | "partitions": {}, 147 | "removable": "0", 148 | "rotational": "1", 149 | "sas_address": null, 150 | "sas_device_handle": null, 151 | "scheduler_mode": "mq-deadline", 152 | "sectors": "129424", 153 | "sectorsize": "512", 154 | "size": "63.20 MB", 155 | "support_discard": "4096", 156 | "vendor": null, 157 | "virtual": 1 158 | }, 159 | "loop3": { 160 | "holders": [], 161 | "host": "", 162 | "links": { 163 | "ids": [], 164 | "labels": [], 165 | "masters": [], 166 | "uuids": [] 167 | }, 168 | "model": null, 169 | "partitions": {}, 170 | "removable": "0", 171 | "rotational": "1", 172 | "sas_address": null, 173 | "sas_device_handle": null, 174 | "scheduler_mode": "mq-deadline", 175 | "sectors": "129520", 176 | "sectorsize": "512", 177 | "size": "63.24 MB", 178 | "support_discard": "4096", 179 | "vendor": null, 180 | "virtual": 1 181 | }, 182 | "loop4": { 183 | "holders": [], 184 | "host": "", 185 | "links": { 186 | "ids": [], 187 | "labels": [], 188 | "masters": [], 189 | "uuids": [] 190 | }, 191 | "model": null, 192 | "partitions": {}, 193 | "removable": "0", 194 | "rotational": "1", 195 | "sas_address": null, 196 | "sas_device_handle": null, 197 | "scheduler_mode": "mq-deadline", 198 | "sectors": "0", 199 | "sectorsize": "512", 200 | "size": "0.00 Bytes", 201 | "support_discard": "0", 202 | "vendor": null, 203 | "virtual": 1 204 | }, 205 | "loop5": { 206 | "holders": [], 207 | "host": "", 208 | "links": { 209 | "ids": [], 210 | "labels": [], 211 | "masters": [], 212 | "uuids": [] 213 | }, 214 | "model": null, 215 | "partitions": {}, 216 | "removable": "0", 217 | "rotational": "1", 218 | "sas_address": null, 219 | "sas_device_handle": null, 220 | "scheduler_mode": "mq-deadline", 221 | "sectors": "0", 222 | "sectorsize": "512", 223 | "size": "0.00 Bytes", 224 | "support_discard": "0", 225 | "vendor": null, 226 | "virtual": 1 227 | }, 228 | "loop6": { 229 | "holders": [], 230 | "host": "", 231 | "links": { 232 | "ids": [], 233 | "labels": [], 234 | "masters": [], 235 | "uuids": [] 236 | }, 237 | "model": null, 238 | "partitions": {}, 239 | "removable": "0", 240 | "rotational": "1", 241 | "sas_address": null, 242 | "sas_device_handle": null, 243 | "scheduler_mode": "mq-deadline", 244 | "sectors": "0", 245 | "sectorsize": "512", 246 | "size": "0.00 Bytes", 247 | "support_discard": "0", 248 | "vendor": null, 249 | "virtual": 1 250 | }, 251 | "loop7": { 252 | "holders": [], 253 | "host": "", 254 | "links": { 255 | "ids": [], 256 | "labels": [], 257 | "masters": [], 258 | "uuids": [] 259 | }, 260 | "model": null, 261 | "partitions": {}, 262 | "removable": "0", 263 | "rotational": "1", 264 | "sas_address": null, 265 | "sas_device_handle": null, 266 | "scheduler_mode": "mq-deadline", 267 | "sectors": "0", 268 | "sectorsize": "512", 269 | "size": "0.00 Bytes", 270 | "support_discard": "0", 271 | "vendor": null, 272 | "virtual": 1 273 | }, 274 | "sda": { 275 | "holders": [], 276 | "host": "SCSI storage controller: Broadcom / LSI 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI", 277 | "links": { 278 | "ids": [], 279 | "labels": [], 280 | "masters": [], 281 | "uuids": [] 282 | }, 283 | "model": "HARDDISK", 284 | "partitions": { 285 | "sda1": { 286 | "holders": [], 287 | "links": { 288 | "ids": [], 289 | "labels": [ 290 | "cloudimg-rootfs" 291 | ], 292 | "masters": [], 293 | "uuids": [ 294 | "6bc3f1bb-8d64-4732-b839-77c17626afa8" 295 | ] 296 | }, 297 | "sectors": "83883999", 298 | "sectorsize": 512, 299 | "size": "40.00 GB", 300 | "start": "2048", 301 | "uuid": "6bc3f1bb-8d64-4732-b839-77c17626afa8" 302 | } 303 | }, 304 | "removable": "0", 305 | "rotational": "1", 306 | "sas_address": null, 307 | "sas_device_handle": null, 308 | "scheduler_mode": "mq-deadline", 309 | "sectors": "83886080", 310 | "sectorsize": "512", 311 | "size": "40.00 GB", 312 | "support_discard": "0", 313 | "vendor": "VBOX", 314 | "virtual": 1 315 | }, 316 | "sdb": { 317 | "holders": [], 318 | "host": "SCSI storage controller: Broadcom / LSI 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI", 319 | "links": { 320 | "ids": [], 321 | "labels": [ 322 | "cidata" 323 | ], 324 | "masters": [], 325 | "uuids": [ 326 | "2022-11-07-21-56-22-00" 327 | ] 328 | }, 329 | "model": "HARDDISK", 330 | "partitions": {}, 331 | "removable": "0", 332 | "rotational": "1", 333 | "sas_address": null, 334 | "sas_device_handle": null, 335 | "scheduler_mode": "mq-deadline", 336 | "sectors": "20480", 337 | "sectorsize": "512", 338 | "size": "10.00 MB", 339 | "support_discard": "0", 340 | "vendor": "VBOX", 341 | "virtual": 1 342 | } 343 | }, 344 | "ansible_distribution": "Ubuntu", 345 | "ansible_distribution_file_parsed": true, 346 | "ansible_distribution_file_path": "/etc/os-release", 347 | "ansible_distribution_file_variety": "Debian", 348 | "ansible_distribution_major_version": "20", 349 | "ansible_distribution_release": "focal", 350 | "ansible_distribution_version": "20.04", 351 | "ansible_dns": { 352 | "nameservers": [ 353 | "127.0.0.53" 354 | ], 355 | "options": { 356 | "edns0": true, 357 | "trust-ad": true 358 | } 359 | }, 360 | "ansible_domain": "", 361 | "ansible_effective_group_id": 1000, 362 | "ansible_effective_user_id": 1000, 363 | "ansible_enp0s3": { 364 | "active": true, 365 | "device": "enp0s3", 366 | "features": { 367 | "esp_hw_offload": "off [fixed]", 368 | "esp_tx_csum_hw_offload": "off [fixed]", 369 | "fcoe_mtu": "off [fixed]", 370 | "generic_receive_offload": "on", 371 | "generic_segmentation_offload": "on", 372 | "highdma": "off [fixed]", 373 | "hw_tc_offload": "off [fixed]", 374 | "l2_fwd_offload": "off [fixed]", 375 | "large_receive_offload": "off [fixed]", 376 | "loopback": "off [fixed]", 377 | "netns_local": "off [fixed]", 378 | "ntuple_filters": "off [fixed]", 379 | "receive_hashing": "off [fixed]", 380 | "rx_all": "off", 381 | "rx_checksumming": "off", 382 | "rx_fcs": "off", 383 | "rx_gro_hw": "off [fixed]", 384 | "rx_udp_tunnel_port_offload": "off [fixed]", 385 | "rx_vlan_filter": "on [fixed]", 386 | "rx_vlan_offload": "on", 387 | "rx_vlan_stag_filter": "off [fixed]", 388 | "rx_vlan_stag_hw_parse": "off [fixed]", 389 | "scatter_gather": "on", 390 | "tcp_segmentation_offload": "on", 391 | "tls_hw_record": "off [fixed]", 392 | "tls_hw_rx_offload": "off [fixed]", 393 | "tls_hw_tx_offload": "off [fixed]", 394 | "tx_checksum_fcoe_crc": "off [fixed]", 395 | "tx_checksum_ip_generic": "on", 396 | "tx_checksum_ipv4": "off [fixed]", 397 | "tx_checksum_ipv6": "off [fixed]", 398 | "tx_checksum_sctp": "off [fixed]", 399 | "tx_checksumming": "on", 400 | "tx_esp_segmentation": "off [fixed]", 401 | "tx_fcoe_segmentation": "off [fixed]", 402 | "tx_gre_csum_segmentation": "off [fixed]", 403 | "tx_gre_segmentation": "off [fixed]", 404 | "tx_gso_partial": "off [fixed]", 405 | "tx_gso_robust": "off [fixed]", 406 | "tx_ipxip4_segmentation": "off [fixed]", 407 | "tx_ipxip6_segmentation": "off [fixed]", 408 | "tx_lockless": "off [fixed]", 409 | "tx_nocache_copy": "off", 410 | "tx_scatter_gather": "on", 411 | "tx_scatter_gather_fraglist": "off [fixed]", 412 | "tx_sctp_segmentation": "off [fixed]", 413 | "tx_tcp6_segmentation": "off [fixed]", 414 | "tx_tcp_ecn_segmentation": "off [fixed]", 415 | "tx_tcp_mangleid_segmentation": "off", 416 | "tx_tcp_segmentation": "on", 417 | "tx_udp_segmentation": "off [fixed]", 418 | "tx_udp_tnl_csum_segmentation": "off [fixed]", 419 | "tx_udp_tnl_segmentation": "off [fixed]", 420 | "tx_vlan_offload": "on [fixed]", 421 | "tx_vlan_stag_hw_insert": "off [fixed]", 422 | "vlan_challenged": "off [fixed]" 423 | }, 424 | "hw_timestamp_filters": [], 425 | "ipv4": { 426 | "address": "10.0.2.15", 427 | "broadcast": "10.0.2.255", 428 | "netmask": "255.255.255.0", 429 | "network": "10.0.2.0", 430 | "prefix": "24" 431 | }, 432 | "ipv6": [ 433 | { 434 | "address": "fe80::9a:94ff:fec9:30e2", 435 | "prefix": "64", 436 | "scope": "link" 437 | } 438 | ], 439 | "macaddress": "02:9a:94:c9:30:e2", 440 | "module": "e1000", 441 | "mtu": 1500, 442 | "pciid": "0000:00:03.0", 443 | "promisc": false, 444 | "speed": 1000, 445 | "timestamping": [ 446 | "tx_software", 447 | "rx_software", 448 | "software" 449 | ], 450 | "type": "ether" 451 | }, 452 | "ansible_enp0s8": { 453 | "active": true, 454 | "device": "enp0s8", 455 | "features": { 456 | "esp_hw_offload": "off [fixed]", 457 | "esp_tx_csum_hw_offload": "off [fixed]", 458 | "fcoe_mtu": "off [fixed]", 459 | "generic_receive_offload": "on", 460 | "generic_segmentation_offload": "on", 461 | "highdma": "off [fixed]", 462 | "hw_tc_offload": "off [fixed]", 463 | "l2_fwd_offload": "off [fixed]", 464 | "large_receive_offload": "off [fixed]", 465 | "loopback": "off [fixed]", 466 | "netns_local": "off [fixed]", 467 | "ntuple_filters": "off [fixed]", 468 | "receive_hashing": "off [fixed]", 469 | "rx_all": "off", 470 | "rx_checksumming": "off", 471 | "rx_fcs": "off", 472 | "rx_gro_hw": "off [fixed]", 473 | "rx_udp_tunnel_port_offload": "off [fixed]", 474 | "rx_vlan_filter": "on [fixed]", 475 | "rx_vlan_offload": "on", 476 | "rx_vlan_stag_filter": "off [fixed]", 477 | "rx_vlan_stag_hw_parse": "off [fixed]", 478 | "scatter_gather": "on", 479 | "tcp_segmentation_offload": "on", 480 | "tls_hw_record": "off [fixed]", 481 | "tls_hw_rx_offload": "off [fixed]", 482 | "tls_hw_tx_offload": "off [fixed]", 483 | "tx_checksum_fcoe_crc": "off [fixed]", 484 | "tx_checksum_ip_generic": "on", 485 | "tx_checksum_ipv4": "off [fixed]", 486 | "tx_checksum_ipv6": "off [fixed]", 487 | "tx_checksum_sctp": "off [fixed]", 488 | "tx_checksumming": "on", 489 | "tx_esp_segmentation": "off [fixed]", 490 | "tx_fcoe_segmentation": "off [fixed]", 491 | "tx_gre_csum_segmentation": "off [fixed]", 492 | "tx_gre_segmentation": "off [fixed]", 493 | "tx_gso_partial": "off [fixed]", 494 | "tx_gso_robust": "off [fixed]", 495 | "tx_ipxip4_segmentation": "off [fixed]", 496 | "tx_ipxip6_segmentation": "off [fixed]", 497 | "tx_lockless": "off [fixed]", 498 | "tx_nocache_copy": "off", 499 | "tx_scatter_gather": "on", 500 | "tx_scatter_gather_fraglist": "off [fixed]", 501 | "tx_sctp_segmentation": "off [fixed]", 502 | "tx_tcp6_segmentation": "off [fixed]", 503 | "tx_tcp_ecn_segmentation": "off [fixed]", 504 | "tx_tcp_mangleid_segmentation": "off", 505 | "tx_tcp_segmentation": "on", 506 | "tx_udp_segmentation": "off [fixed]", 507 | "tx_udp_tnl_csum_segmentation": "off [fixed]", 508 | "tx_udp_tnl_segmentation": "off [fixed]", 509 | "tx_vlan_offload": "on [fixed]", 510 | "tx_vlan_stag_hw_insert": "off [fixed]", 511 | "vlan_challenged": "off [fixed]" 512 | }, 513 | "hw_timestamp_filters": [], 514 | "ipv4": { 515 | "address": "192.168.15.119", 516 | "broadcast": "192.168.15.255", 517 | "netmask": "255.255.255.0", 518 | "network": "192.168.15.0", 519 | "prefix": "24" 520 | }, 521 | "ipv6": [ 522 | { 523 | "address": "fe80::a00:27ff:fea0:f6f7", 524 | "prefix": "64", 525 | "scope": "link" 526 | } 527 | ], 528 | "macaddress": "08:00:27:a0:f6:f7", 529 | "module": "e1000", 530 | "mtu": 1500, 531 | "pciid": "0000:00:08.0", 532 | "promisc": false, 533 | "speed": 1000, 534 | "timestamping": [ 535 | "tx_software", 536 | "rx_software", 537 | "software" 538 | ], 539 | "type": "ether" 540 | }, 541 | "ansible_env": { 542 | "DBUS_SESSION_BUS_ADDRESS": "unix:path=/run/user/1000/bus", 543 | "HOME": "/home/vagrant", 544 | "LANG": "C.UTF-8", 545 | "LOGNAME": "vagrant", 546 | "MOTD_SHOWN": "pam", 547 | "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin", 548 | "PWD": "/home/vagrant", 549 | "SHELL": "/bin/bash", 550 | "SHLVL": "0", 551 | "SSH_CLIENT": "192.168.15.117 59996 22", 552 | "SSH_CONNECTION": "192.168.15.117 59996 192.168.15.119 22", 553 | "SSH_TTY": "/dev/pts/0", 554 | "TERM": "xterm-256color", 555 | "USER": "vagrant", 556 | "XDG_RUNTIME_DIR": "/run/user/1000", 557 | "XDG_SESSION_CLASS": "user", 558 | "XDG_SESSION_ID": "22", 559 | "XDG_SESSION_TYPE": "tty", 560 | "_": "/bin/sh" 561 | }, 562 | "ansible_fibre_channel_wwn": [], 563 | "ansible_fips": false, 564 | "ansible_form_factor": "Other", 565 | "ansible_fqdn": "ubuntu-focal", 566 | "ansible_hostname": "ubuntu-focal", 567 | "ansible_hostnqn": "", 568 | "ansible_interfaces": [ 569 | "enp0s3", 570 | "lo", 571 | "enp0s8" 572 | ], 573 | "ansible_is_chroot": false, 574 | "ansible_iscsi_iqn": "", 575 | "ansible_kernel": "5.4.0-131-generic", 576 | "ansible_kernel_version": "#147-Ubuntu SMP Fri Oct 14 17:07:22 UTC 2022", 577 | "ansible_lo": { 578 | "active": true, 579 | "device": "lo", 580 | "features": { 581 | "esp_hw_offload": "off [fixed]", 582 | "esp_tx_csum_hw_offload": "off [fixed]", 583 | "fcoe_mtu": "off [fixed]", 584 | "generic_receive_offload": "on", 585 | "generic_segmentation_offload": "on", 586 | "highdma": "on [fixed]", 587 | "hw_tc_offload": "off [fixed]", 588 | "l2_fwd_offload": "off [fixed]", 589 | "large_receive_offload": "off [fixed]", 590 | "loopback": "on [fixed]", 591 | "netns_local": "on [fixed]", 592 | "ntuple_filters": "off [fixed]", 593 | "receive_hashing": "off [fixed]", 594 | "rx_all": "off [fixed]", 595 | "rx_checksumming": "on [fixed]", 596 | "rx_fcs": "off [fixed]", 597 | "rx_gro_hw": "off [fixed]", 598 | "rx_udp_tunnel_port_offload": "off [fixed]", 599 | "rx_vlan_filter": "off [fixed]", 600 | "rx_vlan_offload": "off [fixed]", 601 | "rx_vlan_stag_filter": "off [fixed]", 602 | "rx_vlan_stag_hw_parse": "off [fixed]", 603 | "scatter_gather": "on", 604 | "tcp_segmentation_offload": "on", 605 | "tls_hw_record": "off [fixed]", 606 | "tls_hw_rx_offload": "off [fixed]", 607 | "tls_hw_tx_offload": "off [fixed]", 608 | "tx_checksum_fcoe_crc": "off [fixed]", 609 | "tx_checksum_ip_generic": "on [fixed]", 610 | "tx_checksum_ipv4": "off [fixed]", 611 | "tx_checksum_ipv6": "off [fixed]", 612 | "tx_checksum_sctp": "on [fixed]", 613 | "tx_checksumming": "on", 614 | "tx_esp_segmentation": "off [fixed]", 615 | "tx_fcoe_segmentation": "off [fixed]", 616 | "tx_gre_csum_segmentation": "off [fixed]", 617 | "tx_gre_segmentation": "off [fixed]", 618 | "tx_gso_partial": "off [fixed]", 619 | "tx_gso_robust": "off [fixed]", 620 | "tx_ipxip4_segmentation": "off [fixed]", 621 | "tx_ipxip6_segmentation": "off [fixed]", 622 | "tx_lockless": "on [fixed]", 623 | "tx_nocache_copy": "off [fixed]", 624 | "tx_scatter_gather": "on [fixed]", 625 | "tx_scatter_gather_fraglist": "on [fixed]", 626 | "tx_sctp_segmentation": "on", 627 | "tx_tcp6_segmentation": "on", 628 | "tx_tcp_ecn_segmentation": "on", 629 | "tx_tcp_mangleid_segmentation": "on", 630 | "tx_tcp_segmentation": "on", 631 | "tx_udp_segmentation": "off [fixed]", 632 | "tx_udp_tnl_csum_segmentation": "off [fixed]", 633 | "tx_udp_tnl_segmentation": "off [fixed]", 634 | "tx_vlan_offload": "off [fixed]", 635 | "tx_vlan_stag_hw_insert": "off [fixed]", 636 | "vlan_challenged": "on [fixed]" 637 | }, 638 | "hw_timestamp_filters": [], 639 | "ipv4": { 640 | "address": "127.0.0.1", 641 | "broadcast": "", 642 | "netmask": "255.0.0.0", 643 | "network": "127.0.0.0", 644 | "prefix": "8" 645 | }, 646 | "ipv6": [ 647 | { 648 | "address": "::1", 649 | "prefix": "128", 650 | "scope": "host" 651 | } 652 | ], 653 | "mtu": 65536, 654 | "promisc": false, 655 | "timestamping": [ 656 | "tx_software", 657 | "rx_software", 658 | "software" 659 | ], 660 | "type": "loopback" 661 | }, 662 | "ansible_loadavg": { 663 | "15m": 0.0, 664 | "1m": 0.02, 665 | "5m": 0.01 666 | }, 667 | "ansible_local": {}, 668 | "ansible_lsb": { 669 | "codename": "focal", 670 | "description": "Ubuntu 20.04.5 LTS", 671 | "id": "Ubuntu", 672 | "major_release": "20", 673 | "release": "20.04" 674 | }, 675 | "ansible_lvm": "N/A", 676 | "ansible_machine": "x86_64", 677 | "ansible_machine_id": "195813eaee3d43de9d3b43b009b9eaca", 678 | "ansible_memfree_mb": 220, 679 | "ansible_memory_mb": { 680 | "nocache": { 681 | "free": 754, 682 | "used": 222 683 | }, 684 | "real": { 685 | "free": 220, 686 | "total": 976, 687 | "used": 756 688 | }, 689 | "swap": { 690 | "cached": 0, 691 | "free": 0, 692 | "total": 0, 693 | "used": 0 694 | } 695 | }, 696 | "ansible_memtotal_mb": 976, 697 | "ansible_mounts": [ 698 | { 699 | "block_available": 9720500, 700 | "block_size": 4096, 701 | "block_total": 10145391, 702 | "block_used": 424891, 703 | "device": "/dev/sda1", 704 | "fstype": "ext4", 705 | "inode_available": 5046997, 706 | "inode_total": 5120000, 707 | "inode_used": 73003, 708 | "mount": "/", 709 | "options": "rw,relatime", 710 | "size_available": 39815168000, 711 | "size_total": 41555521536, 712 | "uuid": "6bc3f1bb-8d64-4732-b839-77c17626afa8" 713 | }, 714 | { 715 | "block_available": 0, 716 | "block_size": 131072, 717 | "block_total": 384, 718 | "block_used": 384, 719 | "device": "/dev/loop0", 720 | "fstype": "squashfs", 721 | "inode_available": 0, 722 | "inode_total": 486, 723 | "inode_used": 486, 724 | "mount": "/snap/snapd/17336", 725 | "options": "ro,nodev,relatime", 726 | "size_available": 0, 727 | "size_total": 50331648, 728 | "uuid": "N/A" 729 | }, 730 | { 731 | "block_available": 0, 732 | "block_size": 131072, 733 | "block_total": 506, 734 | "block_used": 506, 735 | "device": "/dev/loop2", 736 | "fstype": "squashfs", 737 | "inode_available": 0, 738 | "inode_total": 11885, 739 | "inode_used": 11885, 740 | "mount": "/snap/core20/1634", 741 | "options": "ro,nodev,relatime", 742 | "size_available": 0, 743 | "size_total": 66322432, 744 | "uuid": "N/A" 745 | }, 746 | { 747 | "block_available": 0, 748 | "block_size": 131072, 749 | "block_total": 543, 750 | "block_used": 543, 751 | "device": "/dev/loop1", 752 | "fstype": "squashfs", 753 | "inode_available": 0, 754 | "inode_total": 802, 755 | "inode_used": 802, 756 | "mount": "/snap/lxd/22753", 757 | "options": "ro,nodev,relatime", 758 | "size_available": 0, 759 | "size_total": 71172096, 760 | "uuid": "N/A" 761 | }, 762 | { 763 | "block_available": 0, 764 | "block_size": 131072, 765 | "block_total": 506, 766 | "block_used": 506, 767 | "device": "/dev/loop3", 768 | "fstype": "squashfs", 769 | "inode_available": 0, 770 | "inode_total": 11897, 771 | "inode_used": 11897, 772 | "mount": "/snap/core20/1695", 773 | "options": "ro,nodev,relatime", 774 | "size_available": 0, 775 | "size_total": 66322432, 776 | "uuid": "N/A" 777 | } 778 | ], 779 | "ansible_nodename": "ubuntu-focal", 780 | "ansible_os_family": "Debian", 781 | "ansible_pkg_mgr": "apt", 782 | "ansible_proc_cmdline": { 783 | "BOOT_IMAGE": "/boot/vmlinuz-5.4.0-131-generic", 784 | "console": [ 785 | "tty1", 786 | "ttyS0" 787 | ], 788 | "ro": true, 789 | "root": "UUID=6bc3f1bb-8d64-4732-b839-77c17626afa8" 790 | }, 791 | "ansible_processor": [ 792 | "0", 793 | "GenuineIntel", 794 | "Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz", 795 | "1", 796 | "GenuineIntel", 797 | "Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz" 798 | ], 799 | "ansible_processor_cores": 2, 800 | "ansible_processor_count": 1, 801 | "ansible_processor_nproc": 2, 802 | "ansible_processor_threads_per_core": 1, 803 | "ansible_processor_vcpus": 2, 804 | "ansible_product_name": "VirtualBox", 805 | "ansible_product_serial": "NA", 806 | "ansible_product_uuid": "NA", 807 | "ansible_product_version": "1.2", 808 | "ansible_python": { 809 | "executable": "/usr/bin/python3", 810 | "has_sslcontext": true, 811 | "type": "cpython", 812 | "version": { 813 | "major": 3, 814 | "micro": 10, 815 | "minor": 8, 816 | "releaselevel": "final", 817 | "serial": 0 818 | }, 819 | "version_info": [ 820 | 3, 821 | 8, 822 | 10, 823 | "final", 824 | 0 825 | ] 826 | }, 827 | "ansible_python_version": "3.8.10", 828 | "ansible_real_group_id": 1000, 829 | "ansible_real_user_id": 1000, 830 | "ansible_selinux": { 831 | "status": "disabled" 832 | }, 833 | "ansible_selinux_python_present": true, 834 | "ansible_service_mgr": "systemd", 835 | "ansible_ssh_host_key_dsa_public": "AAAAB3NzaC1kc3MAAACBAKJPGXPhXCnU6IScZeizGB7oI4Lu3vOhO4OAkvMSCZ+Xxh2beVXIOsH1/8OdjmLoa8Wk3anjp9incwgYeo7TogNgDYUyCVD8Z/FLKQhRHn6T8ZU1kFSiSHZJEMiNdmxVADYD05GUVdHohVHyLqRK2cbmDC1nDGOIQhsfPfHcyurtAAAAFQCe2J0JsaPRQeOwu43vnkUPHXe7BwAAAH9wL+ZnEntCDLTiBNHqR74XV3YOfjVBT+MLjsWEMLwR62fJwrz+rcHYYF7MfmKzukdontB//J2n+JfZmcmUryPu9D5MWSzs6dYzk74gCNd0P3AE9WzTntQcCPpemeRSixUwkluviHDkoFpCIjOE1UIGMPkkb3J/oGSFP9OidSFCAAAAgQCCZt8XXnxOFwGVJrclcsX5LMKRjwUMkI0c7Janm/nmRXO9GVCgh7XPOIGiEpWk1jjC4MJTcD8okbwbrG/jwB3/J+Kf4t2YyWFFxRb36tnC7CCKfdruv1Jsbau5d5XiizxRsnaEXM0GRQiJEFqLCHeenkIRzjX9dwLr+1pZeozaQA==", 836 | "ansible_ssh_host_key_dsa_public_keytype": "ssh-dss", 837 | "ansible_ssh_host_key_ecdsa_public": "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLBq3mAHTE0tEKZDkCebXcRN9mokZdl6HVvdnAyUq9Rii6E2YSar41rvVAbRNHun+iLtUx9uU6pvzTT4Ud3229o=", 838 | "ansible_ssh_host_key_ecdsa_public_keytype": "ecdsa-sha2-nistp256", 839 | "ansible_ssh_host_key_ed25519_public": "AAAAC3NzaC1lZDI1NTE5AAAAIEj3N2yfkYgs73TmIHTzWgYv+wwolBpEhoGfgPesxFG2", 840 | "ansible_ssh_host_key_ed25519_public_keytype": "ssh-ed25519", 841 | "ansible_ssh_host_key_rsa_public": "AAAAB3NzaC1yc2EAAAADAQABAAABgQCwAA1drBOrULpf5TE5s/8qw5KyWVc2GbakBqdlv6NmYjcomPx/SCXrALwV43wbkVsWFZC8W+iKtToyoNhIt8JFVu8WPqlayMBv3e8iw5WOOwXt8opQ67UCDIHgvioBIjETwlsvPCxbDd8o50ttfPD8LdYl+ucThlPhE2hCLtWgkehdGm0jCTRiBLhRYQbLCYYbUIgcnnEFW3rGMxAVweuY4mNN/WNMJNh5yPaDPLspTHDNR7HJ/FHia1T8Wpyu6eznT6sk5Au1/X4qCMdUnPxBtzyjsN8Ja8dnLRDSbAMbf7+skbPZFn8t1ax34UsnGDN8dRhUkM+C9avekCJ8V52lxWjQaCeO9cdzB3ya3JS0GIm6niryH0wy1oMSGrPtNwIrknmutp3kF3ni/bkC6P4+SViv4/BeOrz9eUhvA9/Om6C6Wqoj8ji0tGJ3Z1w8J1SjnIc2WdRmxD3TRR4yoqjrcAa2oQGcOmkq+T/5wi3fzZbdDA182B6bwlBbAHszv2U=", 842 | "ansible_ssh_host_key_rsa_public_keytype": "ssh-rsa", 843 | "ansible_swapfree_mb": 0, 844 | "ansible_swaptotal_mb": 0, 845 | "ansible_system": "Linux", 846 | "ansible_system_capabilities": [ 847 | "" 848 | ], 849 | "ansible_system_capabilities_enforced": "True", 850 | "ansible_system_vendor": "innotek GmbH", 851 | "ansible_uptime_seconds": 7569, 852 | "ansible_user_dir": "/home/vagrant", 853 | "ansible_user_gecos": ",,,", 854 | "ansible_user_gid": 1000, 855 | "ansible_user_id": "vagrant", 856 | "ansible_user_shell": "/bin/bash", 857 | "ansible_user_uid": 1000, 858 | "ansible_userspace_architecture": "x86_64", 859 | "ansible_userspace_bits": "64", 860 | "ansible_virtualization_role": "guest", 861 | "ansible_virtualization_tech_guest": [ 862 | "virtualbox" 863 | ], 864 | "ansible_virtualization_tech_host": [], 865 | "ansible_virtualization_type": "virtualbox", 866 | "discovered_interpreter_python": "/usr/bin/python3", 867 | "gather_subset": [ 868 | "all" 869 | ], 870 | "module_setup": true 871 | }, 872 | "changed": false 873 | } 874 | -------------------------------------------------------------------------------- /stuff/vagrant.md: -------------------------------------------------------------------------------- 1 | ## Sumário 2 | 3 | - [Configurando seu laboratório](#configurando-seu-laborat%C3%B3rio) 4 | - [Básico necessário sobre Vagrant](#b%C3%A1sico-necess%C3%A1rio-sobre-vagrant) 5 | - [Configurando duas máquinas virtuais](#configurando-duas-máquinas-virtuais) 6 | - [Configurações adicionais do vagrant](#configurações-adicionais-no-vagrant) 7 | 8 | --- 9 | 10 | ## Instalação do Virtualbox e do Vagrant 11 | 12 | Ansiedade já bateu, né? Vamos construindo uma passinho de cada vez. 13 | 14 | ### Passos para instalação 15 | 16 | > Caso você use o windows, as instalações podem ser feitas via [chocolatey](https://chocolatey.org/install#individual) 17 | 18 | - Abra seu terminal de preferência 19 | 20 | - Instale o virtualbox: 21 | 22 | ```bash 23 | paru -S virtualbox # Arch 24 | choco install virtualbox # Windows 25 | sudo apt-get install virtualbox # Ubuntu 26 | ``` 27 | 28 | - Instale o Vagrant: 29 | ``` 30 | paru -S vagrant # Arch 31 | choco install vagrant # Windows 32 | sudo apt install vagrant # Ubuntu 33 | ``` 34 | 35 | ## Básico necessário sobre Vagrant 36 | 37 | Vagrant é uma ferramenta para provisionamento de máquinas virtuais. Dizendo de forma simples, ele cria e configura máquinas virtuais usando um arquivo de configuração chamado `Vagrantfile`. Nesse arquivo podemos descrever como nossas vms serão configuras. 38 | 39 | Exemplo de um arquivo do Vagrant: 40 | 41 | ```ruby 42 | # nome do arquivo: Vagrantifle 43 | Vagrant.configure("2") do |config| 44 | config.vm.box = "archlinux/archlinux" 45 | end 46 | ``` 47 | 48 | Se tivermos esse arquivo no nosso diretório, podemos executar o vagrant: 49 | 50 | ```bash 51 | vagrant up 52 | ``` 53 | 54 | E ele criará uma máquina virtual com archlinux no nosso virtualbox. 55 | 56 | OBS: Esse comando pode demorar um pouco pois ele vai baixar um hd virtual do archlinux e instalar no seu virtualbox. 57 | 58 | ### Configurando duas máquinas virtuais 59 | 60 | O ansible só oferece suporte para ser executado no linux. Ele pode até configurar máquinas windows, porém só pode ser disparado por uma máquina linux. Para evitar sujar seu ambiente ou mesmo caso você use windows como seu sistema operacional principal. Vamos configurar duas máquinas virtuais com linux. 61 | 62 | Para isso, só precisamos alterar nosso `Vagrantfile`: 63 | 64 | ```ruby 65 | Vagrant.configure("2") do |config| 66 | 67 | config.vm.define "arch" do |arch| 68 | arch.vm.box = "archlinux/archlinux" 69 | end 70 | 71 | config.vm.define "ubuntu" do |ubuntu| 72 | ubuntu.vm.box = "ubuntu/focal64" 73 | end 74 | 75 | end 76 | ``` 77 | 78 | Com isso, agora temos uma vm com ubuntu e outra com archlinux. 79 | 80 | Para dar start nas vms agora podemos fazer de duas formas. Subir uma só ou as duas 81 | 82 | Para subir as duas, podemos usar `vagrant up` como fizemos antes. 83 | 84 | Caso queira subir só o ubuntu `vagrant up ubuntu` ou para subir somente o arch `vagrant up arch`. 85 | 86 | ### Configurações adicionais no Vagrant 87 | 88 | Algumas configurações adicionais para simplificar a criação das nossas máquinas virtuais. 89 | 90 | #### IP Local 91 | Se quisermos conseguir acessar as vms de fora do ambiente precisamos dar um endereço para elas usando nossa rede local, pelo protocolo DHCP. Podemos fazer isso alterando o `Vagrantfile`: 92 | 93 | ```ruby 94 | Vagrant.configure("2") do |config| 95 | 96 | config.vm.define "arch" do |arch| 97 | arch.vm.box = "archlinux/archlinux" 98 | arch.vm.network "public_network", 99 | use_dhcp_assigned_default_route: true 100 | end 101 | 102 | config.vm.define "ubuntu" do |ubuntu| 103 | ubuntu.vm.box = "ubuntu/focal64" 104 | ubuntu.vm.network "public_network", 105 | use_dhcp_assigned_default_route: true 106 | end 107 | 108 | end 109 | ``` 110 | 111 | Isso criará uma nova placa de rede na vm e permitirá o acesso via ssh dá nossa máquina local. 112 | 113 | Para que essas ações passem a valer nas máquinas, precisamos pedir ao vagrant que refaça a configuração delas. 114 | 115 | ```bash 116 | vagrant reload 117 | ``` 118 | 119 | > Quando executar esse passo, caso você tenha mais de uma placa de rede, por exemplo um notebook, ele vai perguntar em qual placa você quer que o dhcp seja usado. Escolha a sua placa conectada a internet. 120 | 121 | 122 | #### Configurações de memória e HD das vms 123 | 124 | Caso tenha alguns problemas relativos a uso de memória ou disco, essas configurações podem te ajudar. 125 | 126 | #### Memória RAM 127 | Caso você tenha um hardware mais modesto e deseja que as vms usem menos memória. ou que sabe tenha mais hardware e deseja que sua vm tenha mais memória. Você pode alterar a quantidade da vm no `Vagrantfile`: 128 | 129 | ```ruby 130 | Vagrant.configure("2") do |config| 131 | 132 | config.vm.define "arch" do |arch| 133 | arch.vm.box = "archlinux/archlinux" 134 | arch.vm.network "public_network", 135 | use_dhcp_assigned_default_route: true 136 | 137 | arch.vm.provider "virtualbox" do |vb| 138 | vb.memory = "1024" 139 | end 140 | 141 | end 142 | 143 | config.vm.define "ubuntu" do |ubuntu| 144 | ubuntu.vm.box = "ubuntu/focal64" 145 | ubuntu.vm.network "public_network", 146 | use_dhcp_assigned_default_route: true 147 | 148 | ubuntu.vm.provider "virtualbox" do |vb| 149 | vb.memory = "1024" 150 | end 151 | 152 | end 153 | 154 | end 155 | ``` 156 | 157 | Nesse caso, todas as máquinas agora tem 1GB de memória. Você pode alterar para suas necessidades. 158 | 159 | Para aplicar, usamos novamente o comando `vagrant reload` 160 | 161 | #### Alterando o tamanho dos HDs 162 | 163 | Caso o disco esteja menor do que você precisa e não consiga performar algumas ações por falta de espaço no disco, você pode instalar o plugin `vagrant-disksize`. Para que ele faça a modificação no tamanho do disco: 164 | 165 | ```bash 166 | vagrant plugin install vagrant-disksize 167 | ``` 168 | 169 | Agora você pode alterar o tamanho do disco da vm no `Vagrantfile`: 170 | 171 | ```ruby 172 | Vagrant.configure("2") do |config| 173 | 174 | config.vm.define "arch" do |arch| 175 | arch.vm.box = "archlinux/archlinux" 176 | arch.disksize.size = "30GB" # Linha que muda o tamanho do disco, só precisa dela 177 | 178 | # O resto do arquivo foi omitido 179 | ``` 180 | 181 | Para aplicar, usamos novamente o comando `vagrant reload` 182 | 183 | #### Dando start nos sistemas atualizados 184 | 185 | Um passo importante, para criarmos nosso ambiente é que ele já comece atualizado. Para não perdemos tempo atualizando o sistema logo de início. Para isso só temos que alterar no `Vagrantfile` para executar uma ação de provisionamento no shell: 186 | 187 | ```ruby 188 | .vm.provision "shell", inline: <<-SHELL 189 | 190 | SHELL 191 | ``` 192 | 193 | Os comandos variam de sistema para sistema. O Archlinux usa o `pacman` como gerenciador de pacote, os sistemas baseados em Debian o `apt`, os sistemas da família red hat usam `dnf`. Então, lembre-se de usar o comando certo para atualizar. Um exemplo do nosso `Vagrantfile`: 194 | 195 | ```ruby 196 | Vagrant.configure("2") do |config| 197 | 198 | config.vm.define "arch" do |arch| 199 | arch.vm.box = "archlinux/archlinux" 200 | arch.disksize.size = "30GB" 201 | arch.vm.network "public_network", 202 | use_dhcp_assigned_default_route: true 203 | 204 | arch.vm.provider "virtualbox" do |vb| 205 | vb.memory = "1024" 206 | end 207 | 208 | arch.vm.provision "shell", inline: <<-SHELL 209 | pacman -Syu --noconfirm 210 | SHELL 211 | end 212 | 213 | config.vm.define "ubuntu" do |ubuntu| 214 | ubuntu.vm.box = "ubuntu/focal64" 215 | ubuntu.vm.network "public_network", 216 | use_dhcp_assigned_default_route: true 217 | 218 | ubuntu.vm.provider "virtualbox" do |vb| 219 | vb.memory = "1024" 220 | end 221 | 222 | ubuntu.vm.provision "shell", inline: <<-SHELL 223 | apt-get update 224 | apt-get upgrade -y 225 | SHELL 226 | end 227 | 228 | end 229 | ``` 230 | 231 | Para que essas ações sejam performadas. Executamos `vagrant provision` 232 | 233 | #### Configurações de SSH 234 | 235 | Para que o ansible possa acessar de forma plena as máquinas virtuais, é sempre bom garantir que as máquinas virtuais estejam com o serviço de ssh configurado. Então, podemos adicionar essa configuração na fase de provisionamento do `Vagrantfile`: 236 | 237 | ```ruby 238 | .vm.provision "shell", inline: <<-SHELL 239 | sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config 240 | systemctl restart sshd 241 | SHELL 242 | ``` 243 | 244 | Assim, garantirmos que o ssh está devidamente configurado. Para executar o provisionamento novamente: 245 | 246 | ```bash 247 | vagrant provision 248 | ``` 249 | --------------------------------------------------------------------------------