├── .gitignore ├── LICENSE ├── README.md ├── defaults └── main.yml ├── files ├── coreos_images │ ├── .add_to_git │ └── .coreos_images_offline └── generated_configs │ ├── .add_to_git │ └── .generated_files_here ├── handlers └── main.yml ├── meta └── main.yml ├── tasks ├── bootstrap.yml ├── bootstrap_cloudinit.yml ├── bootstrap_ignition.yml ├── bootstrap_launch.yml ├── coreos_offline_image.yml ├── generate_config.yml └── main.yml ├── templates ├── coreos_cloudinit.yml.j2 └── coreos_ignition.json.j2 └── tests ├── README.md ├── Vagrantfile ├── ansible_coreos_tests.yml ├── config.rb ├── copy_ssh_keys.sh ├── hosts ├── insert_ssh_key_in_iso.sh ├── playbook_coreos.yml └── user-data /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vagrant 3 | *.retry 4 | *.swp 5 | -------------------------------------------------------------------------------- /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 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 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 | {project} Copyright (C) {year} {fullname} 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 | Ansible CoreOS Container Linux Role 2 | =================================== 3 | 4 | This role bootstrap a complete CoreOS cluster with Cloudinit or/and Ignition. It also support Cloudinit config upgrade. 5 | 6 | [![asciicast](https://asciinema.org/a/amjt78r5c2gsz0c8gf5fk9p3z.png)](https://asciinema.org/a/amjt78r5c2gsz0c8gf5fk9p3z) 7 | 8 | Requirements 9 | ------------ 10 | 11 | This role require Python to work because it's not present in CoreOS by default. You can use deimosfr.coreos-ansible to install it. 12 | 13 | Role Variables 14 | -------------- 15 | 16 | ```yaml 17 | ## CoreOS 18 | 19 | # Choose CoreOS channel between stable, beta or alpha channels 20 | coreos_channel: "stable" 21 | # Generate a token: https://discovery.etcd.io/new?size=3 22 | coreos_token: "enter your token here" 23 | # Choose reboot strategy between: etcd-lock, reboot and off 24 | coreos_reboot_strategy: "off" 25 | 26 | # Only generate config files locally, do not deploy (useful when you can't connect or with some providers) 27 | coreos_generate_only: false 28 | 29 | # Download image locally to avoid downloading it for every nodes 30 | coreos_image_offline: false 31 | # Set CoreOS offline version (do not use current in offline mode) 32 | coreos_image_version: '1409.7.0' 33 | # Set image name to download 34 | coreos_image_name: 'coreos_production_ami_image.bin.bz2' 35 | # Define source image url to locally download image 36 | coreos_image_src_url: "https://{{coreos_channel}}.release.core-os.net/amd64-usr/{{coreos_image_version}}" 37 | # Use this url to install CoreOS from 38 | coreos_image_base_url: "https://{{coreos_channel}}.release.core-os.net/amd64-usr" 39 | 40 | # Set role path for local storage 41 | coreos_role_path: "{{playbook_dir}}/../../deimosfr.coreos-ansible" 42 | 43 | # Define your public interface and IP 44 | coreos_public_ip: "{{ansible_default_ipv4.address}}" 45 | coreos_public_if: "{{ansible_default_ipv4.interface}}" 46 | # Define your private interface and IP 47 | coreos_private_ip: "{{priv_ip}}" 48 | coreos_private_if: "{{priv_if}}" 49 | 50 | # Define dedicated subnet for containers communication 51 | coreos_flanneld_subnet: "10.1.0.0/16" 52 | 53 | # Add fleet metadata 54 | coreos_fleet_metadata: "cluster=dev" 55 | 56 | # If true, will bootstrap the server (data may be lost), 57 | # else config files will be generated 58 | coreos_launch_bootstrap: true 59 | coreos_cloudinit_check_syntax: true 60 | coreos_device_install: "/dev/sda" 61 | coreos_install_additional_options: "" 62 | coreos_eject_cd_before_reboot: true 63 | coreos_reboot_after_bootstrap: true 64 | 65 | # Dump generated Ingition and Cloudinit configs 66 | coreos_dump_ignition_cloudinit_config: true 67 | coreos_dump_ignition_cloudinit_dest: "{{coreos_role_path}}/files/generated_configs" 68 | 69 | # Select Timezone 70 | coreos_timezone: "UTC" 71 | 72 | # CoreOS toolbox image type 73 | coreos_toolbox_docker_image: "debian" 74 | coreos_toolbox_docker_tag: "stable" 75 | 76 | # Ignition 77 | coreos_bootstrap_ignition: false 78 | coreos_ignition: 79 | ignition: 80 | version: "2.0.0" 81 | storage: 82 | disks: 83 | - device: "/dev/sdb" 84 | wipeTable: true 85 | partitions: 86 | - label: "data.0" 87 | number: 1 88 | size: 0 89 | start: 0 90 | - device: "/dev/sdc" 91 | wipeTable: true 92 | partitions: 93 | - label: "data.1" 94 | number: 1 95 | size: 0 96 | start: 0 97 | 98 | # Cloudinit 99 | coreos_bootstrap_cloudinit: true 100 | coreos_cloudinit: 101 | hostname: "{{inventory_hostname}}" 102 | coreos: 103 | update: 104 | group: "{{coreos_channel}}" 105 | reboot-strategy: "{{coreos_reboot_strategy}}" 106 | flannel: 107 | interface: "{{coreos_public_ip}}" 108 | units: 109 | - name: serial-getty@ttyS1.service 110 | command: start 111 | enable: true 112 | - name: etcd-member.service 113 | command: start 114 | enable: true 115 | drop-ins: 116 | - name: 40-etcd-cluster.conf 117 | content: | 118 | [Service] 119 | Environment="ETCD_IMAGE_TAG=v3.2.4" 120 | Environment="ETCD_ADVERTISE_CLIENT_URLS=http://{{priv_ip}}:2379" 121 | Environment="ETCD_DISCOVERY=https://discovery.etcd.io/{{coreos_token}}" 122 | Environment="ETCD_INITIAL_ADVERTISE_PEER_URLS=http://{{priv_ip}}:2380" 123 | Environment="ETCD_LISTEN_CLIENT_URLS=http://127.0.0.1:2379,http://{{priv_ip}}:2379" 124 | Environment="ETCD_LISTEN_PEER_URLS=http://{{priv_ip}}:2380" 125 | - name: flanneld.service 126 | enable: true 127 | command: start 128 | drop-ins: 129 | - name: 50-network-config.conf 130 | content: | 131 | [Service] 132 | ExecStartPre=/usr/bin/etcdctl set /coreos.com/network/config '{ "Network": "{{coreos_flanneld_subnet}}" }' 133 | - name: prepare-data-drive.service 134 | command: start 135 | enable: true 136 | content: | 137 | [Unit] 138 | Description=Prepare data drive 139 | Ater=dev-sdb.device 140 | After=dev-sdc.device 141 | Requires=dev-sdb.device 142 | Requires=dev-sdc.device 143 | ConditionPathExists=!/dev/md0 144 | [Service] 145 | Type=oneshot 146 | RemainAfterExit=yes 147 | ExecStart=/usr/sbin/wipefs -f /dev/sdb 148 | ExecStart=/usr/sbin/parted -s -a opt /dev/sdb mklabel gpt -- mkpart primary ext4 2048s -1 149 | ExecStart=/usr/sbin/parted -s /dev/sdb align-check optimal 1 150 | ExecStart=/usr/sbin/parted -s /dev/sdb set 1 raid on 151 | ExecStart=/usr/sbin/wipefs -f /dev/sdc 152 | ExecStart=/usr/sbin/parted -s -a opt /dev/sdc mklabel gpt -- mkpart primary ext4 2048s -1 153 | ExecStart=/usr/sbin/parted -s /dev/sdc align-check optimal 1 154 | ExecStart=/usr/sbin/parted -s /dev/sdc set 1 raid on 155 | ExecStart=/usr/sbin/mdadm --create --assume-clean --metadata=1.2 --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1 156 | ExecStart=/usr/sbin/pvcreate -y /dev/md0 157 | ExecStart=/usr/sbin/vgcreate raid-vg /dev/md0 158 | ExecStart=/usr/sbin/lvcreate -l 100%FREE -n data raid-vg 159 | ExecStart=/usr/sbin/mkfs.ext4 -m 1 -F /dev/raid-vg/data 160 | - name: mnt-data.mount 161 | command: start 162 | enable: true 163 | content: | 164 | [Unit] 165 | After=prepare-data-drive.service 166 | Requires=prepare-data-drive.service 167 | [Mount] 168 | What=/dev/raid-vg/data 169 | Where=/mnt/data 170 | Type=ext4 171 | Options=rw,noatime,nodiratime,discard,data=ordered 172 | - name: "00-{{coreos_public_if}}.network" 173 | runtime: true 174 | content: | 175 | [Match] 176 | Name={{coreos_public_if}} 177 | [Network] 178 | DHCP=true 179 | - name: "00-{{coreos_private_if}}.network" 180 | runtime: true 181 | content: | 182 | [Match] 183 | Name={{coreos_private_if}} 184 | [Network] 185 | Address={{coreos_private_ip}}/24 186 | - name: iptables-restore.service 187 | command: start 188 | enable: true 189 | - name: settimezone.service 190 | command: start 191 | enable: true 192 | content: | 193 | [Unit] 194 | Description=Set the time zone 195 | [Service] 196 | ExecStart=/usr/bin/timedatectl set-timezone {{coreos_timezone}} 197 | RemainAfterExit=yes 198 | Type=oneshot 199 | - name: systemd-modules-load.service 200 | command: restart 201 | - name: systemd-sysctl.service 202 | command: restart 203 | - name: systemd-timesyncd.service 204 | command: start 205 | enable: true 206 | - name: mdmonitor.service 207 | command: stop 208 | enable: false 209 | - name: docker.service 210 | command: start 211 | drop-ins: 212 | - name: 40-flannel.conf 213 | content: | 214 | [Unit] 215 | Requires=flanneld.service 216 | After=flanneld.service 217 | [Service] 218 | EnvironmentFile=/etc/kubernetes/cni/docker_opts_cni.env 219 | - name: docker-tcp.socket 220 | command: start 221 | enable: true 222 | content: | 223 | [Unit] 224 | Description=Docker Socket for the API 225 | After=mnt-data.mount 226 | Requires=mnt-data.mount 227 | [Socket] 228 | ListenStream=2375 229 | Service=docker.service 230 | BindIPv6Only=both 231 | [Install] 232 | WantedBy=sockets.target 233 | write_files: 234 | - path: "/home/core/.toolboxrc" 235 | owner: core 236 | content: | 237 | TOOLBOX_DOCKER_IMAGE={{coreos_toolbox_docker_image}} 238 | TOOLBOX_DOCKER_TAG={{coreos_toolbox_docker_tag}} 239 | - path: /etc/kubernetes/cni/docker_opts_cni.env 240 | content: | 241 | DOCKER_OPT_BIP="" 242 | DOCKER_OPT_IPMASQ="" 243 | - path: /etc/modules-load.d/nf.conf 244 | content: nf_conntrack 245 | - path: /etc/sysctl.d/ipv4_forward.conf 246 | content: net.ipv4.ip_forward=1 247 | - path: /etc/sysctl.d/swapiness.conf 248 | content: vm.swappiness=1 249 | - path: /etc/sysctl.d/overcommit_memory.conf 250 | content: vm.overcommit_memory=1 251 | - path: /etc/sysctl.d/max_map_count.conf 252 | content: vm.max_map_count=65535 253 | - path: /var/lib/iptables/rules-save 254 | permissions: 0644 255 | owner: root:root 256 | content: | 257 | *filter 258 | :INPUT ACCEPT [0:0] 259 | :FORWARD ACCEPT [0:0] 260 | :OUTPUT ACCEPT [0:0] 261 | -A INPUT -i lo -j ACCEPT 262 | -A INPUT -i {{coreos_private_if}} -j ACCEPT 263 | -A INPUT -i tap0 -p all -j ACCEPT 264 | -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 265 | -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT 266 | -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT 267 | -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT 268 | -A INPUT -p icmp -m icmp --icmp-type 0 -j ACCEPT 269 | -A INPUT -p icmp -m icmp --icmp-type 3 -j ACCEPT 270 | -A INPUT -p icmp -m icmp --icmp-type 11 -j ACCEPT 271 | -A INPUT -j DROP 272 | COMMIT 273 | users: 274 | - name: 'core' 275 | ssh-authorized-keys: 276 | - "your rsa key" 277 | ``` 278 | 279 | Example Playbook 280 | ---------------- 281 | 282 | First you need to fil an inventory. To make it simple, use a hosts file like this one: 283 | ```ini 284 | [local] 285 | localhost 286 | 287 | [coreos-masters] 288 | core01.myfqdn.com pub_ip=222.2.1.199 priv_ip=172.17.8.101 289 | core02.myfqdn.com pub_ip=222.2.1.198 priv_ip=172.17.8.102 290 | core03.myfqdn.com pub_ip=222.2.1.197 priv_ip=172.17.8.103 291 | 292 | [coreos-workers] 293 | core04.myfqdn.com pub_ip=222.2.1.196 priv_ip=172.17.8.104 294 | core05.myfqdn.com pub_ip=222.2.1.195 priv_ip=172.17.8.105 295 | core06.myfqdn.com pub_ip=222.2.1.194 priv_ip=172.17.8.106 296 | 297 | [coreos-nodes:children] 298 | coreos-masters 299 | coreos-workers 300 | 301 | [coreos-nodes:vars] 302 | ansible_ssh_user=core 303 | ansible_python_interpreter="/opt/python/bin/python" 304 | priv_if=enp0s8 305 | ``` 306 | 307 | Then use a playbook like this one (do not forget to edit vars with yours from the default folder): 308 | 309 | ```yaml 310 | --- 311 | 312 | - name: coreos-ansible pypy 313 | hosts: localhost 314 | gather_facts: False 315 | tasks: 316 | - include: ../../deimosfr.coreos-ansible/tasks/ansible_prerequisites.yml 317 | vars: 318 | ansible_python_interpreter: "/usr/bin/python" 319 | coreos_role_path: "{{playbook_dir}}/../../deimosfr.coreos-ansible" 320 | 321 | - name: coreos image offline mode 322 | hosts: localhost 323 | gather_facts: False 324 | tasks: 325 | - include: ../tasks/coreos_offline_image.yml 326 | when: coreos_image_offline 327 | vars: 328 | ansible_python_interpreter: "/usr/bin/python" 329 | coreos_role_path: "{{playbook_dir}}/.." 330 | coreos_image_offline: true 331 | coreos_image_version: '1185.5.0' 332 | coreos_image_name: 'coreos_production_image.bin.bz2' 333 | coreos_image_src_url: "https://stable.release.core-os.net/amd64-usr/{{coreos_image_version}}" 334 | 335 | - name: coreos-ansible 336 | hosts: coreos-nodes 337 | user: core 338 | become: yes 339 | gather_facts: False 340 | roles: 341 | - deimosfr.coreos-ansible 342 | 343 | # First deploy masters to ensure cluster will be ready before workers 344 | - name: coreos-bootstrap 345 | hosts: coreos-masters 346 | user: core 347 | become: yes 348 | roles: 349 | - deimosfr.coreos-container-linux 350 | vars: 351 | coreos_image_base_url: "http://222.2.1.152:8000/coreos_images" 352 | 353 | - name: coreos-bootstrap 354 | hosts: coreos-workers 355 | user: core 356 | become: yes 357 | roles: 358 | - deimosfr.coreos-container-linux 359 | vars: 360 | coreos_image_base_url: "http://222.2.1.152:8000/coreos_images" 361 | ``` 362 | 363 | Known issues 364 | ------------ 365 | 366 | If you get the following message: "A start job is running for ignition (disks)", it's because the current server where you try tu runs Ignition on, is already containing an active RAID. You need to delete it first before starting Ignition. Example: 367 | ``` 368 | mdadm --stop /dev/md/ 369 | mdadm --zero-superblock /dev/ 370 | mdadm --zero-superblock /dev/ 371 | ``` 372 | 373 | License 374 | ------- 375 | 376 | GPLv3 377 | 378 | Author Information 379 | ------------------ 380 | 381 | Pierre Mavro / deimosfr 382 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | ## CoreOS 2 | 3 | # Choose CoreOS channel between stable, beta or alpha channels 4 | coreos_channel: "stable" 5 | # Generate a token: https://discovery.etcd.io/new?size=3 6 | coreos_token: "enter your token here" 7 | # Choose reboot strategy between: etcd-lock, reboot and off 8 | coreos_reboot_strategy: "off" 9 | 10 | # Only generate config files locally, do not deploy (useful when you can't connect or with some providers) 11 | coreos_generate_only: false 12 | 13 | # Download image locally to avoid downloading it for every nodes 14 | coreos_image_offline: false 15 | # Set CoreOS offline version (do not use current in offline mode) 16 | coreos_image_version: '1576.5.0' 17 | # Set image name to download 18 | coreos_image_name: 'coreos_production_ami_image.bin.bz2' 19 | # Define source image url to locally download image 20 | coreos_image_src_url: "https://{{coreos_channel}}.release.core-os.net/amd64-usr/{{coreos_image_version}}" 21 | # Use this url to install CoreOS from 22 | coreos_image_base_url: "https://{{coreos_channel}}.release.core-os.net/amd64-usr" 23 | 24 | # Set role path for local storage 25 | coreos_role_path: "{{playbook_dir}}/../../deimosfr.coreos-ansible" 26 | 27 | # Define your public interface and IP 28 | coreos_public_ip: "{{ansible_default_ipv4.address}}" 29 | coreos_public_if: "{{ansible_default_ipv4.interface}}" 30 | # Define your private interface and IP 31 | coreos_private_ip: "{{priv_ip}}" 32 | coreos_private_if: "{{priv_if}}" 33 | 34 | # Define dedicated subnet for containers communication 35 | coreos_flanneld_subnet: "10.1.0.0/16" 36 | 37 | # If true, will bootstrap the server (data may be lost), 38 | # else config files will be generated 39 | coreos_launch_bootstrap: true 40 | coreos_cloudinit_check_syntax: true 41 | coreos_device_install: "/dev/sda" 42 | coreos_install_additional_options: "" 43 | coreos_eject_cd_before_reboot: true 44 | coreos_reboot_after_bootstrap: true 45 | 46 | # Dump generated Ingition and Cloudinit configs 47 | coreos_dump_ignition_cloudinit_config: true 48 | coreos_dump_ignition_cloudinit_dest: "{{coreos_role_path}}/files/generated_configs" 49 | 50 | # Select Timezone 51 | coreos_timezone: "UTC" 52 | 53 | # CoreOS toolbox image type 54 | coreos_toolbox_docker_image: "debian" 55 | coreos_toolbox_docker_tag: "stable" 56 | 57 | coreos_openssh_port: 29410 58 | 59 | # Ignition 60 | coreos_bootstrap_ignition: false 61 | coreos_ignition: 62 | ignition: 63 | version: "2.0.0" 64 | storage: 65 | disks: 66 | - device: "/dev/sdb" 67 | wipeTable: true 68 | partitions: 69 | - label: "data.0" 70 | number: 1 71 | size: 0 72 | start: 0 73 | - device: "/dev/sdc" 74 | wipeTable: true 75 | partitions: 76 | - label: "data.1" 77 | number: 1 78 | size: 0 79 | start: 0 80 | 81 | # Cloudinit 82 | coreos_bootstrap_cloudinit: true 83 | coreos_cloudinit: 84 | hostname: "{{inventory_hostname}}" 85 | coreos: 86 | update: 87 | group: "{{coreos_channel}}" 88 | reboot-strategy: "{{coreos_reboot_strategy}}" 89 | flannel: 90 | interface: "{{coreos_public_ip}}" 91 | units: 92 | - name: serial-getty@ttyS1.service 93 | command: start 94 | enable: true 95 | - name: update-engine.service 96 | command: start 97 | enable: true 98 | - name: etcd-member.service 99 | command: start 100 | enable: true 101 | drop-ins: 102 | - name: 40-etcd-cluster.conf 103 | content: | 104 | [Service] 105 | Environment="ETCD_IMAGE_TAG=v3.2.13" 106 | Environment="ETCD_ADVERTISE_CLIENT_URLS=http://{{priv_ip}}:2379" 107 | Environment="ETCD_DISCOVERY=https://discovery.etcd.io/{{coreos_token}}" 108 | Environment="ETCD_INITIAL_ADVERTISE_PEER_URLS=http://{{priv_ip}}:2380" 109 | Environment="ETCD_LISTEN_CLIENT_URLS=http://127.0.0.1:2379,http://{{priv_ip}}:2379" 110 | Environment="ETCD_LISTEN_PEER_URLS=http://{{priv_ip}}:2380" 111 | - name: flanneld.service 112 | enable: true 113 | command: start 114 | drop-ins: 115 | - name: 50-network-config.conf 116 | content: | 117 | [Service] 118 | ExecStartPre=/usr/bin/etcdctl set /coreos.com/network/config '{ "Network": "{{coreos_flanneld_subnet}}" }' 119 | - name: prepare-data-drive.service 120 | command: start 121 | enable: true 122 | content: | 123 | [Unit] 124 | Description=Prepare data drive 125 | Ater=dev-sdb.device 126 | After=dev-sdc.device 127 | Requires=dev-sdb.device 128 | Requires=dev-sdc.device 129 | ConditionPathExists=!/dev/md0 130 | [Service] 131 | Type=oneshot 132 | RemainAfterExit=yes 133 | ExecStart=/usr/sbin/wipefs -f /dev/sdb 134 | ExecStart=/usr/sbin/parted -s -a opt /dev/sdb mklabel gpt -- mkpart primary ext4 2048s -1 135 | ExecStart=/usr/sbin/parted -s /dev/sdb align-check optimal 1 136 | ExecStart=/usr/sbin/parted -s /dev/sdb set 1 raid on 137 | ExecStart=/usr/sbin/wipefs -f /dev/sdc 138 | ExecStart=/usr/sbin/parted -s -a opt /dev/sdc mklabel gpt -- mkpart primary ext4 2048s -1 139 | ExecStart=/usr/sbin/parted -s /dev/sdc align-check optimal 1 140 | ExecStart=/usr/sbin/parted -s /dev/sdc set 1 raid on 141 | ExecStart=/usr/sbin/mdadm --create --assume-clean --metadata=1.2 --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1 142 | ExecStart=/usr/sbin/pvcreate -y /dev/md0 143 | ExecStart=/usr/sbin/vgcreate raid-vg /dev/md0 144 | ExecStart=/usr/sbin/lvcreate -l 100%FREE -n data raid-vg 145 | ExecStart=/usr/sbin/mkfs.ext4 -m 1 -F /dev/raid-vg/data 146 | - name: mnt-data.mount 147 | command: start 148 | enable: true 149 | content: | 150 | [Unit] 151 | After=prepare-data-drive.service 152 | Requires=prepare-data-drive.service 153 | [Mount] 154 | What=/dev/raid-vg/data 155 | Where=/mnt/data 156 | Type=ext4 157 | Options=rw,noatime,nodiratime,discard,data=ordered 158 | - name: "00-{{coreos_public_if}}.network" 159 | runtime: true 160 | content: | 161 | [Match] 162 | Name={{coreos_public_if}} 163 | [Network] 164 | DHCP=true 165 | - name: "00-{{coreos_private_if}}.network" 166 | runtime: true 167 | content: | 168 | [Match] 169 | Name={{coreos_private_if}} 170 | [Network] 171 | Address={{coreos_private_ip}}/24 172 | - name: iptables-restore.service 173 | command: start 174 | enable: true 175 | - name: settimezone.service 176 | command: start 177 | enable: true 178 | content: | 179 | [Unit] 180 | Description=Set the time zone 181 | [Service] 182 | ExecStart=/usr/bin/timedatectl set-timezone {{coreos_timezone}} 183 | RemainAfterExit=yes 184 | Type=oneshot 185 | - name: systemd-modules-load.service 186 | command: restart 187 | - name: systemd-sysctl.service 188 | command: restart 189 | - name: systemd-timesyncd.service 190 | command: start 191 | enable: true 192 | - name: mdmonitor.service 193 | command: stop 194 | enable: false 195 | - name: docker.service 196 | command: start 197 | drop-ins: 198 | - name: 40-flannel.conf 199 | content: | 200 | [Unit] 201 | Requires=flanneld.service 202 | After=flanneld.service 203 | [Service] 204 | EnvironmentFile=/etc/kubernetes/cni/docker_opts_cni.env 205 | - name: docker-tcp.socket 206 | command: start 207 | enable: true 208 | content: | 209 | [Unit] 210 | Description=Docker Socket for the API 211 | After=mnt-data.mount 212 | Requires=mnt-data.mount 213 | [Socket] 214 | ListenStream=2375 215 | Service=docker.service 216 | BindIPv6Only=both 217 | [Install] 218 | WantedBy=sockets.target 219 | write_files: 220 | - path: /etc/ssh/sshd_config 221 | owner: root:root 222 | permissions: 6400 223 | content: | 224 | # Use most defaults for sshd configuration. 225 | Port {{coreos_openssh_port}} 226 | UsePrivilegeSeparation sandbox 227 | Subsystem sftp internal-sftp 228 | ClientAliveInterval 180 229 | UseDNS no 230 | UsePAM yes 231 | PermitRootLogin no 232 | AllowUsers core 233 | AuthenticationMethods publickey 234 | PrintLastLog no # handled by PAM 235 | PrintMotd no # handled by PAM 236 | - path: "/home/core/.toolboxrc" 237 | owner: core 238 | content: | 239 | TOOLBOX_DOCKER_IMAGE={{coreos_toolbox_docker_image}} 240 | TOOLBOX_DOCKER_TAG={{coreos_toolbox_docker_tag}} 241 | - path: /etc/kubernetes/cni/docker_opts_cni.env 242 | content: | 243 | DOCKER_OPT_BIP="" 244 | DOCKER_OPT_IPMASQ="" 245 | - path: /usr/share/oem/grub.cfg 246 | content: | 247 | set linux_append="ipv6.disable=1" 248 | - path: /etc/modules-load.d/nf.conf 249 | content: nf_conntrack 250 | - path: /etc/sysctl.d/ipv4_forward.conf 251 | content: net.ipv4.ip_forward=1 252 | - path: /etc/sysctl.d/swapiness.conf 253 | content: vm.swappiness=1 254 | - path: /etc/sysctl.d/overcommit_memory.conf 255 | content: vm.overcommit_memory=1 256 | - path: /etc/sysctl.d/max_map_count.conf 257 | content: vm.max_map_count=65535 258 | - path: /var/lib/iptables/rules-save 259 | permissions: 0644 260 | owner: root:root 261 | content: | 262 | *filter 263 | :INPUT ACCEPT [0:0] 264 | :FORWARD ACCEPT [0:0] 265 | :OUTPUT ACCEPT [0:0] 266 | -A INPUT -i lo -j ACCEPT 267 | -A INPUT -i {{coreos_private_if}} -j ACCEPT 268 | -A INPUT -i tap0 -p all -j ACCEPT 269 | -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 270 | -A INPUT -p tcp -m tcp --dport {{coreos_openssh_port}} -j ACCEPT -m comment --comment "OpenSSH" 271 | -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT 272 | -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT 273 | -A INPUT -p icmp -m icmp --icmp-type 0 -j ACCEPT 274 | -A INPUT -p icmp -m icmp --icmp-type 3 -j ACCEPT 275 | -A INPUT -p icmp -m icmp --icmp-type 11 -j ACCEPT 276 | -A INPUT -j DROP 277 | COMMIT 278 | users: 279 | - name: 'core' 280 | ssh-authorized-keys: 281 | - "your rsa key" 282 | -------------------------------------------------------------------------------- /files/coreos_images/.add_to_git: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deimosfr/ansible-coreos-container-linux/5e8f0d1f0b641f2fbbb10bdefc7bdddea9bbc20f/files/coreos_images/.add_to_git -------------------------------------------------------------------------------- /files/coreos_images/.coreos_images_offline: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deimosfr/ansible-coreos-container-linux/5e8f0d1f0b641f2fbbb10bdefc7bdddea9bbc20f/files/coreos_images/.coreos_images_offline -------------------------------------------------------------------------------- /files/generated_configs/.add_to_git: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deimosfr/ansible-coreos-container-linux/5e8f0d1f0b641f2fbbb10bdefc7bdddea9bbc20f/files/generated_configs/.add_to_git -------------------------------------------------------------------------------- /files/generated_configs/.generated_files_here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deimosfr/ansible-coreos-container-linux/5e8f0d1f0b641f2fbbb10bdefc7bdddea9bbc20f/files/generated_configs/.generated_files_here -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: reboot server 4 | shell: "sleep 2 && shutdown -r now 'Ansible rebooted server'" 5 | async: 1 6 | poll: 0 7 | ignore_errors: true 8 | when: coreos_reboot_after_bootstrap -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: "Pierre Mavro" 4 | company: 5 | license: GPL 6 | min_ansible_version: 2.6 7 | platforms: 8 | - name: CoreOS 9 | versions: 10 | - all 11 | galaxy_tags: 12 | - system 13 | - system:coreos 14 | dependencies: [] 15 | 16 | -------------------------------------------------------------------------------- /tasks/bootstrap.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - include: generate_config.yml 4 | when: coreos_generate_only 5 | 6 | - include: bootstrap_ignition.yml 7 | when: coreos_bootstrap_ignition and coreos_generate_only == False 8 | 9 | - include: bootstrap_cloudinit.yml 10 | when: coreos_bootstrap_cloudinit and coreos_generate_only == False 11 | 12 | - include: bootstrap_launch.yml 13 | when: 14 | - coreos_launch_bootstrap 15 | - coreos_generate_only == False 16 | - coreos_only_save_config == False -------------------------------------------------------------------------------- /tasks/bootstrap_cloudinit.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: create cloudinit configuration file 4 | template: 5 | src: "coreos_cloudinit.yml.j2" 6 | dest: "/tmp/coreos_cloudinit.yml" 7 | register: config_updated 8 | 9 | - name: check cloudinit syntax 10 | command: "coreos-cloudinit -validate --from-file /tmp/coreos_cloudinit.yml" 11 | when: coreos_cloudinit_check_syntax 12 | 13 | - name: backup cloudinit file from core hosts 14 | fetch: 15 | src: "/tmp/coreos_cloudinit.yml" 16 | dest: "{{coreos_dump_ignition_cloudinit_dest}}/{{inventory_hostname}}_cloudinit.yml" 17 | flat: yes 18 | when: coreos_dump_ignition_cloudinit_config 19 | 20 | - name: create coreos-install folder if it does not exist 21 | file: 22 | path: /var/lib/coreos-install 23 | mode: 0700 24 | owner: root 25 | group: root 26 | state: directory 27 | when: 28 | - coreos_generate_only == False 29 | - config_updated.changed == True 30 | 31 | - name: save cloud-init config 32 | copy: 33 | remote_src: yes 34 | src: /tmp/coreos_cloudinit.yml 35 | dest: /var/lib/coreos-install/user_data 36 | mode: 0600 37 | owner: root 38 | group: root 39 | when: 40 | - coreos_generate_only == False 41 | - config_updated.changed == True -------------------------------------------------------------------------------- /tasks/bootstrap_ignition.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: create ignition configuration file 4 | template: 5 | src: "coreos_ignition.json.j2" 6 | dest: "/tmp/coreos_ignition.json" 7 | 8 | - name: backup ignition file from core hosts 9 | fetch: 10 | src: "/tmp/coreos_ignition.json" 11 | dest: "{{coreos_dump_ignition_cloudinit_dest}}/{{inventory_hostname}}_ignition.json" 12 | flat: yes 13 | when: coreos_dump_ignition_cloudinit_config -------------------------------------------------------------------------------- /tasks/bootstrap_launch.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: check if coreos is already installed 4 | command: "grep -c '/usr/share/oem' /proc/mounts" 5 | ignore_errors: yes 6 | changed_when: false 7 | register: mounted_oem 8 | 9 | - name: launch coreos-install with coreos-install 10 | command: > 11 | coreos-install 12 | -d {{coreos_device_install}} 13 | -C {{coreos_channel}} 14 | {% if coreos_bootstrap_cloudinit %}-c /tmp/coreos_cloudinit.yml{% endif %} 15 | {% if coreos_bootstrap_ignition %}-i /tmp/coreos_ignition.json{% endif %} 16 | {% if coreos_image_base_url %}-b {{coreos_image_base_url}}{% endif %} 17 | {% if coreos_image_version %}-V {{coreos_image_version}}{% endif %} 18 | {{coreos_install_additional_options}} 19 | notify: reboot server 20 | when: mounted_oem.rc == 1 21 | 22 | - name: apply cloud-init configuration 23 | command: > 24 | coreos-cloudinit -from-file /tmp/coreos_cloudinit.yml 25 | when: 26 | - mounted_oem.rc == 0 27 | - coreos_bootstrap_cloudinit 28 | - config_updated.changed == True 29 | 30 | - name: eject cdrom 31 | command: eject 32 | when: coreos_eject_cd_before_reboot 33 | ignore_errors: yes 34 | 35 | - meta: flush_handlers -------------------------------------------------------------------------------- /tasks/coreos_offline_image.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: ensure local folders exists 4 | file: 5 | path: "{{coreos_role_path}}/files/coreos_images/{{coreos_image_version}}" 6 | mode: 0755 7 | recurse: yes 8 | state: 'directory' 9 | become: false 10 | delegate_to: 127.0.0.1 11 | 12 | - name: check if coreos image is locally downloaded 13 | raw: "stat {{coreos_role_path}}/files/coreos_images/{{coreos_image_version}}/{{coreos_image_name}}" 14 | register: coreos_image_downloaded 15 | become: false 16 | ignore_errors: True 17 | delegate_to: 127.0.0.1 18 | changed_when: false 19 | 20 | - name: download coreos image locally 21 | get_url: 22 | url: "{{coreos_image_src_url}}/{{item}}" 23 | dest: "{{coreos_role_path}}/files/coreos_images/{{coreos_image_version}}/{{item}}" 24 | with_items: 25 | - "{{coreos_image_name}}" 26 | - "{{coreos_image_name}}.DIGESTS" 27 | - "{{coreos_image_name}}.DIGESTS.asc" 28 | - "{{coreos_image_name}}.sig" 29 | - "version.txt" 30 | become: false 31 | delegate_to: 127.0.0.1 32 | when: coreos_image_downloaded is failed 33 | -------------------------------------------------------------------------------- /tasks/generate_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: create ignition configuration file locally 4 | template: 5 | src: "coreos_ignition.yml.j2" 6 | dest: "{{coreos_dump_ignition_cloudinit_dest}}/{{inventory_hostname}}_cloudinit.yml" 7 | delegate_to: localhost 8 | when: coreos_bootstrap_ignition 9 | 10 | - name: create cloudinit configuration file locally 11 | template: 12 | src: "coreos_cloudinit.yml.j2" 13 | dest: "{{coreos_dump_ignition_cloudinit_dest}}/{{inventory_hostname}}_cloudinit.yml" 14 | delegate_to: localhost 15 | when: coreos_bootstrap_cloudinit 16 | 17 | - meta: end_play -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - include: bootstrap.yml 4 | tags: [coreos] 5 | -------------------------------------------------------------------------------- /templates/coreos_cloudinit.yml.j2: -------------------------------------------------------------------------------- 1 | #cloud-config 2 | 3 | --- 4 | {{coreos_cloudinit | to_nice_yaml }} 5 | -------------------------------------------------------------------------------- /templates/coreos_ignition.json.j2: -------------------------------------------------------------------------------- 1 | {{ coreos_ignition | to_nice_json(indent=2) }} 2 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | Ansible CoreOS role 2 | =================== 3 | 4 | Boot CoreOS CDs 5 | --------------- 6 | Note: ignore SSH failures, this is due to missing VirtualBox guest additions which are not present by default on CoreOS: 7 | ``` 8 | for i in {1..$(cat Vagrantfile| awk '/^\$num_instances/{print $3}')} ; do vagrant up core0${i} ; done 9 | ``` 10 | 11 | Update password and upload you SSH key 12 | --------------- 13 | 14 | * Method 1 (recommended for test purpose): 15 | 16 | Set $insert_ssh_key_in_iso variable in Vagrantfile to true and it will add your SSH key inside the ISO. 17 | 18 | * Method 2: 19 | 20 | Connect to any guests and change password (use "core"): 21 | ``` 22 | $ sudo passwd core 23 | Enter new UNIX password: core 24 | Retype new UNIX password: core 25 | passwd: password updated successfully 26 | ``` 27 | 28 | Copy your ssh key to CoreOS Vms: 29 | ``` 30 | ./copy_ssh_keys.sh 31 | ``` 32 | 33 | Generate a new token 34 | -------------------- 35 | Generate a new token: 36 | ``` 37 | curl "https://discovery.etcd.io/new?size=3" 38 | ``` 39 | And add it to Ansible "coreos_token" variable. 40 | 41 | Launch Ansible 42 | -------------- 43 | 44 | If you're using offline coreos image, you can locally run an http server: 45 | ``` 46 | cd ../files 47 | python -m SimpleHTTPServer 8000 & 48 | ``` 49 | 50 | You just now need to run the playbook: 51 | 52 | ``` 53 | cd ../../.. 54 | ansible-playbook -i roles/deimosfr.coreos-container-linux/tests/hosts roles/deimosfr.coreos-container-linux/tests/playbook_coreos.yml -D 55 | ``` 56 | 57 | Tests 58 | ----- 59 | There is an example of a test playbook to validate everything is fine: 60 | ``` 61 | ansible-playbook -i roles/deimosfr.coreos-container-linux/tests/hosts roles/deimosfr.coreos-container-linux/tests/ansible_coreos_tests.yml -D 62 | ``` 63 | -------------------------------------------------------------------------------- /tests/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # # vi: set ft=ruby : 3 | 4 | require 'fileutils' 5 | require 'net/http' 6 | require 'uri' 7 | 8 | Vagrant.require_version ">= 1.6.0" 9 | 10 | $num_instances = 6 11 | CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data") 12 | CONFIG = File.join(File.dirname(__FILE__), "config.rb") 13 | 14 | # Defaults for config options defined in CONFIG 15 | $coreos_iso_url = "https://stable.release.core-os.net/amd64-usr/current/coreos_production_iso_image.iso" 16 | $coreos_iso_image = "coreos_production_iso_image.iso" 17 | $insert_ssh_key_in_iso = true 18 | $instance_name_prefix = "core" 19 | $update_channel = "stable" 20 | $image_version = "current" 21 | $enable_serial_logging = false 22 | $share_home = false 23 | $vm_gui = false 24 | $vm_memory = 1100 25 | $vm_cpus = 1 26 | $number_of_additional_disk = 2 27 | $vb_cpuexecutioncap = 100 28 | $shared_folders = {} 29 | $forwarded_ports = {} 30 | $bridge_if = "wlp4s0" 31 | $mac_address = [ 32 | '080027F47653', 33 | '080027C80CEA', 34 | '080027887DE5', 35 | '080027887DE6', 36 | '080027887DE7', 37 | '080027887DE8', 38 | '080027887DE9', 39 | ] 40 | 41 | # Attempt to apply the deprecated environment variable NUM_INSTANCES to 42 | # $num_instances while allowing config.rb to override it 43 | if ENV["NUM_INSTANCES"].to_i > 0 && ENV["NUM_INSTANCES"] 44 | $num_instances = ENV["NUM_INSTANCES"].to_i 45 | end 46 | 47 | if File.exist?(CONFIG) 48 | require CONFIG 49 | end 50 | 51 | # Download coreos iso 52 | unless File.file?($coreos_iso_image) 53 | puts("Downloading CoreOS iso...") 54 | File.write($coreos_iso_image, Net::HTTP.get(URI.parse($coreos_iso_url))) 55 | if $insert_ssh_key_in_iso 56 | puts("Inserting SSH key in ISO file...") 57 | %x('./insert_ssh_key_in_iso.sh') 58 | end 59 | end 60 | 61 | # Use old vb_xxx config variables when set 62 | def vm_gui 63 | $vb_gui.nil? ? $vm_gui : $vb_gui 64 | end 65 | 66 | def vm_memory 67 | $vb_memory.nil? ? $vm_memory : $vb_memory 68 | end 69 | 70 | def vm_cpus 71 | $vb_cpus.nil? ? $vm_cpus : $vb_cpus 72 | end 73 | 74 | Vagrant.configure("2") do |config| 75 | # always use Vagrants insecure key 76 | config.ssh.insert_key = false 77 | # forward ssh agent to easily ssh into the different machines 78 | config.ssh.forward_agent = true 79 | 80 | #config.vm.box = "coreos-%s" % $update_channel 81 | config.vm.box = "c33s/empty" 82 | #config.vm.box = "olbat/tiny-core-micro" 83 | #if $image_version != "current" 84 | # config.vm.box_version = $image_version 85 | #end 86 | #config.vm.box_url = "https://storage.googleapis.com/%s.release.core-os.net/amd64-usr/%s/coreos_production_vagrant.json" % [$update_channel, $image_version] 87 | 88 | config.vm.provider :virtualbox do |v| 89 | # On VirtualBox, we don't have guest additions or a functional vboxsf 90 | # in CoreOS, so tell Vagrant that so it can be smarter. 91 | v.check_guest_additions = false 92 | v.functional_vboxsf = false 93 | end 94 | 95 | # plugin conflict 96 | if Vagrant.has_plugin?("vagrant-vbguest") then 97 | config.vbguest.auto_update = false 98 | end 99 | 100 | (1..$num_instances).each do |i| 101 | config.vm.define vm_name = "%s%02d" % [$instance_name_prefix, i] do |config| 102 | config.vm.hostname = vm_name 103 | 104 | # SSH timeout 105 | config.vm.boot_timeout = 1 106 | #config.ssh.max_tries = 1 107 | #config.ssh.timeout = 1 108 | 109 | if $enable_serial_logging 110 | logdir = File.join(File.dirname(__FILE__), "log") 111 | FileUtils.mkdir_p(logdir) 112 | 113 | serialFile = File.join(logdir, "%s-serial.txt" % vm_name) 114 | FileUtils.touch(serialFile) 115 | 116 | config.vm.provider :virtualbox do |vb, override| 117 | vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"] 118 | vb.customize ["modifyvm", :id, "--uartmode1", serialFile] 119 | end 120 | end 121 | 122 | # DVD 123 | config.vm.provider :virtualbox do |vb, override| 124 | vb.customize ["storageattach", :id, "--storagectl", "IDE", "--port", "1", "--device", "0", "--type", "dvddrive", "--medium", "coreos_production_iso_image.iso"] 125 | end 126 | 127 | # Additionnal disks 128 | if $number_of_additional_disk != 0 129 | config.vm.provider :virtualbox do |vb| 130 | controller = 'SATA' 131 | #vb.customize ["storagectl", :id, "--name", "#{controller}", "--add", "sata"] 132 | (1..$number_of_additional_disk).each do |cn| 133 | file_to_disk = vm_name.to_s + '_' + 'disk' + cn.to_s + '.vdi' 134 | vb.customize ['createhd', '--filename', file_to_disk, '--size', 1 * 1024] 135 | vb.customize ['storageattach', :id, '--storagectl', "#{controller}", '--port', cn, '--type', 'hdd', '--medium', file_to_disk] 136 | end 137 | end 138 | end 139 | 140 | #if $expose_docker_tcp 141 | # config.vm.network "forwarded_port", guest: 2375, host: ($expose_docker_tcp + i - 1), host_ip: "127.0.0.1", auto_correct: true 142 | #end 143 | 144 | #$forwarded_ports.each do |guest, host| 145 | # config.vm.network "forwarded_port", guest: guest, host: host, auto_correct: true 146 | #end 147 | 148 | ip = "172.17.8.#{i+100}" 149 | config.vm.network :private_network, ip: ip 150 | 151 | config.vm.network :public_network, :bridge => "#{$bridge_if}", :mac => "#{$mac_address[i-1]}" 152 | 153 | config.vm.provider :virtualbox do |vb| 154 | vb.gui = vm_gui 155 | vb.memory = vm_memory 156 | vb.cpus = vm_cpus 157 | vb.customize ["modifyvm", :id, "--cpuexecutioncap", "#{$vb_cpuexecutioncap}"] 158 | # Boot order 159 | vb.customize ["modifyvm", :id, "--boot1", "dvd", "--boot2", "disk", "--boot3", "none", "--boot4", "none" ] 160 | # Network promiscous 161 | vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"] 162 | vb.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"] 163 | end 164 | 165 | # Uncomment below to enable NFS for sharing the host machine into the coreos-vagrant VM. 166 | #config.vm.synced_folder ".", "/home/core/share", id: "core", :nfs => true, :mount_options => ['nolock,vers=3,udp'] 167 | #$shared_folders.each_with_index do |(host_folder, guest_folder), index| 168 | # config.vm.synced_folder host_folder.to_s, guest_folder.to_s, id: "core-share%02d" % index, nfs: true, mount_options: ['nolock,vers=3,udp'] 169 | #end 170 | 171 | #if $share_home 172 | # config.vm.synced_folder ENV['HOME'], ENV['HOME'], id: "home", :nfs => true, :mount_options => ['nolock,vers=3,udp'] 173 | #end 174 | 175 | #if File.exist?(CLOUD_CONFIG_PATH) 176 | # config.vm.provision :file, :source => "#{CLOUD_CONFIG_PATH}", :destination => "/tmp/vagrantfile-user-data" 177 | # config.vm.provision :shell, :inline => "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", :privileged => true 178 | #end 179 | 180 | end 181 | end 182 | end 183 | -------------------------------------------------------------------------------- /tests/ansible_coreos_tests.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: coreos-ansible 4 | hosts: localhost 5 | gather_facts: False 6 | tasks: 7 | - include: ../../deimosfr.coreos-ansible/tasks/ansible_prerequisites.yml 8 | vars: 9 | ansible_python_interpreter: "/usr/bin/python" 10 | coreos_role_path: "{{playbook_dir}}/.." 11 | coreos_ansible_role_path: "{{playbook_dir}}/../../deimosfr.coreos-ansible" 12 | 13 | - name: coreos-ansible 14 | hosts: coreos-nodes 15 | user: core 16 | become: yes 17 | gather_facts: False 18 | roles: 19 | - deimosfr.coreos-ansible 20 | vars: 21 | coreos_ansible_role_path: "{{playbook_dir}}/../../deimosfr.coreos-ansible" 22 | 23 | - name: coreos-bootstrap 24 | hosts: coreos-nodes 25 | user: core 26 | become: yes 27 | tasks: 28 | - name: get raid device info 29 | stat: 30 | path: '/dev/md0' 31 | register: raid_device 32 | changed_when: false 33 | 34 | - name: get raid status 35 | command: 'mdadm --detail /dev/md0' 36 | register: raid_status 37 | changed_when: false 38 | 39 | - name: get etcd cluster info 40 | command: 'etcdctl cluster-health' 41 | register: etcd_status 42 | changed_when: false 43 | 44 | - name: get fleet cluster info 45 | command: 'fleetctl list-machines' 46 | register: fleet_status 47 | changed_when: false 48 | 49 | - name: ensure raid device is block device 50 | assert: 51 | that: 52 | - raid_device.stat.isblk 53 | - "'State : clean' in raid_status.stdout" 54 | 55 | - name: ensure services are started 56 | service: 57 | name: "{{item}}" 58 | state: started 59 | with_items: 60 | - systemd-modules-load 61 | - systemd-sysctl 62 | - systemd-timesyncd 63 | - etcd2 64 | - fleet 65 | - flanneld 66 | - docker 67 | 68 | - name: ensure cluster services are ok 69 | assert: 70 | that: 71 | - "'cluster is healthy' in etcd_status.stdout" 72 | - "fleet_status.rc == 0" 73 | - "ansible_flannel0.active" 74 | 75 | vars: 76 | ansible_ssh_user: core 77 | ansible_python_interpreter: "/opt/python/bin/python" 78 | -------------------------------------------------------------------------------- /tests/config.rb: -------------------------------------------------------------------------------- 1 | # Used to fetch a new discovery token for a cluster of size $num_instances 2 | $new_discovery_url="https://discovery.etcd.io/new?size=#{$num_instances}" 3 | 4 | # Automatically replace the discovery token on 'vagrant up' 5 | 6 | if File.exists?('user-data') && ARGV[0].eql?('up') 7 | require 'open-uri' 8 | require 'yaml' 9 | 10 | token = open($new_discovery_url).read 11 | 12 | data = YAML.load(IO.readlines('user-data')[1..-1].join) 13 | 14 | if data.key? 'coreos' and data['coreos'].key? 'etcd2' 15 | data['coreos']['etcd2']['discovery'] = token 16 | else 17 | data['coreos']['etcd2']['discovery'] = token 18 | end 19 | 20 | # Fix for YAML.load() converting reboot-strategy from 'off' to `false` 21 | if data.key? 'coreos' and data['coreos'].key? 'update' and data['coreos']['update'].key? 'reboot-strategy' 22 | if data['coreos']['update']['reboot-strategy'] == false 23 | data['coreos']['update']['reboot-strategy'] = 'off' 24 | end 25 | end 26 | 27 | yaml = YAML.dump(data) 28 | File.open('user-data', 'w') { |file| file.write("#cloud-config\n\n#{yaml}") } 29 | end 30 | 31 | # 32 | # coreos-vagrant is configured through a series of configuration 33 | # options (global ruby variables) which are detailed below. To modify 34 | # these options, first copy this file to "config.rb". Then simply 35 | # uncomment the necessary lines, leaving the $, and replace everything 36 | # after the equals sign.. 37 | 38 | # Change basename of the VM 39 | # The default value is "core", which results in VMs named starting with 40 | # "core-01" through to "core-${num_instances}". 41 | #$instance_name_prefix="core" 42 | 43 | # Change the version of CoreOS to be installed 44 | # To deploy a specific version, simply set $image_version accordingly. 45 | # For example, to deploy version 709.0.0, set $image_version="709.0.0". 46 | # The default value is "current", which points to the current version 47 | # of the selected channel 48 | #$image_version = "current" 49 | 50 | # Official CoreOS channel from which updates should be downloaded 51 | #$update_channel='alpha' 52 | 53 | # Log the serial consoles of CoreOS VMs to log/ 54 | # Enable by setting value to true, disable with false 55 | # WARNING: Serial logging is known to result in extremely high CPU usage with 56 | # VirtualBox, so should only be used in debugging situations 57 | #$enable_serial_logging=false 58 | 59 | # Enable port forwarding of Docker TCP socket 60 | # Set to the TCP port you want exposed on the *host* machine, default is 2375 61 | # If 2375 is used, Vagrant will auto-increment (e.g. in the case of $num_instances > 1) 62 | # You can then use the docker tool locally by setting the following env var: 63 | # export DOCKER_HOST='tcp://127.0.0.1:2375' 64 | #$expose_docker_tcp=2375 65 | 66 | # Enable NFS sharing of your home directory ($HOME) to CoreOS 67 | # It will be mounted at the same path in the VM as on the host. 68 | # Example: /Users/foobar -> /Users/foobar 69 | #$share_home=false 70 | 71 | # Customize VMs 72 | #$vm_gui = false 73 | #$vm_memory = 1024 74 | #$vm_cpus = 1 75 | #$vb_cpuexecutioncap = 100 76 | 77 | # Share additional folders to the CoreOS VMs 78 | # For example, 79 | # $shared_folders = {'/path/on/host' => '/path/on/guest', '/home/foo/app' => '/app'} 80 | # or, to map host folders to guest folders of the same name, 81 | # $shared_folders = Hash[*['/home/foo/app1', '/home/foo/app2'].map{|d| [d, d]}.flatten] 82 | #$shared_folders = {} 83 | 84 | # Enable port forwarding from guest(s) to host machine, syntax is: { 80 => 8080 }, auto correction is enabled by default. 85 | #$forwarded_ports = {} 86 | -------------------------------------------------------------------------------- /tests/copy_ssh_keys.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | max_instances=$(awk -F'=' '/^\$num_instances/{ print $2}' Vagrantfile | sed 's/ //g') 4 | fqdn='myfqdn.com' 5 | 6 | for i in $(seq 1 $max_instances) ; do 7 | echo -e "\n => core0${i}${fqdn}" 8 | ssh-keygen -f "${HOME}/.ssh/known_hosts" -R core0${i}${fqdn} 9 | expect -c " 10 | set timeout 1 11 | spawn scp ${HOME}/.ssh/id_rsa.pub core@core0${i}.${fqdn}:~/.ssh/authorized_keys 12 | expect Password: { send core\r } 13 | expect 100% 14 | " 15 | done 16 | -------------------------------------------------------------------------------- /tests/hosts: -------------------------------------------------------------------------------- 1 | [local] 2 | localhost 3 | 4 | [coreos-masters] 5 | core01.myfqdn.com pub_ip=222.2.1.199 priv_ip=172.17.8.101 6 | core02.myfqdn.com pub_ip=222.2.1.198 priv_ip=172.17.8.102 7 | core03.myfqdn.com pub_ip=222.2.1.197 priv_ip=172.17.8.103 8 | 9 | [coreos-workers] 10 | core04.myfqdn.com pub_ip=222.2.1.196 priv_ip=172.17.8.104 11 | core05.myfqdn.com pub_ip=222.2.1.195 priv_ip=172.17.8.105 12 | core06.myfqdn.com pub_ip=222.2.1.194 priv_ip=172.17.8.106 13 | 14 | [coreos-nodes:children] 15 | coreos-masters 16 | coreos-workers 17 | 18 | [coreos-nodes:vars] 19 | ansible_ssh_user=core 20 | ansible_python_interpreter="/opt/python/bin/python" 21 | priv_if=enp0s8 22 | -------------------------------------------------------------------------------- /tests/insert_ssh_key_in_iso.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | iso=coreos_production_iso_image.iso 4 | 5 | # Check if image has already been patched 6 | if [ -f $iso.orig ] ; then 7 | echo "Image already patched" 8 | exit 0 9 | fi 10 | 11 | # Ensure required binaries are present 12 | for binary in 'sudo' 'osirrox' 'gunzip' 'cpio' 'unsquashfs' 'mksquashfs' 'gzip' 'genisoimage' ; do 13 | echo "Check if $binary exists or exit..." 14 | which $binary 1>/dev/null || exit 1 15 | done 16 | 17 | # Flush old data 18 | sudo rm -Rf cd 19 | mkdir cd 20 | 21 | # Extract iso 22 | osirrox -indev $iso -extract / cd 23 | chmod -Rf u+w cd 24 | 25 | # Unzip squashfs 26 | cd ./cd/coreos 27 | gunzip cpio.gz 28 | cpio -i < cpio 29 | sudo unsquashfs usr.squashfs 30 | 31 | # Add ssh key to CoreOS 32 | sudo mkdir squashfs-root/share/skel/.ssh 33 | sudo cp ~/.ssh/id_rsa.pub squashfs-root/share/skel/.ssh/authorized_keys 34 | sudo sh -c 'echo "L /home/core/.ssh/authorized_keys - core core - ../../../usr/share/skel/.ssh/authorized_keys" >> squashfs-root/lib64/tmpfiles.d/baselayout-home.conf' 35 | sudo sh -c 'echo "StrictModes no" >> squashfs-root/share/ssh/sshd_config' 36 | 37 | # Make sqashfs 38 | rm -f usr.squashfs 39 | sudo mksquashfs squashfs-root usr.squashfs -noappend -always-use-fragments 40 | sudo rm -Rf etc squashfs-root 41 | find usr.squashfs | cpio -o -A -H newc -O cpio 42 | sudo rm -f usr.squashfs 43 | gzip -9 cpio 44 | cd .. 45 | 46 | # Make ISO image and clean 47 | if [ ! -f ../$iso.orig ] ; then 48 | mv ../$iso ../$iso.orig 49 | fi 50 | genisoimage -o ../$iso -r -J -no-emul-boot -z -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin -c isolinux/boot.cat ../cd || exit 1 51 | cd .. 52 | sudo rm -Rf cd 53 | -------------------------------------------------------------------------------- /tests/playbook_coreos.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: coreos-ansible pypy 4 | hosts: localhost 5 | gather_facts: False 6 | tasks: 7 | - include: ../../deimosfr.coreos-ansible/tasks/ansible_prerequisites.yml 8 | vars: 9 | ansible_python_interpreter: "/usr/bin/python" 10 | coreos_ansible_role_path: "{{playbook_dir}}/../../deimosfr.coreos-ansible" 11 | 12 | - name: coreos image offline mode 13 | hosts: localhost 14 | gather_facts: False 15 | tasks: 16 | - include: ../tasks/coreos_offline_image.yml 17 | when: coreos_image_offline 18 | vars: 19 | ansible_python_interpreter: "/usr/bin/python" 20 | coreos_role_path: "{{playbook_dir}}/.." 21 | coreos_image_offline: true 22 | coreos_image_version: '1185.5.0' 23 | coreos_image_name: 'coreos_production_image.bin.bz2' 24 | coreos_image_src_url: "https://stable.release.core-os.net/amd64-usr/{{coreos_image_version}}" 25 | 26 | - name: coreos-ansible 27 | hosts: coreos-nodes 28 | user: core 29 | become: yes 30 | gather_facts: False 31 | roles: 32 | - deimosfr.coreos-ansible 33 | vars: 34 | coreos_ansible_role_path: "{{playbook_dir}}/../../deimosfr.coreos-ansible" 35 | 36 | # First deploy masters to ensure cluster will be ready before workers 37 | - name: coreos-bootstrap 38 | hosts: coreos-masters 39 | user: core 40 | become: yes 41 | roles: 42 | - deimosfr.coreos-container-linux 43 | vars: 44 | coreos_image_base_url: "http://222.2.1.152:8000/coreos_images" 45 | coreos_ansible_role_path: "{{playbook_dir}}/../../deimosfr.coreos-ansible" 46 | 47 | - name: coreos-bootstrap 48 | hosts: coreos-workers 49 | user: core 50 | become: yes 51 | roles: 52 | - deimosfr.coreos-container-linux 53 | vars: 54 | coreos_image_base_url: "http://222.2.1.152:8000/coreos_images" 55 | coreos_ansible_role_path: "{{playbook_dir}}/../../deimosfr.coreos-ansible" 56 | -------------------------------------------------------------------------------- /tests/user-data: -------------------------------------------------------------------------------- 1 | #cloud-config 2 | 3 | --- 4 | coreos: 5 | etcd2: 6 | discovery: https://discovery.etcd.io/a8e67fa4d2dcf0d278e2df529d08146f 7 | advertise-client-urls: http://$public_ipv4:2379 8 | initial-advertise-peer-urls: http://$private_ipv4:2380 9 | listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001 10 | listen-peer-urls: http://$private_ipv4:2380,http://$private_ipv4:7001 11 | update: 12 | group: stable 13 | reboot-strategy: 'off' 14 | fleet: 15 | public-ip: "$public_ipv4" 16 | metadata: cluster=vagrant 17 | flannel: 18 | interface: "$public_ipv4" 19 | units: 20 | - name: etcd2.service 21 | command: start 22 | - name: fleet.service 23 | command: start 24 | - name: flanneld.service 25 | drop-ins: 26 | - name: 50-network-config.conf 27 | content: | 28 | [Service] 29 | ExecStartPre=/usr/bin/etcdctl set /coreos.com/network/config '{ "Network": "10.1.0.0/16" }' 30 | command: start 31 | - name: docker-tcp.socket 32 | command: start 33 | enable: true 34 | content: | 35 | [Unit] 36 | Description=Docker Socket for the API 37 | 38 | [Socket] 39 | ListenStream=2375 40 | Service=docker.service 41 | BindIPv6Only=both 42 | 43 | [Install] 44 | WantedBy=sockets.target 45 | write_files: 46 | - path: "/home/core/.toolboxrc" 47 | owner: core 48 | content: | 49 | TOOLBOX_DOCKER_IMAGE=debian 50 | TOOLBOX_DOCKER_TAG=stable 51 | --------------------------------------------------------------------------------