├── .gitignore
├── LICENSE
├── README.md
├── ansible.cfg
├── docs
├── README.md
└── ansible_demo_infra.png
├── inventory
└── default
├── keys
└── vagrant_dsa
├── plays
├── debug.yml
├── deploy.yml
├── disk.yml
├── ec2_killall.yml
├── ec2_new.yml
├── ec2_terminate.yml
├── ec2_vpc_setup.yml
├── group_vars
│ └── prod_jenkins.yml
├── jenkins.yml
├── ping.yml
├── post.yml
├── service.yml
├── site.yml
├── sudo.yml
├── users.yml
├── vm_clone-old.yml
├── vm_clone.yml
└── vm_control.yml
├── roles
├── README.md
├── ansible-users
│ ├── .travis.yml
│ ├── LICENSE
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ └── tests
│ │ └── test.yml
├── app
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ ├── deploy.yml
│ │ └── main.yml
│ ├── templates
│ │ ├── index.html.j2
│ │ ├── nginx.conf.j2
│ │ ├── uwsgi.ini.j2
│ │ └── webapp.service.j2
│ └── vars
│ │ └── main.yml
├── disk
│ ├── README.md
│ └── tasks
│ │ └── main.yml
├── epel
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ └── vars
│ │ ├── RedHat-6.yml
│ │ ├── RedHat-7.yml
│ │ └── main.yml
├── firewall
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ └── vars
│ │ └── main.yml
├── gather_debug
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ └── tasks
│ │ └── main.yml
├── hosts
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ ├── templates
│ │ └── hosts.j2
│ └── vars
│ │ └── main.yml
├── issue
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ ├── templates
│ │ ├── issue-Amazon.j2
│ │ ├── issue-CentOS.j2
│ │ ├── issue-RedHat.j2
│ │ └── issue-Ubuntu.j2
│ └── vars
│ │ └── main.yml
├── nginx
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── files
│ │ └── epel.repo
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ ├── .galaxy_install_info
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ ├── templates
│ │ ├── default.conf.j2
│ │ ├── default.j2
│ │ ├── nginx.conf.j2
│ │ └── site.j2
│ └── vars
│ │ ├── CentOS-6.yml
│ │ ├── CentOS-7.yml
│ │ └── main.yml
├── packages
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ └── vars
│ │ └── main.yml
├── patching
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ ├── templates
│ │ └── template.repo.j2
│ └── vars
│ │ ├── CentOS-6.yml
│ │ ├── CentOS-7.yml
│ │ └── main.yml
├── phone_home
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── files
│ │ └── req_conf.sh
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ └── vars
│ │ └── main.yml
├── services
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ │ └── main.yml
├── shell
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ ├── templates
│ │ └── aliases.sh.j2
│ └── vars
│ │ └── main.yml
├── sshd
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ └── vars
│ │ ├── Amazon.yml
│ │ ├── CentOS.yml
│ │ ├── RedHat.yml
│ │ └── main.yml
├── sudo
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ └── templates
│ │ └── user.j2
├── vmwtools
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── files
│ │ └── vmwtools.fact
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ └── vars
│ │ └── main.yml
├── xentools
│ ├── defaults
│ │ └── main.yml
│ ├── files
│ │ └── xentools.fact
│ └── tasks
│ │ └── main.yml
└── yum
│ ├── README.md
│ ├── defaults
│ └── main.yml
│ ├── files
│ └── RPM-GPG-KEY-EPEL-7
│ ├── handlers
│ └── main.yml
│ ├── meta
│ └── main.yml
│ ├── tasks
│ └── main.yml
│ ├── templates
│ ├── CentOS-Base.repo.j2
│ └── template.repo.j2
│ └── vars
│ └── main.yml
└── scripts
├── ec2_bootstrap.sh
└── tower_setup.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | #vim
2 | *.sw?
3 |
4 | #mac
5 | .DS_store
6 |
--------------------------------------------------------------------------------
/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 Demos
2 |
3 | Here are all the [plays](plays) and [roles](roles) I use in my many varieties of Ansible demo.
4 |
5 | There aren't any instructions, per se, as this is all simply reference material. However, you can view a common demonstration I give [here on Youtube](https://youtu.be/DA1Pmunx6aM).
6 |
7 | **NOTE**: You should, however, assume that you need at least [Ansible Core 2](https://github.com/ansible/ansible) - a lot of the plays and roles here now feature [blocks](http://docs.ansible.com/ansible/playbooks_blocks.html), and so will fail on Core 1.9 and less.
8 |
9 | Quite often I am working with [dynamic inventory](http://docs.ansible.com/ansible/intro_dynamic_inventory.html) sources. Those scripts are not here, as they change. The best place to get them is from [the Ansible source](https://github.com/ansible/ansible/tree/devel/contrib/inventory) itself.
10 |
11 | The main demo I give, [deploying code](roles/app), makes use of [this other repository](https://github.com/phips/flask_app) of mine.
12 |
13 | One of the things I would like to expand this with is alternate hypervisors - using [RHEV](http://www.redhat.com/en/technologies/virtualization/enterprise-virtualization), for example, is a logical next step. If you get time to work on plays for that before I do, I welcome pull requests!
14 |
--------------------------------------------------------------------------------
/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | roles_path = roles
3 | inventory = inventory/prod.aws_ec2.yml
4 | host_key_checking = False
5 | forks = 20
6 | remote_user = centos
7 | private_key_file = ~/.ssh/marphill.pem
8 | retry_files_enabled = False
9 |
10 | [ssh_connection]
11 | # you may need to disable this if requiretty is in your sshd_config
12 | # (or remove requiretty!)
13 | pipelining = True
14 | control_path = /tmp/%%h-%%r
15 | # ssh_args = -F .ssh/config
16 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # Demo Infrastructure
2 |
3 | My most popular demonstration utilises VMware, Jenkins, Git and Ansible Tower to show a software deployment. From a Linux workstation I make a change to some code, which is automatically updated in Jenkins via a trigger, and is subsequently tested, turned into an artifact (tgz file, basically) and deployed to N web server hosts by Ansible Tower.
4 |
5 | Nginx also features as a Yum repository.
6 |
7 | Ansible handles provisioning of virtual machines, installation and configuration of supporting applications (Nginx again, plus [WSGI](http://wsgi.readthedocs.org/en/latest/) and finally deploying our web application code.
8 |
9 | This is how the infrastructure looks:
10 |
11 | 
12 |
13 |
--------------------------------------------------------------------------------
/docs/ansible_demo_infra.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phips/ansible-demos/3bf59df1eb2390b31b5c42333197e2fbb7fec93f/docs/ansible_demo_infra.png
--------------------------------------------------------------------------------
/inventory/default:
--------------------------------------------------------------------------------
1 | [vmcreate:children]
2 | linuxpython
3 |
4 | [linuxpython]
5 | linux ansible_connection=local ansible_python_interpreter=/home/vagrant/pip/bin/python
6 |
--------------------------------------------------------------------------------
/keys/vagrant_dsa:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI
3 | w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP
4 | kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2
5 | hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO
6 | Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW
7 | yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQIBIwKCAQEA4iqWPJXtzZA68mKd
8 | ELs4jJsdyky+ewdZeNds5tjcnHU5zUYE25K+ffJED9qUWICcLZDc81TGWjHyAqD1
9 | Bw7XpgUwFgeUJwUlzQurAv+/ySnxiwuaGJfhFM1CaQHzfXphgVml+fZUvnJUTvzf
10 | TK2Lg6EdbUE9TarUlBf/xPfuEhMSlIE5keb/Zz3/LUlRg8yDqz5w+QWVJ4utnKnK
11 | iqwZN0mwpwU7YSyJhlT4YV1F3n4YjLswM5wJs2oqm0jssQu/BT0tyEXNDYBLEF4A
12 | sClaWuSJ2kjq7KhrrYXzagqhnSei9ODYFShJu8UWVec3Ihb5ZXlzO6vdNQ1J9Xsf
13 | 4m+2ywKBgQD6qFxx/Rv9CNN96l/4rb14HKirC2o/orApiHmHDsURs5rUKDx0f9iP
14 | cXN7S1uePXuJRK/5hsubaOCx3Owd2u9gD6Oq0CsMkE4CUSiJcYrMANtx54cGH7Rk
15 | EjFZxK8xAv1ldELEyxrFqkbE4BKd8QOt414qjvTGyAK+OLD3M2QdCQKBgQDtx8pN
16 | CAxR7yhHbIWT1AH66+XWN8bXq7l3RO/ukeaci98JfkbkxURZhtxV/HHuvUhnPLdX
17 | 3TwygPBYZFNo4pzVEhzWoTtnEtrFueKxyc3+LjZpuo+mBlQ6ORtfgkr9gBVphXZG
18 | YEzkCD3lVdl8L4cw9BVpKrJCs1c5taGjDgdInQKBgHm/fVvv96bJxc9x1tffXAcj
19 | 3OVdUN0UgXNCSaf/3A/phbeBQe9xS+3mpc4r6qvx+iy69mNBeNZ0xOitIjpjBo2+
20 | dBEjSBwLk5q5tJqHmy/jKMJL4n9ROlx93XS+njxgibTvU6Fp9w+NOFD/HvxB3Tcz
21 | 6+jJF85D5BNAG3DBMKBjAoGBAOAxZvgsKN+JuENXsST7F89Tck2iTcQIT8g5rwWC
22 | P9Vt74yboe2kDT531w8+egz7nAmRBKNM751U/95P9t88EDacDI/Z2OwnuFQHCPDF
23 | llYOUI+SpLJ6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ
24 | kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH
25 | +vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ
26 | NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s=
27 | -----END RSA PRIVATE KEY-----
28 |
--------------------------------------------------------------------------------
/plays/debug.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | - hosts: all
4 | gather_facts: false
5 | become: true
6 |
7 | roles:
8 | - { role: gather_debug }
9 |
--------------------------------------------------------------------------------
/plays/deploy.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Deploy web application
3 | hosts: app
4 | become: yes
5 |
6 | roles:
7 | - { role: app }
8 |
--------------------------------------------------------------------------------
/plays/disk.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | - hosts: all
4 | gather_facts: false
5 | become: true
6 |
7 | roles:
8 | - { role: disk }
9 |
--------------------------------------------------------------------------------
/plays/ec2_killall.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: all:!tag_type_tower:!tag_type_jenkins
3 | vars:
4 | region: eu-west-1
5 |
6 | tasks:
7 | - name: DANGER WILL ROBINSON! DANGER!
8 | debug: var=ec2_id
9 |
10 | - name: Kill it
11 | local_action:
12 | module: ec2
13 | region: "{{ region }}"
14 | instance_ids: "{{ ec2_id }}"
15 | state: absent
16 |
17 | - name: Success
18 | debug: msg="Terminated instance ID {{ ec2_id }}"
19 |
20 | - name: Kill ELB
21 | local_action:
22 | module: ec2_elb_lb
23 | region: "{{ region }}"
24 | name: "{{ lbname | default('VPClb') }}"
25 | state: absent
26 | when: kill_elb is defined
27 |
--------------------------------------------------------------------------------
/plays/ec2_new.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vim: set ft=ansible:
3 | - name: Create new EC2 instances
4 | hosts: localhost
5 | gather_facts: false
6 | connection: local
7 |
8 | vars:
9 | region: eu-west-2
10 | ami: ami-0eab3a90fc693af19 # CentOS Linux 7 x86_64 HVM EBS ENA 1901_01
11 | keypair: "{{ ec2_keypair_name | default('you need to define this') }}"
12 | set_dns: False
13 | count: 1
14 | tags:
15 | env: "{{ tags_env | default('prod') }}"
16 | type: "{{ tags_type | default('web') }}"
17 | wait_for_ssh: False
18 |
19 | tasks:
20 | - name: Launch instance
21 | local_action:
22 | module: ec2
23 | keypair: "{{ keypair }}"
24 | instance_type: "{{ type | default('t2.micro') }}"
25 | # subnet-0f33c166 is eu-west-2c 172.31.32.0
26 | vpc_subnet_id: "subnet-{{ vpc_subnet | default('0f33c166') }}"
27 | image: "{{ ami }}"
28 | region: "{{ region }}"
29 | count: "{{ count }}"
30 | wait: yes
31 | instance_tags: "{{ tags }}"
32 | # user_data: "{{ lookup('file', '../scripts/ec2_bootstrap.sh') }}"
33 | assign_public_ip: "{{ assign_eip | default(true) }}"
34 | register: ec2
35 |
36 | - name: Instance info
37 | debug:
38 | msg: "{{ item.id }} {{ item.public_ip }}"
39 | with_items: "{{ ec2.instances }}"
40 |
41 |
--------------------------------------------------------------------------------
/plays/ec2_terminate.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vim: set ft=ansible:
3 | # terminate the specified EC2 instance-id
4 |
5 | - hosts: localhost
6 | connection: local
7 | gather_facts: false
8 |
9 | vars:
10 | region: eu-west-1
11 |
12 | tasks:
13 | - name: Check for variables
14 | fail: msg="Must pass id to -e"
15 | when: id is not defined
16 |
17 | - name: Terminate instance
18 | ec2:
19 | region: "{{ region }}"
20 | instance_ids: "{{ id }}"
21 | state: absent
22 |
23 | - name: Success
24 | debug: msg="Terminated instance ID {{ id }}"
25 |
--------------------------------------------------------------------------------
/plays/ec2_vpc_setup.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vim: set ft=ansible:
3 | - hosts: localhost
4 | connection: local
5 | gather_facts: false
6 | vars:
7 | region: eu-west-1
8 | tags:
9 | env: "{{ tags_env | default('dev') }}"
10 |
11 | tasks:
12 | - name: Check for variables
13 | fail:
14 | msg: "Must supply tags_env to -e"
15 | when: tags_env is not defined
16 |
17 | - name: Create VPC
18 | local_action:
19 | module: ec2_vpc
20 | cidr_block: "{{ vpc_subnet | default('172.16.16.0/24') }}"
21 | resource_tags: "{{ tags }}"
22 | region: "{{ region }}"
23 | state: present
24 | internet_gateway: true
25 | subnets:
26 | - cidr: "{{ vpc_subnet | default('172.16.16.0/24') }}"
27 | resource_tags:
28 | tier: dmz
29 | route_tables:
30 | - subnets:
31 | - "{{ vpc_subnet | default('172.16.16.0/24') }}"
32 | routes:
33 | - dest: 0.0.0.0/0
34 | gw: igw
35 | register: vpc
36 |
37 | - name: Ensure firewall rules are present
38 | local_action:
39 | module: ec2_group
40 | name: default
41 | description: "default VPC security group"
42 | region: "{{ region }}"
43 | vpc_id: "{{ vpc.vpc_id }}"
44 | purge_rules: false
45 | rules:
46 | # TOWER
47 | - proto: tcp
48 | from_port: 22
49 | to_port: 22
50 | cidr_ip: 52.16.66.2/32
51 |
52 | - name: VPC subnet id is
53 | debug:
54 | msg: "{{ vpc.subnets[0].id }}"
55 |
56 | - name: Ensure load balancer launched
57 | local_action:
58 | module: ec2_elb_lb
59 | name: "{{ lbname | default('VPClb') }}"
60 | region: "{{ region }}"
61 | state: present
62 | subnets: "{{ vpc.subnets[0].id }}"
63 | connection_draining_timeout: 60
64 | listeners:
65 | - protocol: http
66 | load_balancer_port: 80
67 | instance_port: 80
68 | health_check:
69 | ping_protocol: http # options are http, https, ssl, tcp
70 | ping_port: 80
71 | ping_path: "/" # not required for tcp or ssl
72 | response_timeout: 5 # seconds
73 | interval: 30 # seconds
74 | unhealthy_threshold: 5
75 | healthy_threshold: 5
76 | register: elb
77 |
78 | # - debug: var=elb.elb.dns_name
79 |
80 | - name: Ensure LB is registered in DNS
81 | route53:
82 | command: create
83 | overwrite: yes
84 | record: www.bovine.cow
85 | zone: bovine.cow
86 | type: CNAME
87 | ttl: 180
88 | value: "{{ elb.elb.dns_name }}"
89 |
90 |
--------------------------------------------------------------------------------
/plays/group_vars/prod_jenkins.yml:
--------------------------------------------------------------------------------
1 | ---
2 | java_packages:
3 | - java-1.7.0-openjdk
4 |
5 | jenkins_plugins:
6 | - git
7 | - github
8 | - git-parameter
9 | - ssh
10 | - google-login
11 | - shiningpanda
12 |
13 | packages:
14 | - ack
15 | - python26-devel
16 | - python26-pip
17 | - libxslt-devel
18 | - gcc
19 |
20 | packages_pip:
21 | - ansible-tower-cli
22 |
--------------------------------------------------------------------------------
/plays/jenkins.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # install jenkins
3 |
4 | - hosts: all:!tag_type_tower
5 | gather_facts: true
6 | user: ec2-user
7 | sudo: true
8 | tags: [ prod_jenkins, pkgs ]
9 |
10 | tasks:
11 | - name: Dynamic grouping
12 | group_by: key={{ ec2_tag_env }}_{{ ec2_tag_type }}
13 |
14 | - hosts: prod_jenkins
15 | sudo: yes
16 | roles:
17 | - { role: packages, tags: pkgs }
18 | - { role: geerlingguy.java }
19 | - { role: geerlingguy.jenkins }
20 |
--------------------------------------------------------------------------------
/plays/ping.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Ping
3 | hosts: all
4 | gather_facts: no
5 | tasks:
6 | - name: Ping host
7 | ping:
8 |
--------------------------------------------------------------------------------
/plays/post.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vim: set syn=ansible ts=2 sw=2 et:
3 | #
4 | # intended to be used by ansible >=2.0
5 | - hosts: all
6 | become: true
7 |
8 | roles:
9 | - { role: firewall
10 | , when: ansible_distribution_major_version == '7' or ansible_distribution == 'Fedora'
11 | , tags: fw }
12 | - { role: hosts, tags: hosts }
13 | - { role: issue, tags: issue }
14 | - { role: sshd, tags: ssh }
15 | - { role: shell, tags: shell }
16 | - { role: yum, tags: yum }
17 | - { role: epel, tags: epel }
18 | - { role: packages, tags: pkgs }
19 | - { role: phone_home, tags: ph }
20 | - { role: xentools
21 | , when: ansible_virtualization_type == "xen"
22 | , tags: tools }
23 | - { role: vmwtools
24 | , when: (ansible_virtualization_type == "VMware" and vmwtools_install)
25 | , tags: tools }
26 |
27 | - hosts: app
28 | become: true
29 | roles:
30 | - { role: app }
31 |
--------------------------------------------------------------------------------
/plays/service.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | - hosts: all
4 | gather_facts: false
5 | become: true
6 |
7 | roles:
8 | - { role: services }
9 |
--------------------------------------------------------------------------------
/plays/site.yml:
--------------------------------------------------------------------------------
1 | - include: deploy.yml
2 | - include: ec2_killall.yml
3 | #- include: ec2_new.yml
4 | #- include: ec2_terminate.yml
5 | #- include: ec2_vpc_setup.yml
6 | - include: ping.yml
7 | - include: post.yml
8 | #- include: vm_clone-new.yml
9 | - include: vm_clone.yml
10 | - include: vm_control.yml
11 |
--------------------------------------------------------------------------------
/plays/sudo.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | - hosts: all
4 | gather_facts: false
5 | become: true
6 |
7 | roles:
8 | - { role: sudo }
9 |
--------------------------------------------------------------------------------
/plays/users.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vim: set syn=ansible ts=2 sw=2 et:
3 | - hosts: all
4 | become: true
5 |
6 | roles:
7 | - { role: ansible-users, tags: users }
8 |
--------------------------------------------------------------------------------
/plays/vm_clone-old.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vim: set ft=ansible et ts=2 sw=2:
3 | #
4 | # Create a new VM from a template
5 |
6 | - name: VM from template
7 | hosts: vmcreate
8 | gather_facts: false
9 | connection: local
10 | vars:
11 | vcenter_hostname: vcsa.box
12 | esxhost: esx1.box
13 | datastore: datastore1
14 | network: "VMnetwork"
15 | vmtemplate: CentOS7-Base
16 | vmcluster: LAN
17 | notes: Created by Ansible
18 | dumpfacts: False
19 | tasks:
20 | - name: Check for required variables
21 | fail: msg="Must pass name and group to -e"
22 | when: name is not defined or group is not defined
23 |
24 | - name: Check for vSphere access parameters
25 | fail: msg="Must set vcenter_user and vcenter_pass in a Vault"
26 | when: (vcenter_user is not defined) or (vcenter_pass is not defined)
27 |
28 | - name: Create VM from template
29 | vsphere_guest:
30 | vcenter_hostname: "{{ vcenter_hostname }}"
31 | username: "{{ vcenter_user }}"
32 | password: "{{ vcenter_pass }}"
33 | guest: "{{ name }}"
34 | from_template: yes
35 | template_src: "{{ vmtemplate }}"
36 | resource_pool: "/Resources"
37 | vm_extra_config:
38 | notes: "{{ notes }}"
39 | otheridentifyinginfo:
40 | env: "dev"
41 | esxi:
42 | datacenter: BOX
43 | hostname: "{{ esxhost }}"
44 | vm_hardware:
45 | memory_mb: "{{ vm_memory | default(1024) }}"
46 |
47 | - block:
48 | - name: Wait a minute for tools to start
49 | wait_for:
50 | timeout: 60
51 | changed_when: False
52 |
53 | - name: Gather VM facts
54 | vsphere_guest:
55 | vcenter_hostname: "{{ vcenter_hostname }}"
56 | username: "{{ vcenter_user }}"
57 | password: "{{ vcenter_pass }}"
58 | guest: "{{ name }}"
59 | vmware_guest_facts: yes
60 | register: newvm
61 |
62 | - name: IP address info
63 | debug:
64 | msg: "{{ newvm.ansible_facts.hw_eth0.ipaddresses[0] }} {{ name }}"
65 |
66 | # oops, we probably need to wait a little longer to grab IP address
67 | rescue:
68 | - name: Wait a bit longer for tools to start
69 | wait_for:
70 | timeout: 30
71 | changed_when: False
72 |
73 | - name: Gather VM facts
74 | vsphere_guest:
75 | vcenter_hostname: "{{ vcenter_hostname }}"
76 | username: "{{ vcenter_user }}"
77 | password: "{{ vcenter_pass }}"
78 | guest: "{{ name }}"
79 | vmware_guest_facts: yes
80 | register: newvm
81 |
82 | - name: IP address info
83 | debug:
84 | msg: "{{ newvm.ansible_facts.hw_eth0.ipaddresses[0] }} {{ name }}"
85 |
86 | - name: Dump all facts when ask to
87 | debug:
88 | msg: "{{ newvm.ansible_facts }}"
89 | when: dumpfacts
90 |
91 | - name: Wait for ssh to be available
92 | wait_for:
93 | host: "{{ newvm.ansible_facts.hw_eth0.ipaddresses[0] }}"
94 | port: 22
95 | timeout: 600
96 | state: started
97 |
98 | - name: Create temporary variables file
99 | copy:
100 | content: "ansible_ssh_host: {{ newvm.ansible_facts.hw_eth0.ipaddresses[0] }}"
101 | dest: "/var/tmp/{{ name }}-vars.yml"
102 |
103 | - name: Ensure host is in Tower inventory
104 | command: "tower-cli host modify --create-on-missing --name {{ name }} --inventory 6 --variables /var/tmp/{{ name }}-vars.yml"
105 |
106 | - name: Associate host with group in Tower
107 | command: "tower-cli host associate --host {{ name }} --group {{ group }}"
108 |
109 | - name: Dump temporary variables file
110 | file:
111 | path: "/var/tmp/{{ name }}-vars.yml"
112 | state: absent
113 |
114 | - name: Add to new group
115 | add_host:
116 | name: "{{ newvm.ansible_facts.hw_eth0.ipaddresses[0] }}"
117 | group: just_created
118 | ip: "{{ newvm.ansible_facts.hw_eth0.ipaddresses[0] }}"
119 | changed_when: false
120 |
121 | - name: Bootstrap new VM
122 | hosts: just_created
123 | become: true
124 | pre_tasks:
125 | - name: Set hostname
126 | hostname:
127 | name: "{{ name }}"
128 |
129 | - name: Set hostname in /etc/hosts
130 | lineinfile:
131 | dest: /etc/hosts
132 | regexp: "^{{ ansible_default_ipv4.address }}.+$"
133 | line: "{{ ansible_default_ipv4.address }} {{ name }}"
134 |
135 | - name: Poke Tower for post-install config
136 | shell: test -x /opt/scripts/req_conf.sh && /opt/scripts/req_conf.sh &
137 | changed_when: false
138 |
--------------------------------------------------------------------------------
/plays/vm_clone.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vim: set ft=ansible et ts=2 sw=2:
3 | #
4 | # Create a new VM from a template
5 |
6 | - name: VM from template
7 | hosts: vmcreate
8 | gather_facts: false
9 | connection: local
10 | vars:
11 | vcenter_hostname: vcsa.box
12 | esxhost: esx1.box
13 | datastore: datastore1
14 | network: "VMnetwork"
15 | vmtemplate: CentOS7-Base
16 | vmcluster: LAN
17 | notes: Created by Ansible
18 | dumpfacts: False
19 | tasks:
20 | - name: Check for required variables
21 | fail: msg="Must pass name and group to -e"
22 | when: name is not defined or group is not defined
23 |
24 | - name: Check for vSphere access parameters
25 | fail: msg="Must set vcenter_user and vcenter_pass in a Vault"
26 | when: (vcenter_user is not defined) or (vcenter_pass is not defined)
27 |
28 | - name: Create VM from template
29 | vmware_guest:
30 | validate_certs: False
31 | hostname: "{{ vcenter_hostname }}"
32 | username: "{{ vcenter_user }}"
33 | password: "{{ vcenter_pass }}"
34 | esxi_hostname: "{{ esxhost }}"
35 | datacenter: BOX
36 | name: "{{ name }}"
37 | template: "{{ vmtemplate }}"
38 | disk:
39 | - size_gb: "{{ disk_size | default(20) }}"
40 | type: thin
41 | datastore: "{{ datastore }}"
42 | nic:
43 | - type: vmxnet3
44 | network: "{{ network }}"
45 | hardware:
46 | memory_mb: "{{ vm_memory | default(1024) }}"
47 | wait_for_ip_address: True
48 | state: present
49 | register: newvm
50 |
51 | - name: IP address info
52 | debug:
53 | msg: "{{ newvm.instance.ipv4 }} {{ name }}"
54 |
55 |
--------------------------------------------------------------------------------
/plays/vm_control.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vim: set ft=ansible et ts=2 sw=2:
3 | #
4 | # Control the state of a VM - poweredon, poweredoff or absent
5 | # (i.e. delete it)
6 |
7 | - hosts: vmcreate
8 | gather_facts: false
9 | connection: local
10 | vars:
11 | state: poweredon
12 | tasks:
13 | - name: Check for required variables
14 | fail: msg="Must pass name to -e"
15 | when: name is not defined
16 |
17 | - name: Check for vSphere access parameters
18 | fail: msg="Must set vcenter_user and vcenter_pass in a Vault"
19 | when: (vcenter_user is not defined) or (vcenter_pass is not defined)
20 |
21 | - name: Shutdown VM first if delete required
22 | vmware_guest:
23 | hostname: "{{ vcenter_hostname }}"
24 | username: "{{ vcenter_user }}"
25 | password: "{{ vcenter_pass }}"
26 | name: "{{ name }}"
27 | state: "poweredoff"
28 | when: state == "absent"
29 |
30 | - name: Set VM to desired state
31 | vmware_guest:
32 | hostname: "{{ vcenter_hostname }}"
33 | username: "{{ vcenter_user }}"
34 | password: "{{ vcenter_pass }}"
35 | name: "{{ name }}"
36 | state: "{{ state }}"
37 |
38 |
--------------------------------------------------------------------------------
/roles/README.md:
--------------------------------------------------------------------------------
1 | # Role notes
2 |
3 | Users is https://galaxy.ansible.com/singleplatform-eng/users
4 |
5 |
--------------------------------------------------------------------------------
/roles/ansible-users/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | sudo: required
3 | language: python
4 | python: "2.7"
5 |
6 | install:
7 | - pip install ansible
8 |
9 | # Add ansible.cfg to pick up roles path.
10 | - "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"
11 |
12 | script:
13 | # Syntax Check
14 | - ansible-playbook -i localhost, tests/test.yml --syntax-check
15 |
16 | # Run test.yml
17 | - ansible-playbook -i localhost, --connection=local -b tests/test.yml
18 |
19 | # Run the role/playbook again, checking to make sure it's idempotent.
20 | - >
21 | ansible-playbook -i localhost, --connection=local -b tests/test.yml
22 | | grep -q 'changed=0.*failed=0'
23 | && (echo 'Idempotence test: pass' && exit 0)
24 | || (echo 'Idempotence test: fail' && exit 1)
25 |
26 | # Lets check on the state of the users. I would invoke severspec myself however
27 | # its a big thing to bring in on a small pull.
28 | - id ansibletestuser | grep --silent "uid=2222(ansibletestuser) gid=2222(ansibletestuser) groups=2222(ansibletestuser),2(bin),100(users)"
29 | - id ansibletestuser2 | grep --silent "uid=2223(ansibletestuser2) gid=2223(ansibletestuser2) groups=2223(ansibletestuser2),2(bin),100(users)"
30 | - id ansibletestuser3 | grep --silent "uid=2224(ansibletestuser3) gid=4001(ansibletestgroup1) groups=4001(ansibletestgroup1),2(bin),100(users)"
31 | - id ansibletestuser4 | grep --silent "uid=2225(ansibletestuser4) gid=100(users) groups=100(users),2(bin)"
32 | - id ansibletestuser5 | grep --silent "uid=2226(ansibletestuser5) gid=4000(ansibletestgroup) groups=4000(ansibletestgroup),2(bin),100(users)"
33 | - grep --silent "^ansibletestgroup:" /etc/group
34 | - grep --silent "^ansibletestgroup1:" /etc/group
35 | - ls -lgd /home/ansibletestuser | awk '{exit $3!="ansibletestuser"}'
36 | - ls -lgd /home/otherdirectory | awk '{exit $3!="ansibletestuser2"}'
37 | - ls -lgd /home/ansibletestuser3 | awk '{exit $3!="ansibletestgroup1"}'
38 | - ls -lgd /home/otherdirectory1 | awk '{exit $3!="users"}'
39 | - ls -lgd /home/ansibletestuser5 | awk '{exit $3!="ansibletestgroup"}'
40 | - ls -lg /home/ansibletestuser/.profile | awk '{exit $3!="ansibletestuser"}'
41 | - ls -lg /home/otherdirectory/.profile | awk '{exit $3!="ansibletestuser2"}'
42 | - ls -lg /home/ansibletestuser3/.profile | awk '{exit $3!="ansibletestgroup1"}'
43 | - ls -lg /home/otherdirectory1/.profile | awk '{exit $3!="users"}'
44 | - ls -lgd /home/ansibletestuser5/.profile | awk '{exit $3!="ansibletestgroup"}'
45 |
46 | notifications:
47 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
48 |
--------------------------------------------------------------------------------
/roles/ansible-users/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2013 Mark Harrison
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
--------------------------------------------------------------------------------
/roles/ansible-users/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/singleplatform-eng/ansible-users)
2 |
3 | # ansible-users
4 |
5 | Role to manage users on a system.
6 |
7 | ## Role configuration
8 |
9 | * users_create_per_user_group (default: true) - when creating users, also
10 | create a group with the same username and make that the user's primary
11 | group.
12 | * users_group (default: users) - if users_create_per_user_group is _not_ set,
13 | then this is the primary group for all created users.
14 | * users_default_shell (default: /bin/bash) - the default shell if none is
15 | specified for the user.
16 | * users_create_homedirs (default: true) - create home directories for new
17 | users. Set this to false if you manage home directories separately.
18 | * authorized_keys_file (default: .ssh/authorized_keys) - Set this if the
19 | ssh server is configured to use a non standard authorized keys file.
20 |
21 | ## Creating users
22 |
23 | Add a users variable containing the list of users to add. A good place to put
24 | this is in `group_vars/all` or `group_vars/groupname` if you only want the
25 | users to be on certain machines.
26 |
27 | The following attributes are required for each user:
28 |
29 | * username - The user's username.
30 | * name - The full name of the user (gecos field).
31 | * home - The home directory of the user to create (optional, defaults to /home/username).
32 | * uid - The numeric user id for the user (optional). This is required for uid consistency
33 | across systems.
34 | * gid - The numeric group id for the group (optional). Otherwise, the
35 | uid will be used.
36 | * password - If a hash is provided then that will be used, but otherwise the
37 | account will be locked.
38 | * update_password - This can be either 'always' or 'on_create'
39 | - 'always' will update passwords if they differ. (default)
40 | - 'on_create' will only set the password for newly created users.
41 | * group - Optional primary group override.
42 | * groups - A list of supplementary groups for the user.
43 | * append - If yes, will only add groups, not set them to just the list in groups (optional).
44 | * profile - A string block for setting custom shell profiles.
45 | * ssh_key - This should be a list of SSH keys for the user (optional). Each SSH key
46 | should be included directly and should have no newlines.
47 | * generate_ssh_key - Whether to generate a SSH key for the user (optional, defaults to no).
48 |
49 | In addition, the following items are optional for each user:
50 |
51 | * shell - The user's shell. This defaults to /bin/bash. The default is
52 | configurable using the users_default_shell variable if you want to give all
53 | users the same shell, but it is different than /bin/bash.
54 |
55 | Example:
56 |
57 | ---
58 | users:
59 | - username: foo
60 | name: Foo Barrington
61 | groups: ['wheel','systemd-journal']
62 | uid: 1001
63 | home: /local/home/foo
64 | profile: |
65 | alias ll='ls -lah'
66 | ssh_key:
67 | - "ssh-rsa AAAAA.... foo@machine"
68 | - "ssh-rsa AAAAB.... foo2@machine"
69 | groups_to_create:
70 | - name: developers
71 | gid: 10000
72 | users_deleted:
73 | - username: bar
74 | name: Bar User
75 | uid: 1002
76 |
77 | ## Deleting users
78 |
79 | The `users_deleted` variable contains a list of users who should no longer be
80 | in the system, and these will be removed on the next ansible run. The format
81 | is the same as for users to add, but the only required field is `username`.
82 | However, it is recommended that you also keep the `uid` field for reference so
83 | that numeric user ids are not accidentally reused.
84 |
85 | You can optionally choose to remove the user's home directory and mail spool with
86 | the `remove` parameter, and force removal of files with the `force` parameter.
87 |
88 | users_deleted:
89 | - username: bar
90 | uid: 1002
91 | remove: yes
92 | force: yes
93 |
--------------------------------------------------------------------------------
/roles/ansible-users/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Create a group for every user and make that their primary group
3 | users_create_per_user_group: true
4 | # If we're not creating a per-user group, then this is the group all users
5 | # belong to
6 | users_group: users
7 | # The default shell for a user if none is specified
8 | users_default_shell: /bin/bash
9 | # Create home dirs for new users? Set this to false if you manage home
10 | # directories in some other way.
11 | users_create_homedirs: true
12 |
13 | # Lists of users to create and delete
14 | users: []
15 | users_deleted: []
16 |
17 | # List of groups to create
18 | # Example:
19 | # groups_to_create:
20 | # - name: developers
21 | # gid: 10000
22 | groups_to_create: []
23 |
24 | authorized_keys_file: ".ssh/authorized_keys"
25 |
--------------------------------------------------------------------------------
/roles/ansible-users/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: Mark Harrison (Modified by SinglePlatform Engineering)
4 | description: User creation role
5 | license: MIT
6 | min_ansible_version: 1.3
7 | platforms:
8 | - name: EL
9 | versions:
10 | - all
11 | - name: GenericUNIX
12 | versions:
13 | - all
14 | - any
15 | - name: Fedora
16 | versions:
17 | - all
18 | - name: opensuse
19 | versions:
20 | - all
21 | - name: Ubuntu
22 | versions:
23 | - all
24 | - name: SLES
25 | versions:
26 | - all
27 | - name: GenericLinux
28 | versions:
29 | - all
30 | - any
31 | - name: Debian
32 | versions:
33 | - all
34 | galaxy_tags:
35 | - system
36 |
37 | dependencies: []
38 |
--------------------------------------------------------------------------------
/roles/ansible-users/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Creating groups
3 | group:
4 | name: "{{ item.name }}"
5 | gid: "{{ item.gid | default(omit) }}"
6 | with_items: "{{ groups_to_create }}"
7 | tags: ["users", "groups", "configuration"]
8 |
9 | - name: Per-user group creation
10 | group:
11 | name: "{{ item.username }}"
12 | gid: "{{ item.gid | default(item.uid) | default(omit) }}"
13 | with_items: "{{ users }}"
14 | when: "'group' not in item and users_create_per_user_group"
15 | tags: ["users", "configuration"]
16 |
17 | - name: User creation
18 | user:
19 | name: "{{ item.username }}"
20 | group: "{{ item.group | default(item.username if users_create_per_user_group else users_group) }}"
21 | # empty string removes user from all secondary groups
22 | groups: "{{ item.groups | join(',') if 'groups' in item else '' }}"
23 | append: "{{ item.append | default(omit) }}"
24 | shell: "{{ item.shell if item.shell is defined else users_default_shell }}"
25 | password: "{{ item.password if item.password is defined else '!' }}"
26 | comment: "{{ item.name if item.name is defined else '' }}"
27 | uid: "{{ item.uid | default(omit) }}"
28 | home: "{{ item.home | default('/home/' + item.username) }}"
29 | createhome: "{{ 'yes' if users_create_homedirs else 'no' }}"
30 | generate_ssh_key: "{{ item.generate_ssh_key | default(omit) }}"
31 | update_password: "{{ item.update_password | default(omit) }}"
32 | with_items: "{{ users }}"
33 | tags: ["users", "configuration"]
34 |
35 | - name: SSH keys
36 | authorized_key:
37 | user: "{{ item.0.username }}"
38 | key: "{{ item.1 }}"
39 | path: "{{ item.0.home | default('/home/' + item.0.username) }}/{{ authorized_keys_file }}"
40 | with_subelements:
41 | - "{{ users }}"
42 | - ssh_key
43 | - skip_missing: yes
44 | tags: ["users", "configuration"]
45 |
46 | - name: Setup user profiles
47 | blockinfile:
48 | block: "{{ item.profile }}"
49 | dest: "{{ item.home | default('/home/' + item.username) }}/.profile"
50 | owner: "{{ item.username }}"
51 | group: "{{ item.group | default(item.username if users_create_per_user_group else users_group) }}"
52 | mode: 0644
53 | create: true
54 | when: users_create_homedirs and item.profile is defined
55 | with_items: "{{ users }}"
56 |
57 | - name: Deleted user removal
58 | user:
59 | name: "{{ item.username }}"
60 | state: absent
61 | remove: "{{ item.remove | default(omit) }}"
62 | force: "{{ item.force | default(omit) }}"
63 | with_items: "{{ users_deleted }}"
64 | tags: ["users", "configuration"]
65 |
66 | - name: Deleted per-user group removal
67 | group:
68 | name: "{{ item.username }}"
69 | state: absent
70 | with_items: "{{ users_deleted }}"
71 | when: users_create_per_user_group
72 | tags: ["users", "configuration"]
73 |
--------------------------------------------------------------------------------
/roles/ansible-users/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | vars:
5 | groups_to_create:
6 | - name: ansibletestgroup
7 | gid: 4000
8 | users:
9 | - name: Ansible Test User
10 | username: ansibletestuser
11 | uid: 2222
12 | groups: [users, bin]
13 | shell: /bin/sh
14 | profile: |
15 | alias ll='ls -lah'
16 | alias cp='cp -iv'
17 | ssh_key:
18 | - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVpUJQCOaPg3p5xro9e+1fkGRWNOGrrExiKMqTE91Fwu349bxfMnMzRS0PAERouR9EEL+Ee4Yzhav/uNc35eCtXzACtluXnAncMrQj6pM3IqASynhvXTygHljmcMbBSDQtLrTZeW+YzIcOgk5UM1yBi26WoUYva2aCr9IRvKdYreAK08OiMdZedpOye0ZdvIYJGcyITwc6YMmrAhP7jZlrk/mDEkf2a4eBp+475o7MJtaC9npqYkToM8vqvx5AGEKqXt7/f1/paOY7KsR+VGPQy6k2RkXjWBsXPesZ3d3XLZHE60wAk0EsuJO8A25+uWSB6ILQeRSYYmGea/WIf6kd noone@throwaway.example.com"
19 |
20 | roles:
21 | - ansible-users
22 |
23 | - hosts: localhost
24 | remote_user: root
25 | vars:
26 | users:
27 | - name: Ansible Test User2
28 | username: ansibletestuser2
29 | uid: 2223
30 | groups: [users, bin]
31 | shell: /bin/sh
32 | home: /home/otherdirectory
33 | profile: |
34 | alias ll='ls -lah'
35 | alias cp='cp -iv'
36 | ssh_key:
37 | - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVpUJQCOaPg3p5xro9e+1fkGRWNOGrrExiKMqTE91Fwu349bxfMnMzRS0PAERouR9EEL+Ee4Yzhav/uNc35eCtXzACtluXnAncMrQj6pM3IqASynhvXTygHljmcMbBSDQtLrTZeW+YzIcOgk5UM1yBi26WoUYva2aCr9IRvKdYreAK08OiMdZedpOye0ZdvIYJGcyITwc6YMmrAhP7jZlrk/mDEkf2a4eBp+475o7MJtaC9npqYkToM8vqvx5AGEKqXt7/f1/paOY7KsR+VGPQy6k2RkXjWBsXPesZ3d3XLZHE60wAk0EsuJO8A25+uWSB6ILQeRSYYmGea/WIf6kd noone@throwaway.example.com"
38 |
39 | roles:
40 | - ansible-users
41 |
42 | - hosts: localhost
43 | remote_user: root
44 | vars:
45 | users_create_per_user_group: false
46 | users_group: ansibletestgroup
47 | groups_to_create:
48 | - name: ansibletestgroup1
49 | gid: 4001
50 | users:
51 | - name: Ansible Test User3
52 | username: ansibletestuser3
53 | uid: 2224
54 | group: ansibletestgroup1
55 | groups: [users, bin]
56 | shell: /bin/sh
57 | profile: |
58 | alias ll='ls -lah'
59 | alias cp='cp -iv'
60 | ssh_key:
61 | - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVpUJQCOaPg3p5xro9e+1fkGRWNOGrrExiKMqTE91Fwu349bxfMnMzRS0PAERouR9EEL+Ee4Yzhav/uNc35eCtXzACtluXnAncMrQj6pM3IqASynhvXTygHljmcMbBSDQtLrTZeW+YzIcOgk5UM1yBi26WoUYva2aCr9IRvKdYreAK08OiMdZedpOye0ZdvIYJGcyITwc6YMmrAhP7jZlrk/mDEkf2a4eBp+475o7MJtaC9npqYkToM8vqvx5AGEKqXt7/f1/paOY7KsR+VGPQy6k2RkXjWBsXPesZ3d3XLZHE60wAk0EsuJO8A25+uWSB6ILQeRSYYmGea/WIf6kd noone@throwaway.example.com"
62 |
63 | roles:
64 | - ansible-users
65 |
66 | - hosts: localhost
67 | remote_user: root
68 | vars:
69 | users_create_per_user_group: false
70 | users_group: users
71 | users:
72 | - name: Ansible Test User4
73 | username: ansibletestuser4
74 | uid: 2225
75 | groups: [users, bin]
76 | shell: /bin/sh
77 | home: /home/otherdirectory1
78 | profile: |
79 | alias ll='ls -lah'
80 | alias cp='cp -iv'
81 | ssh_key:
82 | - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVpUJQCOaPg3p5xro9e+1fkGRWNOGrrExiKMqTE91Fwu349bxfMnMzRS0PAERouR9EEL+Ee4Yzhav/uNc35eCtXzACtluXnAncMrQj6pM3IqASynhvXTygHljmcMbBSDQtLrTZeW+YzIcOgk5UM1yBi26WoUYva2aCr9IRvKdYreAK08OiMdZedpOye0ZdvIYJGcyITwc6YMmrAhP7jZlrk/mDEkf2a4eBp+475o7MJtaC9npqYkToM8vqvx5AGEKqXt7/f1/paOY7KsR+VGPQy6k2RkXjWBsXPesZ3d3XLZHE60wAk0EsuJO8A25+uWSB6ILQeRSYYmGea/WIf6kd noone@throwaway.example.com"
83 |
84 | roles:
85 | - ansible-users
86 |
87 | - hosts: localhost
88 | remote_user: root
89 | vars:
90 | users:
91 | - name: Ansible Test User5
92 | username: ansibletestuser5
93 | uid: 2226
94 | group: ansibletestgroup
95 | groups: [users, bin]
96 | shell: /bin/sh
97 | profile: |
98 | alias ll='ls -lah'
99 | alias cp='cp -iv'
100 | ssh_key:
101 | - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVpUJQCOaPg3p5xro9e+1fkGRWNOGrrExiKMqTE91Fwu349bxfMnMzRS0PAERouR9EEL+Ee4Yzhav/uNc35eCtXzACtluXnAncMrQj6pM3IqASynhvXTygHljmcMbBSDQtLrTZeW+YzIcOgk5UM1yBi26WoUYva2aCr9IRvKdYreAK08OiMdZedpOye0ZdvIYJGcyITwc6YMmrAhP7jZlrk/mDEkf2a4eBp+475o7MJtaC9npqYkToM8vqvx5AGEKqXt7/f1/paOY7KsR+VGPQy6k2RkXjWBsXPesZ3d3XLZHE60wAk0EsuJO8A25+uWSB6ILQeRSYYmGea/WIf6kd noone@throwaway.example.com"
102 |
103 | roles:
104 | - ansible-users
105 |
--------------------------------------------------------------------------------
/roles/app/README.md:
--------------------------------------------------------------------------------
1 | app
2 | ===
3 |
4 | Deploys a [Python/Flask](http://flask.pocoo.org) [web application](https://github.com/phips/flask_app) from an artifact (supplied by Jenkins) and fronts it with nginx+WSGI.
5 |
6 | This role forms a major part of my demonstrations, and has been tinkered with and expanded over time. A customer once asked me if [Ansible Tower](ansible.com/tower) provided an authorisation system for code deployments - it doesn't, but this role mimics behaviour that could be made to work like that. In short it does a check against a third party web service for permission - in the context of the demos this is simply a curl against an nginx server running on another host. If the curl fails then deployment will be set to True anyway, so you don't need to put this part of the puzzle into your own setups.
7 |
8 | Requirements
9 | ------------
10 |
11 | You need a working Jenkins machine to pull the artifact from, and if you want to mimic talking to a third party for 'deployment permission' then you need a web server hosting files in its root directory named after the hosts you're deploying to. The files should simply contain 'True' or 'False'.
12 |
13 | Role Variables
14 | --------------
15 |
16 | app_path: /srv/web_app
17 | app_remote_web: web.box
18 | app_jenkins_host: jenkins.box
19 | app_jenkins_port: 8080
20 | app_jenkins_job: webapp_dev
21 |
22 |
23 | Dependencies
24 | ------------
25 |
26 | Not strictly required, but I use [Benno Joy's nginx role](https://galaxy.ansible.com/bennojoy/nginx/) from [Galaxy](galaxy.ansible.com) to set up my standalone nginx server.
27 |
28 | Example Playbook
29 | ----------------
30 |
31 | - hosts: appservers
32 | roles:
33 | - { role: app }
34 |
35 | License
36 | -------
37 |
38 | BSD
39 |
40 | Author Information
41 | ------------------
42 |
43 | Mark Phillips
44 |
45 |
46 |
--------------------------------------------------------------------------------
/roles/app/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for app
3 |
4 | app_path: /srv/web_app
5 | app_remote_web: web.box
6 | app_jenkins_host: jenkins.box
7 | app_jenkins_port: 8080
8 | app_jenkins_job: webapp_dev
9 |
--------------------------------------------------------------------------------
/roles/app/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for app
3 |
4 | - name: restart webapp service
5 | service:
6 | name: webapp
7 | state: restarted
8 |
9 |
--------------------------------------------------------------------------------
/roles/app/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: your name
4 | description:
5 | company: your company (optional)
6 | # Some suggested licenses:
7 | # - BSD (default)
8 | # - MIT
9 | # - GPLv2
10 | # - GPLv3
11 | # - Apache
12 | # - CC-BY
13 | license: license (GPLv2, CC-BY, etc)
14 | min_ansible_version: 1.2
15 | #
16 | # Below are all platforms currently available. Just uncomment
17 | # the ones that apply to your role. If you don't see your
18 | # platform on this list, let us know and we'll get it added!
19 | #
20 | #platforms:
21 | #- name: EL
22 | # versions:
23 | # - all
24 | # - 5
25 | # - 6
26 | # - 7
27 | #- name: GenericUNIX
28 | # versions:
29 | # - all
30 | # - any
31 | #- name: Fedora
32 | # versions:
33 | # - all
34 | # - 16
35 | # - 17
36 | # - 18
37 | # - 19
38 | # - 20
39 | #- name: SmartOS
40 | # versions:
41 | # - all
42 | # - any
43 | #- name: opensuse
44 | # versions:
45 | # - all
46 | # - 12.1
47 | # - 12.2
48 | # - 12.3
49 | # - 13.1
50 | # - 13.2
51 | #- name: Amazon
52 | # versions:
53 | # - all
54 | # - 2013.03
55 | # - 2013.09
56 | #- name: GenericBSD
57 | # versions:
58 | # - all
59 | # - any
60 | #- name: FreeBSD
61 | # versions:
62 | # - all
63 | # - 8.0
64 | # - 8.1
65 | # - 8.2
66 | # - 8.3
67 | # - 8.4
68 | # - 9.0
69 | # - 9.1
70 | # - 9.1
71 | # - 9.2
72 | #- name: Ubuntu
73 | # versions:
74 | # - all
75 | # - lucid
76 | # - maverick
77 | # - natty
78 | # - oneiric
79 | # - precise
80 | # - quantal
81 | # - raring
82 | # - saucy
83 | # - trusty
84 | #- name: SLES
85 | # versions:
86 | # - all
87 | # - 10SP3
88 | # - 10SP4
89 | # - 11
90 | # - 11SP1
91 | # - 11SP2
92 | # - 11SP3
93 | #- name: GenericLinux
94 | # versions:
95 | # - all
96 | # - any
97 | #- name: Debian
98 | # versions:
99 | # - all
100 | # - etch
101 | # - lenny
102 | # - squeeze
103 | # - wheezy
104 | #
105 | # Below are all categories currently available. Just as with
106 | # the platforms above, uncomment those that apply to your role.
107 | #
108 | #categories:
109 | #- cloud
110 | #- cloud:ec2
111 | #- cloud:gce
112 | #- cloud:rax
113 | #- clustering
114 | #- database
115 | #- database:nosql
116 | #- database:sql
117 | #- development
118 | #- monitoring
119 | #- networking
120 | #- packaging
121 | #- system
122 | #- web
123 | dependencies: []
124 | # List your role dependencies here, one per line. Only
125 | # dependencies available via galaxy should be listed here.
126 | # Be sure to remove the '[]' above if you add dependencies
127 | # to this list.
128 |
129 |
--------------------------------------------------------------------------------
/roles/app/tasks/deploy.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # deploy app
3 |
4 | - name: Set selinux permissive (disgraceful hack)
5 | selinux:
6 | policy: targeted
7 | state: permissive
8 |
9 | - name: Ensure packages are installed
10 | yum:
11 | name: "{{ item }}"
12 | state: present
13 | with_items:
14 | - python-lxml
15 | - nginx
16 |
17 | - name: Ensure dir for app path exists
18 | file:
19 | path: "{{ app_path }}"
20 | state: directory
21 | owner: vagrant
22 | group: vagrant
23 |
24 | - name: Download application artifact
25 | get_url:
26 | url: http://{{ app_jenkins_host }}:{{ app_jenkins_port }}/job/{{ app_jenkins_job }}/lastSuccessfulBuild/artifact/dist/app.tgz
27 | dest: /var/tmp
28 |
29 | - name: Unarchive artifact
30 | unarchive:
31 | copy: false
32 | dest: "{{ app_path }}"
33 | src: /var/tmp/app.tgz
34 | owner: vagrant
35 | group: vagrant
36 |
37 | - name: Set up service definition
38 | template:
39 | src: webapp.service.j2
40 | dest: /etc/systemd/system/webapp.service
41 | owner: root
42 | group: root
43 | mode: 0644
44 | notify:
45 | - restart webapp service
46 |
47 | - name: Ensure the app service is running
48 | service:
49 | name: webapp
50 | state: started
51 | enabled: yes
52 |
53 | - name: Configure nginx to front the app
54 | template:
55 | src: nginx.conf.j2
56 | dest: /etc/nginx/nginx.conf
57 | owner: root
58 | group: root
59 | mode: 0644
60 |
61 | - name: Ensure nginx is running
62 | service:
63 | name: nginx
64 | state: started
65 | enabled: yes
66 |
67 | - name: Display machine IP
68 | debug:
69 | msg: "{{ ansible_default_ipv4.address }}"
70 |
71 |
--------------------------------------------------------------------------------
/roles/app/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for app
3 |
4 | - name: Check for OS support
5 | fail:
6 | msg: "OS is not supported"
7 | when: ansible_os_family != 'RedHat'
8 |
9 | - block:
10 | - set_fact:
11 | deploy: "{{ lookup('pipe', 'curl -m2 -s {{ app_remote_web }}/{{ inventory_hostname }}') }}"
12 | rescue:
13 | - set_fact:
14 | deploy: True
15 |
16 | - include: deploy.yml
17 | when: deploy
18 | register: deployed
19 |
20 | - fail:
21 | msg: "Deployment to {{ inventory_hostname }} was not permitted by policy"
22 | when: deployed|skipped
23 |
--------------------------------------------------------------------------------
/roles/app/templates/index.html.j2:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Informative test web page
5 |
6 |
11 |
12 |
13 |
14 |
15 | hostname: {{ ansible_ec2_public_hostname }}
16 |
17 | instance_id: {{ ansible_ec2_instance_id }}
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/roles/app/templates/nginx.conf.j2:
--------------------------------------------------------------------------------
1 | # {{ ansible_managed }}
2 |
3 | user nginx;
4 | worker_processes auto;
5 | error_log /var/log/nginx/error.log;
6 | pid /run/nginx.pid;
7 |
8 | events {
9 | worker_connections 1024;
10 | }
11 |
12 | http {
13 | log_format main '$remote_addr - $remote_user [$time_local] "$request" '
14 | '$status $body_bytes_sent "$http_referer" '
15 | '"$http_user_agent" "$http_x_forwarded_for"';
16 |
17 | access_log /var/log/nginx/access.log main;
18 |
19 | sendfile on;
20 | tcp_nopush on;
21 | tcp_nodelay on;
22 | keepalive_timeout 65;
23 | types_hash_max_size 2048;
24 |
25 | include /etc/nginx/mime.types;
26 | default_type application/octet-stream;
27 |
28 | server {
29 | listen 80;
30 | server_name localhost {{ ansible_default_ipv4.address }};
31 | charset utf-8;
32 | client_max_body_size 75M;
33 |
34 | location / { try_files $uri @yourapplication; }
35 | location @yourapplication {
36 | include uwsgi_params;
37 | uwsgi_pass unix:{{ app_path }}/uwsgi.sock;
38 | }
39 |
40 | error_page 404 /404.html;
41 | location = /40x.html {
42 | }
43 |
44 | error_page 500 502 503 504 /50x.html;
45 | location = /50x.html {
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/roles/app/templates/uwsgi.ini.j2:
--------------------------------------------------------------------------------
1 | # {{ ansible_managed }}
2 | [uwsgi]
3 | module = run_prod
4 | callable = app
5 | pythonpath = {{ app_path }}
6 | virtualenv = {{ app_path }}/support
7 | master = true
8 | processes = 2
9 | socket = uwsgi.sock
10 | chmod-socket = 666
11 | vacuum = true
12 | die-on-term = true
13 |
--------------------------------------------------------------------------------
/roles/app/templates/webapp.service.j2:
--------------------------------------------------------------------------------
1 | # {{ ansible_managed }}
2 | [Unit]
3 | Description=uWSGI instance to serve Flask app
4 | After=network.target
5 |
6 | [Service]
7 | User=vagrant
8 | Group=vagrant
9 | WorkingDirectory={{ app_path }}
10 | Environment="PATH={{ app_path }}/support/bin"
11 | ExecStart={{ app_path }}/support/bin/uwsgi --ini uwsgi.ini
12 |
13 | [Install]
14 | WantedBy=multi-user.target
15 |
16 |
--------------------------------------------------------------------------------
/roles/app/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for app
3 |
--------------------------------------------------------------------------------
/roles/disk/README.md:
--------------------------------------------------------------------------------
1 | disk
2 | ====
3 |
4 | Find large files.
5 |
6 | Requirements
7 | ------------
8 |
9 |
10 | Role Variables
11 | --------------
12 |
13 |
14 | Dependencies
15 | ------------
16 |
17 |
18 | Example Playbook
19 | ----------------
20 |
21 | - hosts: servers
22 | roles:
23 | - { role: disk, disk_path: /apps }
24 |
25 | License
26 | -------
27 |
28 | BSD
29 |
30 | Author Information
31 | ------------------
32 |
33 | Mark Phillips
34 |
35 |
36 | Tower Callback
37 | --------------
38 |
39 | 15 50416894-383e-41bb-8e95-64a8fba39869
40 |
--------------------------------------------------------------------------------
/roles/disk/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for disk
3 |
4 | - name: Find large files
5 | command: /bin/find "{{ disk_path | default('/') }}" -size +{{ disk_min_size_check | default('1') }}M -ls
6 | register: output
7 |
8 | - name: Output
9 | debug:
10 | var: output.stdout_lines
11 | when: output.stdout != ''
12 |
--------------------------------------------------------------------------------
/roles/epel/README.md:
--------------------------------------------------------------------------------
1 | epel
2 | ====
3 |
4 | Enable EPEL - Extra Packages for Enterprise Linux.
5 |
6 | Requirements
7 | ------------
8 |
9 |
10 | Role Variables
11 | --------------
12 |
13 | epel_rpm: the full URL to epel-release.
14 |
15 | Set in in vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml to enable different OS release versions.
16 |
17 | Dependencies
18 | ------------
19 |
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | - hosts: servers
25 | roles:
26 | - { role: epel }
27 |
28 | License
29 | -------
30 |
31 | BSD
32 |
33 | Author Information
34 | ------------------
35 |
36 | Mark Phillips
37 | [Probably](http://probably.co.uk)
38 |
--------------------------------------------------------------------------------
/roles/epel/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for epel
3 |
--------------------------------------------------------------------------------
/roles/epel/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for epel
3 |
--------------------------------------------------------------------------------
/roles/epel/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: your name
4 | description:
5 | company: your company (optional)
6 | # Some suggested licenses:
7 | # - BSD (default)
8 | # - MIT
9 | # - GPLv2
10 | # - GPLv3
11 | # - Apache
12 | # - CC-BY
13 | license: license (GPLv2, CC-BY, etc)
14 | min_ansible_version: 1.2
15 | #
16 | # Below are all platforms currently available. Just uncomment
17 | # the ones that apply to your role. If you don't see your
18 | # platform on this list, let us know and we'll get it added!
19 | #
20 | #platforms:
21 | #- name: EL
22 | # versions:
23 | # - all
24 | # - 5
25 | # - 6
26 | # - 7
27 | #- name: GenericUNIX
28 | # versions:
29 | # - all
30 | # - any
31 | #- name: Fedora
32 | # versions:
33 | # - all
34 | # - 16
35 | # - 17
36 | # - 18
37 | # - 19
38 | # - 20
39 | #- name: opensuse
40 | # versions:
41 | # - all
42 | # - 12.1
43 | # - 12.2
44 | # - 12.3
45 | # - 13.1
46 | # - 13.2
47 | #- name: Amazon
48 | # versions:
49 | # - all
50 | # - 2013.03
51 | # - 2013.09
52 | #- name: GenericBSD
53 | # versions:
54 | # - all
55 | # - any
56 | #- name: FreeBSD
57 | # versions:
58 | # - all
59 | # - 8.0
60 | # - 8.1
61 | # - 8.2
62 | # - 8.3
63 | # - 8.4
64 | # - 9.0
65 | # - 9.1
66 | # - 9.1
67 | # - 9.2
68 | #- name: Ubuntu
69 | # versions:
70 | # - all
71 | # - lucid
72 | # - maverick
73 | # - natty
74 | # - oneiric
75 | # - precise
76 | # - quantal
77 | # - raring
78 | # - saucy
79 | # - trusty
80 | #- name: SLES
81 | # versions:
82 | # - all
83 | # - 10SP3
84 | # - 10SP4
85 | # - 11
86 | # - 11SP1
87 | # - 11SP2
88 | # - 11SP3
89 | #- name: GenericLinux
90 | # versions:
91 | # - all
92 | # - any
93 | #- name: Debian
94 | # versions:
95 | # - all
96 | # - etch
97 | # - lenny
98 | # - squeeze
99 | # - wheezy
100 | #
101 | # Below are all categories currently available. Just as with
102 | # the platforms above, uncomment those that apply to your role.
103 | #
104 | #categories:
105 | #- cloud
106 | #- cloud:ec2
107 | #- cloud:gce
108 | #- cloud:rax
109 | #- clustering
110 | #- database
111 | #- database:nosql
112 | #- database:sql
113 | #- development
114 | #- monitoring
115 | #- networking
116 | #- packaging
117 | #- system
118 | #- web
119 | dependencies: []
120 | # List your role dependencies here, one per line. Only
121 | # dependencies available via galaxy should be listed here.
122 | # Be sure to remove the '[]' above if you add dependencies
123 | # to this list.
124 |
125 |
--------------------------------------------------------------------------------
/roles/epel/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for epel
3 |
4 | - name: Include OS major ver vars file
5 | include_vars: "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml"
6 |
7 | - name: Ensure EPEL is installed
8 | shell: rpm -q epel-release || yum install -y {{ epel_rpm }}
9 | register: epel_check
10 | changed_when: '"not installed" in epel_check.stdout'
11 |
12 |
--------------------------------------------------------------------------------
/roles/epel/vars/RedHat-6.yml:
--------------------------------------------------------------------------------
1 | ---
2 | epel_rpm: http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
3 |
--------------------------------------------------------------------------------
/roles/epel/vars/RedHat-7.yml:
--------------------------------------------------------------------------------
1 | ---
2 | epel_rpm: http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
3 |
4 |
--------------------------------------------------------------------------------
/roles/epel/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for epel
3 |
--------------------------------------------------------------------------------
/roles/firewall/README.md:
--------------------------------------------------------------------------------
1 | Firewall
2 | =========
3 |
4 | Only for CentOS 7 - set default zone
5 |
6 | Requirements
7 | ------------
8 |
9 |
10 | Role Variables
11 | --------------
12 |
13 | firewall_default_zone
14 |
15 | Dependencies
16 | ------------
17 |
18 |
19 | Example Playbook
20 | ----------------
21 |
22 | - hosts: servers
23 | roles:
24 | - { role: firewall, firewall_default_zone: trusted }
25 |
26 | License
27 | -------
28 |
29 | BSD
30 |
31 | Author Information
32 | ------------------
33 |
34 | Mark Phillips
35 | http://probably.co.uk
36 |
--------------------------------------------------------------------------------
/roles/firewall/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for firewall
3 |
4 | firewall_default_zone: trusted
5 |
--------------------------------------------------------------------------------
/roles/firewall/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for firewall
3 |
--------------------------------------------------------------------------------
/roles/firewall/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: your name
4 | description:
5 | company: your company (optional)
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 | # Some suggested licenses:
10 | # - BSD (default)
11 | # - MIT
12 | # - GPLv2
13 | # - GPLv3
14 | # - Apache
15 | # - CC-BY
16 | license: license (GPLv2, CC-BY, etc)
17 | min_ansible_version: 1.2
18 | #
19 | # Below are all platforms currently available. Just uncomment
20 | # the ones that apply to your role. If you don't see your
21 | # platform on this list, let us know and we'll get it added!
22 | #
23 | #platforms:
24 | #- name: EL
25 | # versions:
26 | # - all
27 | # - 5
28 | # - 6
29 | # - 7
30 | #- name: GenericUNIX
31 | # versions:
32 | # - all
33 | # - any
34 | #- name: Fedora
35 | # versions:
36 | # - all
37 | # - 16
38 | # - 17
39 | # - 18
40 | # - 19
41 | # - 20
42 | # - 21
43 | # - 22
44 | #- name: Windows
45 | # versions:
46 | # - all
47 | # - 2012R2
48 | #- name: SmartOS
49 | # versions:
50 | # - all
51 | # - any
52 | #- name: opensuse
53 | # versions:
54 | # - all
55 | # - 12.1
56 | # - 12.2
57 | # - 12.3
58 | # - 13.1
59 | # - 13.2
60 | #- name: Amazon
61 | # versions:
62 | # - all
63 | # - 2013.03
64 | # - 2013.09
65 | #- name: GenericBSD
66 | # versions:
67 | # - all
68 | # - any
69 | #- name: FreeBSD
70 | # versions:
71 | # - all
72 | # - 8.0
73 | # - 8.1
74 | # - 8.2
75 | # - 8.3
76 | # - 8.4
77 | # - 9.0
78 | # - 9.1
79 | # - 9.1
80 | # - 9.2
81 | #- name: Ubuntu
82 | # versions:
83 | # - all
84 | # - lucid
85 | # - maverick
86 | # - natty
87 | # - oneiric
88 | # - precise
89 | # - quantal
90 | # - raring
91 | # - saucy
92 | # - trusty
93 | # - utopic
94 | # - vivid
95 | #- name: SLES
96 | # versions:
97 | # - all
98 | # - 10SP3
99 | # - 10SP4
100 | # - 11
101 | # - 11SP1
102 | # - 11SP2
103 | # - 11SP3
104 | #- name: GenericLinux
105 | # versions:
106 | # - all
107 | # - any
108 | #- name: Debian
109 | # versions:
110 | # - all
111 | # - etch
112 | # - jessie
113 | # - lenny
114 | # - squeeze
115 | # - wheezy
116 | #
117 | # Below are all categories currently available. Just as with
118 | # the platforms above, uncomment those that apply to your role.
119 | #
120 | #categories:
121 | #- cloud
122 | #- cloud:ec2
123 | #- cloud:gce
124 | #- cloud:rax
125 | #- clustering
126 | #- database
127 | #- database:nosql
128 | #- database:sql
129 | #- development
130 | #- monitoring
131 | #- networking
132 | #- packaging
133 | #- system
134 | #- web
135 | dependencies: []
136 | # List your role dependencies here, one per line.
137 | # Be sure to remove the '[]' above if you add dependencies
138 | # to this list.
139 |
140 |
--------------------------------------------------------------------------------
/roles/firewall/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for firewall
3 |
4 | - name: Get default zone
5 | command: firewall-cmd --get-default-zone
6 | register: output
7 | changed_when: false
8 |
9 | - name: Set default zone
10 | command: firewall-cmd --set-default-zone {{ firewall_default_zone }}
11 | when: firewall_default_zone not in output.stdout
12 |
--------------------------------------------------------------------------------
/roles/firewall/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for firewall
3 |
--------------------------------------------------------------------------------
/roles/gather_debug/README.md:
--------------------------------------------------------------------------------
1 | gather_debug
2 | ============
3 |
4 | A rather simplistic role to run some commands and dump output.
5 |
6 | Requirements
7 | ------------
8 |
9 | Role Variables
10 | --------------
11 |
12 | Dependencies
13 | ------------
14 |
15 | Example Playbook
16 | ----------------
17 |
18 | - hosts: servers
19 | roles:
20 | - { role: gather_debug }
21 |
22 | License
23 | -------
24 |
25 | BSD
26 |
27 | Further thoughts
28 | ----------------
29 |
30 | Lots of this could be turned into variables for flexiblity, and you could even
31 | use regexs to 'search' the stdout of commands for particular values. Say,
32 | higher than X%, or whatever.
33 |
34 |
35 | Author Information
36 | ------------------
37 |
38 | Mark Phillips
39 |
--------------------------------------------------------------------------------
/roles/gather_debug/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for gather_debug
--------------------------------------------------------------------------------
/roles/gather_debug/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for gather_debug
3 |
4 | - name: Gather recent vmstat info
5 | command: /bin/vmstat 1 5
6 | register: vmstat
7 |
8 | - name: Gather top CPU hogs
9 | command: ps -eo user,pid,size,pcpu,cmd --sort=-pcpu
10 | register: pscpu
11 |
12 | - name: Gather top memory hogs
13 | command: ps -eo user,pid,size,pcpu,cmd --sort=-size
14 | register: pssize
15 |
16 | - name: Swap + wait states
17 | debug:
18 | var: vmstat.stdout_lines
19 |
20 | - name: Top 3 CPU hogs
21 | debug:
22 | var: pscpu.stdout_lines[:4]
23 |
24 | - name: Top 3 memory hogs
25 | debug:
26 | var: pssize.stdout_lines[:4]
27 |
--------------------------------------------------------------------------------
/roles/hosts/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | ========
3 |
4 | Sets the hostname on a target machine, assigning the name as defined in inventory.
5 |
6 | This may be expanded further at some point to do other 'host related' stuff.
7 |
8 | Requirements
9 | ------------
10 |
11 | Inventory name MUST be a valid hostname - if it is an IP address the role will
12 | skip setting the name. Logic skips an IP address regex; effectively `|match` is
13 | using python [re.match](https://docs.python.org/2/library/re.html).
14 |
15 | When DNS is lacking, put the name you want to use in the inventory file, then
16 | simply use ansible_ssh_host=IP.ADD.RES.SS
17 |
18 | Role Variables
19 | --------------
20 |
21 |
22 | Dependencies
23 | ------------
24 |
25 |
26 | Example Playbook
27 | -------------------------
28 |
29 | - hosts: servers
30 | roles:
31 | - { role: hosts }
32 |
33 | License
34 | -------
35 |
36 | BSD
37 |
38 | Author Information
39 | ------------------
40 |
41 | Mark Phillips
42 |
--------------------------------------------------------------------------------
/roles/hosts/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for hosts
3 |
4 | hosts_pop_hosts: False
5 |
--------------------------------------------------------------------------------
/roles/hosts/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for hosts
3 |
--------------------------------------------------------------------------------
/roles/hosts/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: your name
4 | description:
5 | company: your company (optional)
6 | # Some suggested licenses:
7 | # - BSD (default)
8 | # - MIT
9 | # - GPLv2
10 | # - GPLv3
11 | # - Apache
12 | # - CC-BY
13 | license: license (GPLv2, CC-BY, etc)
14 | min_ansible_version: 1.2
15 | #
16 | # Below are all platforms currently available. Just uncomment
17 | # the ones that apply to your role. If you don't see your
18 | # platform on this list, let us know and we'll get it added!
19 | #
20 | #platforms:
21 | #- name: EL
22 | # versions:
23 | # - all
24 | # - 5
25 | # - 6
26 | #- name: GenericUNIX
27 | # versions:
28 | # - all
29 | # - any
30 | #- name: Fedora
31 | # versions:
32 | # - all
33 | # - 16
34 | # - 17
35 | # - 18
36 | # - 19
37 | # - 20
38 | #- name: opensuse
39 | # versions:
40 | # - all
41 | # - 12.1
42 | # - 12.2
43 | # - 12.3
44 | # - 13.1
45 | # - 13.2
46 | #- name: Amazon
47 | # versions:
48 | # - all
49 | # - 2013.03
50 | # - 2013.09
51 | #- name: GenericBSD
52 | # versions:
53 | # - all
54 | # - any
55 | #- name: FreeBSD
56 | # versions:
57 | # - all
58 | # - 8.0
59 | # - 8.1
60 | # - 8.2
61 | # - 8.3
62 | # - 8.4
63 | # - 9.0
64 | # - 9.1
65 | # - 9.1
66 | # - 9.2
67 | #- name: Ubuntu
68 | # versions:
69 | # - all
70 | # - lucid
71 | # - maverick
72 | # - natty
73 | # - oneiric
74 | # - precise
75 | # - quantal
76 | # - raring
77 | # - saucy
78 | # - trusty
79 | #- name: SLES
80 | # versions:
81 | # - all
82 | # - 10SP3
83 | # - 10SP4
84 | # - 11
85 | # - 11SP1
86 | # - 11SP2
87 | # - 11SP3
88 | #- name: GenericLinux
89 | # versions:
90 | # - all
91 | # - any
92 | #- name: Debian
93 | # versions:
94 | # - all
95 | # - etch
96 | # - lenny
97 | # - squeeze
98 | # - wheezy
99 | #
100 | # Below are all categories currently available. Just as with
101 | # the platforms above, uncomment those that apply to your role.
102 | #
103 | #categories:
104 | #- cloud
105 | #- cloud:ec2
106 | #- cloud:gce
107 | #- cloud:rax
108 | #- database
109 | #- database:nosql
110 | #- database:sql
111 | #- development
112 | #- monitoring
113 | #- networking
114 | #- packaging
115 | #- system
116 | #- web
117 | dependencies: []
118 | # List your role dependencies here, one per line. Only
119 | # dependencies available via galaxy should be listed here.
120 | # Be sure to remove the '[]' above if you add dependencies
121 | # to this list.
122 |
123 |
--------------------------------------------------------------------------------
/roles/hosts/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vim: set ft=ansible:
3 |
4 | - name: Ensure hostname set
5 | hostname:
6 | name: "{{ inventory_hostname }}"
7 | when: not inventory_hostname|match('(\d{1,3}\.){3}\d{1,3}')
8 |
9 | - name: Ensure hostname is in /etc/hosts
10 | lineinfile:
11 | dest: /etc/hosts
12 | regexp: "^{{ ansible_default_ipv4.address }}.+$"
13 | line: "{{ ansible_default_ipv4.address }} {{ inventory_hostname }}"
14 |
15 | - name: Ensure /etc/hosts populated
16 | template:
17 | src: hosts.j2
18 | dest: /etc/hosts
19 | owner: root
20 | group: root
21 | mode: 0644
22 | when: hosts_pop_hosts
23 |
--------------------------------------------------------------------------------
/roles/hosts/templates/hosts.j2:
--------------------------------------------------------------------------------
1 | # {{ ansible_managed }}
2 | 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
3 | ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
4 |
5 | {% for host in groups.all %}
6 | {% if hostvars[host]['ansible_default_ipv4'] is defined %}
7 | {{ hostvars[host]['ansible_default_ipv4']['address'] }} {{ host }}
8 | {% endif %}
9 | {% endfor %}
10 |
11 |
--------------------------------------------------------------------------------
/roles/hosts/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for hosts
3 |
--------------------------------------------------------------------------------
/roles/issue/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | Configure /etc/issue - typically a template.
5 |
6 | Requirements
7 | ------------
8 |
9 | None.
10 |
11 | Role Variables
12 | --------------
13 |
14 | None.
15 |
16 | Dependencies
17 | ------------
18 |
19 | None.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | - hosts: servers
25 | roles:
26 | - { role: issue }
27 |
28 | License
29 | -------
30 |
31 | BSD
32 |
33 | Author Information
34 | ------------------
35 |
36 | Mark Phillips
37 |
38 |
--------------------------------------------------------------------------------
/roles/issue/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for issue
3 |
--------------------------------------------------------------------------------
/roles/issue/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for issue
3 |
--------------------------------------------------------------------------------
/roles/issue/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: your name
4 | description:
5 | company: your company (optional)
6 | # Some suggested licenses:
7 | # - BSD (default)
8 | # - MIT
9 | # - GPLv2
10 | # - GPLv3
11 | # - Apache
12 | # - CC-BY
13 | license: license (GPLv2, CC-BY, etc)
14 | min_ansible_version: 1.2
15 | #
16 | # Below are all platforms currently available. Just uncomment
17 | # the ones that apply to your role. If you don't see your
18 | # platform on this list, let us know and we'll get it added!
19 | #
20 | #platforms:
21 | #- name: EL
22 | # versions:
23 | # - all
24 | # - 5
25 | # - 6
26 | # - 7
27 | #- name: GenericUNIX
28 | # versions:
29 | # - all
30 | # - any
31 | #- name: Fedora
32 | # versions:
33 | # - all
34 | # - 16
35 | # - 17
36 | # - 18
37 | # - 19
38 | # - 20
39 | #- name: opensuse
40 | # versions:
41 | # - all
42 | # - 12.1
43 | # - 12.2
44 | # - 12.3
45 | # - 13.1
46 | # - 13.2
47 | #- name: Amazon
48 | # versions:
49 | # - all
50 | # - 2013.03
51 | # - 2013.09
52 | #- name: GenericBSD
53 | # versions:
54 | # - all
55 | # - any
56 | #- name: FreeBSD
57 | # versions:
58 | # - all
59 | # - 8.0
60 | # - 8.1
61 | # - 8.2
62 | # - 8.3
63 | # - 8.4
64 | # - 9.0
65 | # - 9.1
66 | # - 9.1
67 | # - 9.2
68 | #- name: Ubuntu
69 | # versions:
70 | # - all
71 | # - lucid
72 | # - maverick
73 | # - natty
74 | # - oneiric
75 | # - precise
76 | # - quantal
77 | # - raring
78 | # - saucy
79 | # - trusty
80 | #- name: SLES
81 | # versions:
82 | # - all
83 | # - 10SP3
84 | # - 10SP4
85 | # - 11
86 | # - 11SP1
87 | # - 11SP2
88 | # - 11SP3
89 | #- name: GenericLinux
90 | # versions:
91 | # - all
92 | # - any
93 | #- name: Debian
94 | # versions:
95 | # - all
96 | # - etch
97 | # - lenny
98 | # - squeeze
99 | # - wheezy
100 | #
101 | # Below are all categories currently available. Just as with
102 | # the platforms above, uncomment those that apply to your role.
103 | #
104 | #categories:
105 | #- cloud
106 | #- cloud:ec2
107 | #- cloud:gce
108 | #- cloud:rax
109 | #- clustering
110 | #- database
111 | #- database:nosql
112 | #- database:sql
113 | #- development
114 | #- monitoring
115 | #- networking
116 | #- packaging
117 | #- system
118 | #- web
119 | dependencies: []
120 | # List your role dependencies here, one per line. Only
121 | # dependencies available via galaxy should be listed here.
122 | # Be sure to remove the '[]' above if you add dependencies
123 | # to this list.
124 |
125 |
--------------------------------------------------------------------------------
/roles/issue/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for issue
3 |
4 | - name: Gather EC2 facts
5 | ec2_facts:
6 | when: ansible_distribution == 'Amazon'
7 |
8 | - name: Ensure /etc/issue is present
9 | template:
10 | src: "issue-{{ ansible_distribution }}.j2"
11 | dest: /etc/issue
12 | owner: root
13 | group: root
14 | mode: 0644
15 |
--------------------------------------------------------------------------------
/roles/issue/templates/issue-Amazon.j2:
--------------------------------------------------------------------------------
1 | _____________________
2 | < I've been Ansibled! >
3 | ---------------------
4 | \ ^__^
5 | \ (oo)\_______
6 | (__)\ )\/\
7 | ||----w |
8 | || ||
9 |
10 | Distro: {{ ansible_distribution }}
11 | IP: {{ ansible_ec2_public_ipv4 }} ID: {{ ansible_ec2_reservation_id }}
12 |
13 |
--------------------------------------------------------------------------------
/roles/issue/templates/issue-CentOS.j2:
--------------------------------------------------------------------------------
1 | Kernel \r on an \m
2 |
3 | Distro: {{ ansible_distribution }}
4 | IP: {{ ansible_default_ipv4.address }} MAC: {{ ansible_default_ipv4.macaddress }}
5 |
6 |
--------------------------------------------------------------------------------
/roles/issue/templates/issue-RedHat.j2:
--------------------------------------------------------------------------------
1 | Kernel \r on an \m
2 |
3 | IP: {{ ansible_default_ipv4.address }} MAC: {{ ansible_default_ipv4.macaddress }}
4 |
5 |
--------------------------------------------------------------------------------
/roles/issue/templates/issue-Ubuntu.j2:
--------------------------------------------------------------------------------
1 | Kernel \r on an \m
2 |
3 | IP: {{ ansible_default_ipv4.address }} MAC: {{ ansible_default_ipv4.macaddress }}
4 |
5 |
--------------------------------------------------------------------------------
/roles/issue/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for issue
3 |
--------------------------------------------------------------------------------
/roles/nginx/README.md:
--------------------------------------------------------------------------------
1 | nginx
2 | =====
3 |
4 | This role installs and configures the nginx web server. The user can specify
5 | any http configuration parameters they wish to apply their site. Any number of
6 | sites can be added with configurations of your choice.
7 |
8 | Requirements
9 | ------------
10 |
11 | This role requires Ansible 1.4 or higher and platform requirements are listed
12 | in the metadata file.
13 |
14 | Role Variables
15 | --------------
16 |
17 | The variables that can be passed to this role and a brief description about
18 | them are as follows.
19 |
20 | # The max clients allowed
21 | nginx_max_clients: 512
22 |
23 | # A hash of the http paramters. Note that any
24 | # valid nginx http paramters can be added here.
25 | # (see the nginx documentation for details.)
26 | nginx_http_params:
27 | sendfile: "on"
28 | tcp_nopush: "on"
29 | tcp_nodelay: "on"
30 | keepalive_timeout: "65"
31 | access_log: "/var/log/nginx/access.log"
32 | error_log: "/var/log/nginx/error.log"
33 |
34 | # A list of hashs that define the servers for nginx,
35 | # as with http parameters. Any valid server parameters
36 | # can be defined here.
37 | nginx_sites:
38 | - server:
39 | file_name: foo
40 | listen: 8080
41 | server_name: localhost
42 | root: "/tmp/site1"
43 | location1: {name: /, try_files: "$uri $uri/ /index.html"}
44 | location2: {name: /images/, try_files: "$uri $uri/ /index.html"}
45 | - server:
46 | file_name: bar
47 | listen: 9090
48 | server_name: ansible
49 | root: "/tmp/site2"
50 | location1: {name: /, try_files: "$uri $uri/ /index.html"}
51 | location2: {name: /images/, try_files: "$uri $uri/ /index.html"}
52 |
53 | Examples
54 | ========
55 |
56 | 1) Install nginx with HTTP directives of choices, but with no sites
57 | configured:
58 |
59 | - hosts: all
60 | roles:
61 | - {role: nginx,
62 | nginx_http_params: { sendfile: "on",
63 | access_log: "/var/log/nginx/access.log"},
64 | nginx_sites: none }
65 |
66 |
67 | 2) Install nginx with different HTTP directives than previous example, but no
68 | sites configured.
69 |
70 | - hosts: all
71 | roles:
72 | - {role: nginx,
73 | nginx_http_params: { tcp_nodelay: "on",
74 | error_log: "/var/log/nginx/error.log"},
75 | nginx_sites: none }
76 |
77 | Note: Please make sure the HTTP directives passed are valid, as this role
78 | won't check for the validity of the directives. See the nginx documentation
79 | for details.
80 |
81 | 3) Install nginx and add a site to the configuration.
82 |
83 | - hosts: all
84 |
85 | roles:
86 | - role: nginx,
87 | nginx_http_params:
88 | sendfile: "on"
89 | access_log: "/var/log/nginx/access.log"
90 | nginx_sites:
91 | - server:
92 | file_name: bar
93 | listen: 8080
94 | location1: {name: "/", try_files: "$uri $uri/ /index.html"}
95 | location2: {name: /images/, try_files: "$uri $uri/ /index.html"}
96 |
97 | Note: Each site added is represented by list of hashes, and the configurations
98 | generated are populated in `/etc/nginx/sites-available/` and have corresponding
99 | symlinks from `/etc/nginx/sites-enabled/`
100 |
101 | The file name for the specific site configurtaion is specified in the hash
102 | with the key "file_name", any valid server directives can be added to hash.
103 | For location directive add the key "location" suffixed by a unique number, the
104 | value for the location is hash, please make sure they are valid location
105 | directives.
106 |
107 | 4) Install Nginx and add 2 sites (different method)
108 |
109 | ---
110 | - hosts: all
111 | roles:
112 | - role: nginx
113 | nginx_http_params:
114 | sendfile: "on"
115 | access_log: "/var/log/nginx/access.log"
116 | nginx_sites:
117 | - server:
118 | file_name: foo
119 | listen: 8080
120 | server_name: localhost
121 | root: "/tmp/site1"
122 | location1: {name: /, try_files: "$uri $uri/ /index.html"}
123 | location2: {name: /images/, try_files: "$uri $uri/ /index.html"}
124 | - server:
125 | file_name: bar
126 | listen: 9090
127 | server_name: ansible
128 | root: "/tmp/site2"
129 | location1: {name: /, try_files: "$uri $uri/ /index.html"}
130 | location2: {name: /images/, try_files: "$uri $uri/ /index.html"}
131 |
132 | Dependencies
133 | ------------
134 |
135 | None
136 |
137 | License
138 | -------
139 |
140 | BSD
141 |
142 | Author Information
143 | ------------------
144 |
145 | Benno Joy
146 |
147 |
148 |
--------------------------------------------------------------------------------
/roles/nginx/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | nginx_max_clients: 512
4 |
5 | nginx_http_params:
6 | sendfile: "on"
7 | tcp_nopush: "on"
8 | tcp_nodelay: "on"
9 | keepalive_timeout: "65"
10 |
11 | nginx_log_dir: "/var/log/nginx"
12 | nginx_access_log_name: "access.log"
13 | nginx_error_log_name: "error.log"
14 | nginx_separate_logs_per_site: False
15 |
16 | nginx_sites: []
17 | # - server:
18 | # file_name: foo
19 | # listen: 8080
20 | # server_name: localhost
21 | # root: "/tmp/site1"
22 | # location1: {name: /, try_files: "$uri $uri/ /index.html"}
23 | # location2: {name: /images/, try_files: "$uri $uri/ /index.html"}
24 |
--------------------------------------------------------------------------------
/roles/nginx/files/epel.repo:
--------------------------------------------------------------------------------
1 | [epel]
2 | name=Extra Packages for Enterprise Linux 6 - $basearch
3 | baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
4 | #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
5 | failovermethod=priority
6 | enabled=1
7 | gpgcheck=0
8 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
9 |
10 | [epel-debuginfo]
11 | name=Extra Packages for Enterprise Linux 6 - $basearch - Debug
12 | #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug
13 | mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch
14 | failovermethod=priority
15 | enabled=0
16 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
17 | gpgcheck=1
18 |
19 | [epel-source]
20 | name=Extra Packages for Enterprise Linux 6 - $basearch - Source
21 | #baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS
22 | mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch
23 | failovermethod=priority
24 | enabled=0
25 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
26 | gpgcheck=1
27 |
--------------------------------------------------------------------------------
/roles/nginx/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: restart nginx
3 | service:
4 | name: nginx
5 | state: restarted
6 |
7 | - name: reload nginx
8 | service:
9 | name: nginx
10 | state: reloaded
11 |
--------------------------------------------------------------------------------
/roles/nginx/meta/.galaxy_install_info:
--------------------------------------------------------------------------------
1 | {install_date: 'Fri Jan 30 20:08:16 2015', version: master}
2 |
--------------------------------------------------------------------------------
/roles/nginx/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: "Benno Joy"
4 | company: AnsibleWorks
5 | license: BSD
6 | min_ansible_version: 1.4
7 | platforms:
8 | - name: EL
9 | versions:
10 | - 5
11 | - 6
12 | - name: Fedora
13 | versions:
14 | - 16
15 | - 17
16 | - 18
17 | - name: Ubuntu
18 | versions:
19 | - precise
20 | - quantal
21 | - raring
22 | - saucy
23 | categories:
24 | - web
25 | dependencies: []
26 |
27 |
--------------------------------------------------------------------------------
/roles/nginx/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vim: set ft=ansible:
3 |
4 | - name: Include OS specific variables
5 | include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
6 |
7 | - name: Install the nginx repo package
8 | yum:
9 | name: "{{ nginx_repo }}"
10 | state: present
11 | when: ansible_os_family == "RedHat"
12 |
13 | - name: Install the nginx packages
14 | yum:
15 | name: "{{ item }}"
16 | state: present
17 | with_items: redhat_pkg
18 | when: ansible_os_family == "RedHat"
19 |
20 | - name: Install the nginx packages
21 | apt:
22 | name: "{{ item }}"
23 | state: present
24 | update_cache: yes
25 | with_items: ubuntu_pkg
26 | when: ansible_os_family == "Debian"
27 |
28 | - name: Create the directories for site specific configurations
29 | file:
30 | path: "/etc/nginx/{{ item }}"
31 | state: directory
32 | owner: root
33 | group: root
34 | mode: 0755
35 | with_items:
36 | - "sites-available"
37 | - "sites-enabled"
38 |
39 | - name: Copy the nginx configuration file
40 | template:
41 | src: nginx.conf.j2
42 | dest: /etc/nginx/nginx.conf
43 | notify:
44 | - restart nginx
45 |
46 | - name: Copy the nginx default configuration file
47 | template:
48 | src: default.conf.j2
49 | dest: /etc/nginx/conf.d/default.conf
50 |
51 | - name: Copy the nginx default site configuration file
52 | template:
53 | src: default.j2
54 | dest: /etc/nginx/sites-available/default
55 |
56 | - name: Set default site state
57 | file:
58 | path: /etc/nginx/sites-enabled/default
59 | src: /etc/nginx/sites-available/default
60 | state: "{{ nginx_default_site | default('link') }}"
61 | notify:
62 | - reload nginx
63 |
64 | - name: Create the site root directories
65 | file:
66 | path: "/srv/www/{{ item['server']['file_name'] }}"
67 | state: directory
68 | owner: "{{ item['root_owner'] }}"
69 | group: "{{ item['root_group'] }}"
70 | with_items: nginx_sites
71 | when: nginx_sites|lower != 'none'
72 |
73 | - name: Create the configurations for sites
74 | template:
75 | src: site.j2
76 | dest: "/etc/nginx/sites-available/{{ item['server']['file_name'] }}"
77 | with_items: nginx_sites
78 | when: nginx_sites|lower != 'none'
79 |
80 | - name: Create the links to enable site configurations
81 | file:
82 | path: "/etc/nginx/sites-enabled/{{ item['server']['file_name'] }}"
83 | src: "/etc/nginx/sites-available/{{ item['server']['file_name'] }}"
84 | state: link
85 | with_items: nginx_sites
86 | when: nginx_sites|lower != 'none'
87 | notify:
88 | - reload nginx
89 |
90 | - name: start the nginx service
91 | service:
92 | name: nginx
93 | state: started
94 | enabled: yes
95 |
96 |
--------------------------------------------------------------------------------
/roles/nginx/templates/default.conf.j2:
--------------------------------------------------------------------------------
1 | # {{ ansible_managed }}
2 |
--------------------------------------------------------------------------------
/roles/nginx/templates/default.j2:
--------------------------------------------------------------------------------
1 | #{{ ansible_managed }}
2 |
3 | server {
4 | listen 80;
5 | server_name localhost;
6 |
7 | location / {
8 | root /usr/share/nginx/html;
9 | index index.html index.htm;
10 | }
11 |
12 | error_page 500 502 503 504 /50x.html;
13 | location = /50x.html {
14 | root /usr/share/nginx/html;
15 | }
16 |
17 | # deny access to .htaccess files, if Apache's document root
18 | # concurs with nginx's one
19 |
20 | location ~ /\.ht {
21 | deny all;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/roles/nginx/templates/nginx.conf.j2:
--------------------------------------------------------------------------------
1 | # {{ ansible_managed }}
2 | {% if ansible_os_family == 'RedHat' %}
3 | user nginx;
4 | {% endif %}
5 | {% if ansible_os_family == 'Debian' %}
6 | user www-data;
7 | {% endif %}
8 |
9 | worker_processes {{ ansible_processor_count }};
10 | pid /var/run/nginx.pid;
11 |
12 |
13 | events {
14 | worker_connections {{ nginx_max_clients }};
15 | }
16 |
17 |
18 | http {
19 | include /etc/nginx/mime.types;
20 | default_type application/octet-stream;
21 |
22 | access_log {{ nginx_log_dir}}/{{ nginx_access_log_name}};
23 | error_log {{ nginx_log_dir}}/{{ nginx_error_log_name}};
24 |
25 | {% for k,v in nginx_http_params.iteritems() %}
26 | {{ k }} {{ v }};
27 | {% endfor %}
28 |
29 | gzip on;
30 | gzip_disable "msie6";
31 |
32 | include /etc/nginx/conf.d/*.conf;
33 | include /etc/nginx/sites-enabled/*;
34 | }
35 |
--------------------------------------------------------------------------------
/roles/nginx/templates/site.j2:
--------------------------------------------------------------------------------
1 | # {{ ansible_managed }}
2 |
3 | server {
4 | {% if nginx_separate_logs_per_site == True %}
5 | access_log {{ nginx_log_dir}}/{{ item.server.server_name}}-{{ nginx_access_log_name}};
6 | error_log {{ nginx_log_dir}}/{{ item.server.server_name}}-{{ nginx_error_log_name}};
7 | {% endif %}
8 |
9 | {% for k,v in item.server.iteritems() %}
10 | {% if k.find('location') == -1 and k != 'file_name' %}
11 | {{ k }} {{ v }};
12 | {% endif %}
13 | {% endfor %}
14 |
15 | {% for k,v in item.server.iteritems() if k.find('location') != -1 %}
16 | location {{ v.name }} {
17 | {% for x,y in v.iteritems() if x != 'name' %}
18 | {{ x }} {{ y }};
19 | {% endfor %}
20 | }
21 | {% endfor %}
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/roles/nginx/vars/CentOS-6.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # nginx vars for CentOS-6
3 |
4 | nginx_repo: http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
5 |
--------------------------------------------------------------------------------
/roles/nginx/vars/CentOS-7.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # nginx vars for CentOS-7
3 |
4 | nginx_repo: http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
5 |
--------------------------------------------------------------------------------
/roles/nginx/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | env:
4 | RUNLEVEL: 1
5 |
6 | redhat_pkg:
7 | - nginx
8 |
9 | ubuntu_pkg:
10 | - python-selinux
11 | - nginx
12 |
13 |
14 |
--------------------------------------------------------------------------------
/roles/packages/README.md:
--------------------------------------------------------------------------------
1 | packages
2 | ========
3 |
4 | Install some packages. Can be used to install random packages that specific
5 | roles don't really cover.
6 |
7 | Requirements
8 | ------------
9 |
10 |
11 | Role Variables
12 | --------------
13 |
14 | group_vars:
15 | packages:
16 | (array)
17 |
18 | Dependencies
19 | ------------
20 |
21 |
22 | Example Playbook
23 | -------------------------
24 |
25 | - hosts: servers
26 | roles:
27 | - packages
28 |
29 | License
30 | -------
31 |
32 | BSD
33 |
34 | Author Information
35 | ------------------
36 |
37 | Mark Phillips
38 |
--------------------------------------------------------------------------------
/roles/packages/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for packages
3 |
--------------------------------------------------------------------------------
/roles/packages/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for packages
3 |
--------------------------------------------------------------------------------
/roles/packages/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: Mark Phillips
4 | description:
5 | company: DevOpsGuys
6 | # Some suggested licenses:
7 | # - BSD (default)
8 | # - MIT
9 | # - GPLv2
10 | # - GPLv3
11 | # - Apache
12 | # - CC-BY
13 | license: license (GPLv2, CC-BY, etc)
14 | min_ansible_version: 1.2
15 | #
16 | # Below are all platforms currently available. Just uncomment
17 | # the ones that apply to your role. If you don't see your
18 | # platform on this list, let us know and we'll get it added!
19 | #
20 | #platforms:
21 | #- name: EL
22 | # versions:
23 | # - all
24 | # - 5
25 | # - 6
26 | #- name: GenericUNIX
27 | # versions:
28 | # - all
29 | # - any
30 | #- name: Fedora
31 | # versions:
32 | # - all
33 | # - 16
34 | # - 17
35 | # - 18
36 | # - 19
37 | # - 20
38 | #- name: opensuse
39 | # versions:
40 | # - all
41 | # - 12.1
42 | # - 12.2
43 | # - 12.3
44 | # - 13.1
45 | # - 13.2
46 | #- name: GenericBSD
47 | # versions:
48 | # - all
49 | # - any
50 | #- name: FreeBSD
51 | # versions:
52 | # - all
53 | # - 8.0
54 | # - 8.1
55 | # - 8.2
56 | # - 8.3
57 | # - 8.4
58 | # - 9.0
59 | # - 9.1
60 | # - 9.1
61 | # - 9.2
62 | #- name: Ubuntu
63 | # versions:
64 | # - all
65 | # - lucid
66 | # - maverick
67 | # - natty
68 | # - oneiric
69 | # - precise
70 | # - quantal
71 | # - raring
72 | # - saucy
73 | # - trusty
74 | #- name: SLES
75 | # versions:
76 | # - all
77 | # - 10SP3
78 | # - 10SP4
79 | # - 11
80 | # - 11SP1
81 | # - 11SP2
82 | # - 11SP3
83 | #- name: GenericLinux
84 | # versions:
85 | # - all
86 | # - any
87 | #- name: Debian
88 | # versions:
89 | # - all
90 | # - etch
91 | # - lenny
92 | # - squeeze
93 | # - wheezy
94 | #
95 | # Below are all categories currently available. Just as with
96 | # the platforms above, uncomment those that apply to your role.
97 | #
98 | #categories:
99 | #- cloud
100 | #- cloud:ec2
101 | #- cloud:gce
102 | #- cloud:rax
103 | #- database
104 | #- database:nosql
105 | #- database:sql
106 | #- development
107 | #- monitoring
108 | #- networking
109 | #- packaging
110 | #- system
111 | #- web
112 | dependencies: []
113 | # List your role dependencies here, one per line. Only
114 | # dependencies available via galaxy should be listed here.
115 | # Be sure to remove the '[]' above if you add dependencies
116 | # to this list.
117 |
118 |
--------------------------------------------------------------------------------
/roles/packages/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for packages
3 |
4 | - name: Ensure packages are installed
5 | yum:
6 | name: "{{ packages | default([]) }}"
7 | state: present
8 |
9 | - name: Ensure python-pip packages are installed
10 | pip:
11 | name: "{{ item }}"
12 | state: latest
13 | with_items: "{{ packages_pip | default([]) }}"
14 |
--------------------------------------------------------------------------------
/roles/packages/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for packages
3 |
--------------------------------------------------------------------------------
/roles/patching/README.md:
--------------------------------------------------------------------------------
1 | Patching
2 | ========
3 |
4 | A role to patch hosts. The role permits selective patching, dependent on subscription to Yum repositories and variable setting to confirm action.
5 |
6 | Requirements
7 | ------------
8 |
9 |
10 | Role Variables
11 | --------------
12 |
13 | defaults/main.yml
14 | patchme: False
15 |
16 | Can be set on a group basis, host basis or even run basis.
17 |
18 | Dependencies
19 | ------------
20 |
21 |
22 | Example Playbook
23 | -------------------------
24 |
25 | - hosts: servers
26 | roles:
27 | - { role: patching, patchme: True }
28 |
29 | License
30 | -------
31 |
32 | BSD
33 |
34 | Author Information
35 | ------------------
36 |
37 | Mark Phillips
38 |
--------------------------------------------------------------------------------
/roles/patching/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for patching
3 |
4 | patchme: False
5 |
--------------------------------------------------------------------------------
/roles/patching/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for patching
3 |
--------------------------------------------------------------------------------
/roles/patching/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: your name
4 | description:
5 | company: your company (optional)
6 | # Some suggested licenses:
7 | # - BSD (default)
8 | # - MIT
9 | # - GPLv2
10 | # - GPLv3
11 | # - Apache
12 | # - CC-BY
13 | license: license (GPLv2, CC-BY, etc)
14 | min_ansible_version: 1.2
15 | #
16 | # Below are all platforms currently available. Just uncomment
17 | # the ones that apply to your role. If you don't see your
18 | # platform on this list, let us know and we'll get it added!
19 | #
20 | #platforms:
21 | #- name: EL
22 | # versions:
23 | # - all
24 | # - 5
25 | # - 6
26 | # - 7
27 | #- name: GenericUNIX
28 | # versions:
29 | # - all
30 | # - any
31 | #- name: Fedora
32 | # versions:
33 | # - all
34 | # - 16
35 | # - 17
36 | # - 18
37 | # - 19
38 | # - 20
39 | #- name: opensuse
40 | # versions:
41 | # - all
42 | # - 12.1
43 | # - 12.2
44 | # - 12.3
45 | # - 13.1
46 | # - 13.2
47 | #- name: Amazon
48 | # versions:
49 | # - all
50 | # - 2013.03
51 | # - 2013.09
52 | #- name: GenericBSD
53 | # versions:
54 | # - all
55 | # - any
56 | #- name: FreeBSD
57 | # versions:
58 | # - all
59 | # - 8.0
60 | # - 8.1
61 | # - 8.2
62 | # - 8.3
63 | # - 8.4
64 | # - 9.0
65 | # - 9.1
66 | # - 9.1
67 | # - 9.2
68 | #- name: Ubuntu
69 | # versions:
70 | # - all
71 | # - lucid
72 | # - maverick
73 | # - natty
74 | # - oneiric
75 | # - precise
76 | # - quantal
77 | # - raring
78 | # - saucy
79 | # - trusty
80 | #- name: SLES
81 | # versions:
82 | # - all
83 | # - 10SP3
84 | # - 10SP4
85 | # - 11
86 | # - 11SP1
87 | # - 11SP2
88 | # - 11SP3
89 | #- name: GenericLinux
90 | # versions:
91 | # - all
92 | # - any
93 | #- name: Debian
94 | # versions:
95 | # - all
96 | # - etch
97 | # - lenny
98 | # - squeeze
99 | # - wheezy
100 | #
101 | # Below are all categories currently available. Just as with
102 | # the platforms above, uncomment those that apply to your role.
103 | #
104 | #categories:
105 | #- cloud
106 | #- cloud:ec2
107 | #- cloud:gce
108 | #- cloud:rax
109 | #- clustering
110 | #- database
111 | #- database:nosql
112 | #- database:sql
113 | #- development
114 | #- monitoring
115 | #- networking
116 | #- packaging
117 | #- system
118 | #- web
119 | dependencies: []
120 | # List your role dependencies here, one per line. Only
121 | # dependencies available via galaxy should be listed here.
122 | # Be sure to remove the '[]' above if you add dependencies
123 | # to this list.
124 |
125 |
--------------------------------------------------------------------------------
/roles/patching/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for patching
3 |
4 | - name: Include OS version specific differences
5 | include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
6 |
7 | - name: Ensure Yum repositories are configured
8 | template:
9 | src: template.repo.j2
10 | dest: "/etc/yum.repos.d/{{ item.label }}.repo"
11 | owner: root
12 | group: root
13 | mode: 0644
14 | when: patching_repos
15 | with_items: "{{ patching_repos }}"
16 |
17 | - name: Ensure OS shipped yum repo configs are absent
18 | file:
19 | path: "/etc/yum.repos.d/{{ patching_default_repo_def }}"
20 | state: absent
21 |
22 | - name: Patch this host
23 | command: yum update -y --enablerepo=osupdates
24 | when: patching
25 |
--------------------------------------------------------------------------------
/roles/patching/templates/template.repo.j2:
--------------------------------------------------------------------------------
1 | # {{ ansible_managed }}
2 | [{{ item.label }}]
3 | name={{ item.name }}
4 | baseurl={{ item.baseurl }}
5 | enabled={% if item.enabled %}1
6 | {% else %}0
7 | {% endif %}
8 | gpgcheck={% if item.gpgcheck %}1
9 | gpgkey={{ item.gpgkey }}
10 | {% else %}0
11 | {% endif %}
12 |
--------------------------------------------------------------------------------
/roles/patching/vars/CentOS-6.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for CentOS-6
3 |
4 | patching_default_repo_def: CentOS-Base.repo
5 |
--------------------------------------------------------------------------------
/roles/patching/vars/CentOS-7.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for CentOS-7
3 |
4 | patching_default_repo_def: CentOS-Base.repo
5 |
--------------------------------------------------------------------------------
/roles/patching/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for patching
3 |
--------------------------------------------------------------------------------
/roles/phone_home/README.md:
--------------------------------------------------------------------------------
1 | phone_home
2 | ==========
3 |
4 | Configures a script to run under the special cron situation, 'reboot'. In other words, only run when the machine boots. This script does a call to an Ansible Tower server to run a given Job Template (i.e. an Ansible play). The script uses DNS records to look up the Job Template ID, and the Tower server.
5 |
6 | Further Reading
7 | ---------------
8 |
9 | https://linux.die.net/man/5/crontab
10 | https://docs.ansible.com/ansible-tower/latest/html/userguide/job_templates.html#provisioning-callbacks
11 | http://probably.co.uk/simple-service-discovery-using-ansible-tower-and-dns.html
12 |
13 | Role Variables
14 | --------------
15 |
16 | You can set these, rather than have them looked up in DNS, if you choose...
17 | ```
18 | phone_home_tower
19 | phone_home_key
20 | phone_home_id
21 | ```
22 |
23 | Dependencies
24 | ------------
25 |
26 | None.
27 |
28 | Example Playbook
29 | ----------------
30 |
31 | - hosts: servers
32 | roles:
33 | - { role: phone_home }
34 |
35 | License
36 | -------
37 |
38 | BSD
39 |
40 | Author Information
41 | ------------------
42 |
43 | Mark Phillips
44 |
45 |
--------------------------------------------------------------------------------
/roles/phone_home/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for phone_home
3 |
--------------------------------------------------------------------------------
/roles/phone_home/files/req_conf.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Derived from request_tower_configuration.sh script, shipped with Ansible Tower
4 | #
5 | # This version can take server, host key and job ID as parameters, but can also look them up from DNS.
6 | # See this blog post for more information: http://probably.co.uk/simple-service-discovery-using-ansible-tower-and-dns.html
7 |
8 | usage() {
9 | echo -e "Requests server configuration from Ansible Tower\n"
10 | echo "Usage: $0 [:server port] "
11 | echo "Example: $0 example.towerhost.net 44d7507f2ead49af5fca80aa18fd24bc 38"
12 | exit 1
13 | }
14 |
15 | # my name
16 | script=$0
17 |
18 | if [ $(uname) != "Linux" ]; then
19 | logger -p user.err "Ansible: ${script} FAIL, only tested on Linux"
20 | exit 1
21 | fi
22 |
23 | if [ ! -x /usr/bin/dig ]; then
24 | logger -p user.err "Ansible: ${script} FAIL, no dig command. Try installing bind-utils"
25 | exit 1
26 | fi
27 |
28 | if [ ! -x /bin/dnsdomainname ]; then
29 | logger -p user.err "Ansible: ${script} FAIL, no dnsdomainname command. Try installing hostname"
30 | exit 1
31 | fi
32 |
33 | dnsdomain=$(/bin/dnsdomainname)
34 | if [ -z $dnsdomain ]; then
35 | logger -p user.err "Ansible: ${script} FAIL, can't establish DNS domain name"
36 | exit 1
37 | fi
38 |
39 | towersvr=${1:-$(dig +short _cm._tcp.${dnsdomain} srv|awk '/^0/ {print $4}')}
40 | configkey=${2:-$(dig +short ${dnsdomain} txt | tr -d '"' | cut -f1 -d" ")}
41 | jtid=${3:-$(dig +short ${dnsdomain} txt | tr -d '"' | cut -f2 -d" ")}
42 |
43 | if [[ -z $towersvr || -z $configkey || -z $jtid ]]; then
44 | logger -p user.err "Ansible: ${script} FAIL, no towersvr, configkey or jtid"
45 | exit 1
46 | fi
47 |
48 | retry_attempts=10
49 | attempt=0
50 | while [[ $attempt -lt $retry_attempts ]]
51 | do
52 | status_code=$(curl -s -i --data "host_config_key=${configkey}" http://${towersvr}/api/v1/job_templates/${jtid}/callback/ | head -n 1 | awk '{print $2}')
53 | if [[ $status_code -ge 300 ]]; then
54 | logger -p user.err "Ansible: ${script} FAIL, ${status_code} received"
55 | exit 1
56 | else
57 | exit 0
58 | fi
59 | attempt=$(( attempt + 1 ))
60 | echo "${status_code} received... retrying in 1 minute. (Attempt ${attempt})"
61 | sleep 60
62 | done
63 | exit 1
64 |
--------------------------------------------------------------------------------
/roles/phone_home/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for phone_home
3 |
--------------------------------------------------------------------------------
/roles/phone_home/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: your name
4 | description:
5 | company: your company (optional)
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 | # Some suggested licenses:
10 | # - BSD (default)
11 | # - MIT
12 | # - GPLv2
13 | # - GPLv3
14 | # - Apache
15 | # - CC-BY
16 | license: license (GPLv2, CC-BY, etc)
17 | min_ansible_version: 1.2
18 | #
19 | # Below are all platforms currently available. Just uncomment
20 | # the ones that apply to your role. If you don't see your
21 | # platform on this list, let us know and we'll get it added!
22 | #
23 | #platforms:
24 | #- name: EL
25 | # versions:
26 | # - all
27 | # - 5
28 | # - 6
29 | # - 7
30 | #- name: GenericUNIX
31 | # versions:
32 | # - all
33 | # - any
34 | #- name: Fedora
35 | # versions:
36 | # - all
37 | # - 16
38 | # - 17
39 | # - 18
40 | # - 19
41 | # - 20
42 | # - 21
43 | # - 22
44 | #- name: Windows
45 | # versions:
46 | # - all
47 | # - 2012R2
48 | #- name: SmartOS
49 | # versions:
50 | # - all
51 | # - any
52 | #- name: opensuse
53 | # versions:
54 | # - all
55 | # - 12.1
56 | # - 12.2
57 | # - 12.3
58 | # - 13.1
59 | # - 13.2
60 | #- name: Amazon
61 | # versions:
62 | # - all
63 | # - 2013.03
64 | # - 2013.09
65 | #- name: GenericBSD
66 | # versions:
67 | # - all
68 | # - any
69 | #- name: FreeBSD
70 | # versions:
71 | # - all
72 | # - 8.0
73 | # - 8.1
74 | # - 8.2
75 | # - 8.3
76 | # - 8.4
77 | # - 9.0
78 | # - 9.1
79 | # - 9.1
80 | # - 9.2
81 | #- name: Ubuntu
82 | # versions:
83 | # - all
84 | # - lucid
85 | # - maverick
86 | # - natty
87 | # - oneiric
88 | # - precise
89 | # - quantal
90 | # - raring
91 | # - saucy
92 | # - trusty
93 | # - utopic
94 | # - vivid
95 | #- name: SLES
96 | # versions:
97 | # - all
98 | # - 10SP3
99 | # - 10SP4
100 | # - 11
101 | # - 11SP1
102 | # - 11SP2
103 | # - 11SP3
104 | #- name: GenericLinux
105 | # versions:
106 | # - all
107 | # - any
108 | #- name: Debian
109 | # versions:
110 | # - all
111 | # - etch
112 | # - jessie
113 | # - lenny
114 | # - squeeze
115 | # - wheezy
116 | #
117 | # Below are all categories currently available. Just as with
118 | # the platforms above, uncomment those that apply to your role.
119 | #
120 | #categories:
121 | #- cloud
122 | #- cloud:ec2
123 | #- cloud:gce
124 | #- cloud:rax
125 | #- clustering
126 | #- database
127 | #- database:nosql
128 | #- database:sql
129 | #- development
130 | #- monitoring
131 | #- networking
132 | #- packaging
133 | #- system
134 | #- web
135 | dependencies: []
136 | # List your role dependencies here, one per line.
137 | # Be sure to remove the '[]' above if you add dependencies
138 | # to this list.
139 |
140 |
--------------------------------------------------------------------------------
/roles/phone_home/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for phone_home
3 | # vim: set ft=ansible:
4 |
5 | - name: Scripts directory
6 | file:
7 | path: /opt/scripts
8 | owner: root
9 | group: root
10 | mode: 0755
11 | state: directory
12 |
13 | - name: Script in place
14 | copy:
15 | src: req_conf.sh
16 | dest: /opt/scripts/req_conf.sh
17 | owner: root
18 | group: root
19 | mode: 0755
20 |
21 | - name: Set reboot cronjob
22 | cron:
23 | name: "Phone home on reboot"
24 | special_time: reboot
25 | job: "/opt/scripts/req_conf.sh {{ phone_home_tower|default('') }} {{ phone_home_key|default('') }} {{ phone_home_id|default('') }}"
26 |
--------------------------------------------------------------------------------
/roles/phone_home/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for phone_home
3 |
--------------------------------------------------------------------------------
/roles/services/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/roles/services/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for services
3 |
4 | services_list:
5 | - atd
6 | - rsyslog
7 |
--------------------------------------------------------------------------------
/roles/services/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for services
--------------------------------------------------------------------------------
/roles/services/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.4
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/roles/services/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for services
3 |
4 | - name: Ensure service state is {{ services_state }}
5 | service:
6 | name: "{{ services_name }}"
7 | state: "{{ services_state }}"
8 |
--------------------------------------------------------------------------------
/roles/services/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/roles/services/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - services
--------------------------------------------------------------------------------
/roles/services/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for services
--------------------------------------------------------------------------------
/roles/shell/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | ========
3 |
4 | Some basic requirements for shells. Aliases, that kind of thing.
5 |
6 | Requirements
7 | ------------
8 |
9 |
10 | Role Variables
11 | --------------
12 |
13 |
14 | Dependencies
15 | ------------
16 |
17 |
18 | Example Playbook
19 | -------------------------
20 |
21 | - hosts: servers
22 | roles:
23 | - shell
24 |
25 | License
26 | -------
27 |
28 | BSD
29 |
30 | Author Information
31 | ------------------
32 |
33 | Mark Phillips
34 |
--------------------------------------------------------------------------------
/roles/shell/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for shell
3 |
--------------------------------------------------------------------------------
/roles/shell/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for shell
3 |
--------------------------------------------------------------------------------
/roles/shell/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: your name
4 | description:
5 | company: your company (optional)
6 | # Some suggested licenses:
7 | # - BSD (default)
8 | # - MIT
9 | # - GPLv2
10 | # - GPLv3
11 | # - Apache
12 | # - CC-BY
13 | license: license (GPLv2, CC-BY, etc)
14 | min_ansible_version: 1.2
15 | #
16 | # Below are all platforms currently available. Just uncomment
17 | # the ones that apply to your role. If you don't see your
18 | # platform on this list, let us know and we'll get it added!
19 | #
20 | #platforms:
21 | #- name: EL
22 | # versions:
23 | # - all
24 | # - 5
25 | # - 6
26 | #- name: GenericUNIX
27 | # versions:
28 | # - all
29 | # - any
30 | #- name: Fedora
31 | # versions:
32 | # - all
33 | # - 16
34 | # - 17
35 | # - 18
36 | # - 19
37 | # - 20
38 | #- name: opensuse
39 | # versions:
40 | # - all
41 | # - 12.1
42 | # - 12.2
43 | # - 12.3
44 | # - 13.1
45 | # - 13.2
46 | #- name: GenericBSD
47 | # versions:
48 | # - all
49 | # - any
50 | #- name: FreeBSD
51 | # versions:
52 | # - all
53 | # - 8.0
54 | # - 8.1
55 | # - 8.2
56 | # - 8.3
57 | # - 8.4
58 | # - 9.0
59 | # - 9.1
60 | # - 9.1
61 | # - 9.2
62 | #- name: Ubuntu
63 | # versions:
64 | # - all
65 | # - lucid
66 | # - maverick
67 | # - natty
68 | # - oneiric
69 | # - precise
70 | # - quantal
71 | # - raring
72 | # - saucy
73 | # - trusty
74 | #- name: SLES
75 | # versions:
76 | # - all
77 | # - 10SP3
78 | # - 10SP4
79 | # - 11
80 | # - 11SP1
81 | # - 11SP2
82 | # - 11SP3
83 | #- name: GenericLinux
84 | # versions:
85 | # - all
86 | # - any
87 | #- name: Debian
88 | # versions:
89 | # - all
90 | # - etch
91 | # - lenny
92 | # - squeeze
93 | # - wheezy
94 | #
95 | # Below are all categories currently available. Just as with
96 | # the platforms above, uncomment those that apply to your role.
97 | #
98 | #categories:
99 | #- cloud
100 | #- cloud:ec2
101 | #- cloud:gce
102 | #- cloud:rax
103 | #- database
104 | #- database:nosql
105 | #- database:sql
106 | #- development
107 | #- monitoring
108 | #- networking
109 | #- packaging
110 | #- system
111 | #- web
112 | dependencies: []
113 | # List your role dependencies here, one per line. Only
114 | # dependencies available via galaxy should be listed here.
115 | # Be sure to remove the '[]' above if you add dependencies
116 | # to this list.
117 |
118 |
--------------------------------------------------------------------------------
/roles/shell/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for shell
3 |
4 | - name: Ensure aliases.sh present
5 | template:
6 | src: aliases.sh.j2
7 | dest: /etc/profile.d/aliases.sh
8 | owner: root
9 | group: root
10 | mode: 0644
11 |
12 |
--------------------------------------------------------------------------------
/roles/shell/templates/aliases.sh.j2:
--------------------------------------------------------------------------------
1 | # {{ ansible_managed }}
2 | alias l='ls -laF'
3 | alias lr='ls -Fartl'
4 | alias j=jobs
5 | [ -x /usr/bin/vim ] && alias vi=vim
6 |
--------------------------------------------------------------------------------
/roles/shell/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for shell
3 |
--------------------------------------------------------------------------------
/roles/sshd/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | ========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | -------------------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | Mark Phillips
39 |
--------------------------------------------------------------------------------
/roles/sshd/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for sshd
3 |
4 | sshd_options:
5 | - setting: PermitRootLogin
6 | value: 'without-password'
7 | state: present
8 | - setting: UseDNS
9 | value: 'no'
10 | state: present
11 |
--------------------------------------------------------------------------------
/roles/sshd/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for sshd
3 |
4 | - name: restart sshd
5 | service:
6 | name: sshd
7 | state: restarted
8 |
--------------------------------------------------------------------------------
/roles/sshd/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: your name
4 | description:
5 | company: your company (optional)
6 | # Some suggested licenses:
7 | # - BSD (default)
8 | # - MIT
9 | # - GPLv2
10 | # - GPLv3
11 | # - Apache
12 | # - CC-BY
13 | license: license (GPLv2, CC-BY, etc)
14 | min_ansible_version: 1.2
15 | #
16 | # Below are all platforms currently available. Just uncomment
17 | # the ones that apply to your role. If you don't see your
18 | # platform on this list, let us know and we'll get it added!
19 | #
20 | #platforms:
21 | #- name: EL
22 | # versions:
23 | # - all
24 | # - 5
25 | # - 6
26 | # - 7
27 | #- name: GenericUNIX
28 | # versions:
29 | # - all
30 | # - any
31 | #- name: Fedora
32 | # versions:
33 | # - all
34 | # - 16
35 | # - 17
36 | # - 18
37 | # - 19
38 | # - 20
39 | #- name: opensuse
40 | # versions:
41 | # - all
42 | # - 12.1
43 | # - 12.2
44 | # - 12.3
45 | # - 13.1
46 | # - 13.2
47 | #- name: Amazon
48 | # versions:
49 | # - all
50 | # - 2013.03
51 | # - 2013.09
52 | #- name: GenericBSD
53 | # versions:
54 | # - all
55 | # - any
56 | #- name: FreeBSD
57 | # versions:
58 | # - all
59 | # - 8.0
60 | # - 8.1
61 | # - 8.2
62 | # - 8.3
63 | # - 8.4
64 | # - 9.0
65 | # - 9.1
66 | # - 9.1
67 | # - 9.2
68 | #- name: Ubuntu
69 | # versions:
70 | # - all
71 | # - lucid
72 | # - maverick
73 | # - natty
74 | # - oneiric
75 | # - precise
76 | # - quantal
77 | # - raring
78 | # - saucy
79 | # - trusty
80 | #- name: SLES
81 | # versions:
82 | # - all
83 | # - 10SP3
84 | # - 10SP4
85 | # - 11
86 | # - 11SP1
87 | # - 11SP2
88 | # - 11SP3
89 | #- name: GenericLinux
90 | # versions:
91 | # - all
92 | # - any
93 | #- name: Debian
94 | # versions:
95 | # - all
96 | # - etch
97 | # - lenny
98 | # - squeeze
99 | # - wheezy
100 | #
101 | # Below are all categories currently available. Just as with
102 | # the platforms above, uncomment those that apply to your role.
103 | #
104 | #categories:
105 | #- cloud
106 | #- cloud:ec2
107 | #- cloud:gce
108 | #- cloud:rax
109 | #- clustering
110 | #- database
111 | #- database:nosql
112 | #- database:sql
113 | #- development
114 | #- monitoring
115 | #- networking
116 | #- packaging
117 | #- system
118 | #- web
119 | dependencies: []
120 | # List your role dependencies here, one per line. Only
121 | # dependencies available via galaxy should be listed here.
122 | # Be sure to remove the '[]' above if you add dependencies
123 | # to this list.
124 |
125 |
--------------------------------------------------------------------------------
/roles/sshd/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for sshd
3 | # vim: set ft=ansible:
4 |
5 | - name: Include OS specific variables
6 | include_vars: "{{ ansible_distribution }}.yml"
7 |
8 | - name: Ensure sshd settings are applied
9 | lineinfile:
10 | dest: /etc/ssh/sshd_config
11 | regexp: "^{{ item.setting }}"
12 | line: "{{ item.setting }} {{ item.value }}"
13 | state: "{{ item.state }}"
14 | with_items: "{{ sshd_options }}"
15 | notify:
16 | - restart sshd
17 |
--------------------------------------------------------------------------------
/roles/sshd/vars/Amazon.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # sshd vars file for Amazon
3 |
4 | sshd_options:
5 | - setting: PermitRootLogin
6 | value: 'forced-commands-only'
7 | state: present
8 | - setting: Banner
9 | value: '/etc/issue'
10 | state: present
11 |
--------------------------------------------------------------------------------
/roles/sshd/vars/CentOS.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
--------------------------------------------------------------------------------
/roles/sshd/vars/RedHat.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
--------------------------------------------------------------------------------
/roles/sshd/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for sshd
3 |
--------------------------------------------------------------------------------
/roles/sudo/README.md:
--------------------------------------------------------------------------------
1 | sudo
2 | ====
3 |
4 | Manage user sudo entitlements – with a time based 'cleanup'.
5 |
6 | Requirements
7 | ------------
8 |
9 |
10 | Role Variables
11 | --------------
12 |
13 | sudo_user: (set on play)
14 | sudo_cleanup: true
15 | sudo_count: 10
16 | sudo_units: minutes
17 |
18 |
19 | Example Playbook
20 | ----------------
21 |
22 | - hosts: servers
23 | roles:
24 | - { role: sudo sudo_user: bob }
25 |
26 | License
27 | -------
28 |
29 | BSD
30 |
31 | Author Information
32 | ------------------
33 |
34 | Mark Phillips
35 |
36 |
--------------------------------------------------------------------------------
/roles/sudo/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for sudo
3 | sudo_cleanup: true
4 |
--------------------------------------------------------------------------------
/roles/sudo/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vim: set ft=ansible:
3 | # tasks file for sudo
4 |
5 | - name: Ensure sudoers.d file exists
6 | template:
7 | src: user.j2
8 | dest: "/etc/sudoers.d/{{ sudo_user }}"
9 | owner: root
10 | group: root
11 | mode: 0640
12 |
13 | - name: Time based cleanup
14 | at:
15 | command: "rm /etc/sudoers.d/{{ sudo_user }}"
16 | count: "{{ sudo_count | default('10') }}"
17 | units: "{{ sudo_units | default('minutes') }}"
18 | when: sudo_cleanup|bool
19 |
--------------------------------------------------------------------------------
/roles/sudo/templates/user.j2:
--------------------------------------------------------------------------------
1 | # {{ ansible_managed }}
2 |
3 | {{ sudo_user }} ALL=(ALL) NOPASSWD:ALL
4 |
--------------------------------------------------------------------------------
/roles/vmwtools/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/roles/vmwtools/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for vmwtools
3 |
4 | vmwtools_tar: VMwareTools-10.0.5-3228253.tar.gz
5 | vmwtools_sha: 296c438522e625822ad2392d70a07fc15f5929a1708941d0353e4db70c54d93f
6 | vmwtools_tmp: /var/tmp
7 | vmwtools_cleanup: False
8 | vmwtools_install: True
9 |
--------------------------------------------------------------------------------
/roles/vmwtools/files/vmwtools.fact:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [[ -x /usr/bin/vmware-uninstall-tools.pl ]]; then
4 | echo '{"installed":true}'
5 | else
6 | echo '{"installed":false}'
7 | fi
8 |
--------------------------------------------------------------------------------
/roles/vmwtools/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for vmwtools
3 |
--------------------------------------------------------------------------------
/roles/vmwtools/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: your name
4 | description:
5 | company: your company (optional)
6 | # Some suggested licenses:
7 | # - BSD (default)
8 | # - MIT
9 | # - GPLv2
10 | # - GPLv3
11 | # - Apache
12 | # - CC-BY
13 | license: license (GPLv2, CC-BY, etc)
14 | min_ansible_version: 1.2
15 | #
16 | # Below are all platforms currently available. Just uncomment
17 | # the ones that apply to your role. If you don't see your
18 | # platform on this list, let us know and we'll get it added!
19 | #
20 | #platforms:
21 | #- name: EL
22 | # versions:
23 | # - all
24 | # - 5
25 | # - 6
26 | # - 7
27 | #- name: GenericUNIX
28 | # versions:
29 | # - all
30 | # - any
31 | #- name: Fedora
32 | # versions:
33 | # - all
34 | # - 16
35 | # - 17
36 | # - 18
37 | # - 19
38 | # - 20
39 | #- name: opensuse
40 | # versions:
41 | # - all
42 | # - 12.1
43 | # - 12.2
44 | # - 12.3
45 | # - 13.1
46 | # - 13.2
47 | #- name: Amazon
48 | # versions:
49 | # - all
50 | # - 2013.03
51 | # - 2013.09
52 | #- name: GenericBSD
53 | # versions:
54 | # - all
55 | # - any
56 | #- name: FreeBSD
57 | # versions:
58 | # - all
59 | # - 8.0
60 | # - 8.1
61 | # - 8.2
62 | # - 8.3
63 | # - 8.4
64 | # - 9.0
65 | # - 9.1
66 | # - 9.1
67 | # - 9.2
68 | #- name: Ubuntu
69 | # versions:
70 | # - all
71 | # - lucid
72 | # - maverick
73 | # - natty
74 | # - oneiric
75 | # - precise
76 | # - quantal
77 | # - raring
78 | # - saucy
79 | # - trusty
80 | #- name: SLES
81 | # versions:
82 | # - all
83 | # - 10SP3
84 | # - 10SP4
85 | # - 11
86 | # - 11SP1
87 | # - 11SP2
88 | # - 11SP3
89 | #- name: GenericLinux
90 | # versions:
91 | # - all
92 | # - any
93 | #- name: Debian
94 | # versions:
95 | # - all
96 | # - etch
97 | # - lenny
98 | # - squeeze
99 | # - wheezy
100 | #
101 | # Below are all categories currently available. Just as with
102 | # the platforms above, uncomment those that apply to your role.
103 | #
104 | #categories:
105 | #- cloud
106 | #- cloud:ec2
107 | #- cloud:gce
108 | #- cloud:rax
109 | #- clustering
110 | #- database
111 | #- database:nosql
112 | #- database:sql
113 | #- development
114 | #- monitoring
115 | #- networking
116 | #- packaging
117 | #- system
118 | #- web
119 | dependencies: []
120 | # List your role dependencies here, one per line. Only
121 | # dependencies available via galaxy should be listed here.
122 | # Be sure to remove the '[]' above if you add dependencies
123 | # to this list.
124 |
125 |
--------------------------------------------------------------------------------
/roles/vmwtools/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for vmwtools
3 |
4 | - name: Ensure facts directory exists
5 | file:
6 | path: /etc/ansible/facts.d
7 | state: directory
8 | owner: root
9 | group: root
10 | mode: 0755
11 |
12 | - name: Setup fact
13 | copy:
14 | src: vmwtools.fact
15 | dest: /etc/ansible/facts.d/
16 | mode: 0755
17 | register: newfact
18 |
19 | - name: Reload facts
20 | setup:
21 | when: newfact|changed
22 |
23 | - name: Install pre-requisite packages
24 | yum:
25 | name: "{{ item }}"
26 | with_items:
27 | - fuse-libs
28 | - fuse
29 | - kernel-devel
30 |
31 | - name: Check for prior download
32 | stat:
33 | path: "{{ vmwtools_tmp }}/{{ vmwtools_tar}}"
34 | register: tar
35 |
36 | - name: Fetch tools install
37 | get_url:
38 | url: "{{ vmwtools_url }}/{{ vmwtools_tar }}"
39 | dest: "{{ vmwtools_tmp }}"
40 | sha256sum: "{{ vmwtools_sha }}"
41 | when: not tar.stat.exists
42 | register: fetch
43 |
44 | - name: Unarchive tools dist
45 | unarchive:
46 | src: "{{ vmwtools_tmp }}/{{ vmwtools_tar }}"
47 | dest: "{{ vmwtools_tmp }}"
48 | copy: no
49 | creates: "{{ vmwtools_tmp }}/vmware-tools-distrib"
50 | when: fetch.changed or fetch.skipped
51 |
52 | - name: Check for archive
53 | stat:
54 | path: "{{ vmwtools_tmp }}/vmware-tools-distrib"
55 | register: archive
56 |
57 | - name: Installing tools
58 | command: "{{ vmwtools_tmp }}/vmware-tools-distrib/vmware-install.pl -d"
59 | when: not ansible_local.vmwtools.installed
60 |
61 | - name: Remove temporary files
62 | command: "rm -rf {{ vmwtools_tmp }}/vmware-tools-distrib"
63 | when: vmwtools_cleanup
64 |
65 |
--------------------------------------------------------------------------------
/roles/vmwtools/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for vmwtools
3 |
--------------------------------------------------------------------------------
/roles/xentools/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for xentools
3 |
4 | xentools_archive: xentools-6.5.tgz
5 | xentools_sha256: 3ee2a0df7269a60d9637344bfca6bbfd9013f87c7d092d4ace64347d72869b8d
6 | xentools_force: False
7 |
--------------------------------------------------------------------------------
/roles/xentools/files/xentools.fact:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | XEDAEMON='/usr/sbin/xe-daemon'
4 |
5 | if [[ -x $XEDAEMON ]]; then
6 | echo '{"installed":true}'
7 | else
8 | echo '{"installed":false}'
9 | fi
10 |
--------------------------------------------------------------------------------
/roles/xentools/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Ensure facts directory exists
3 | file:
4 | path: /etc/ansible/facts.d
5 | state: directory
6 | owner: root
7 | group: root
8 | mode: 0755
9 |
10 | - name: Setup fact
11 | copy:
12 | src: xentools.fact
13 | dest: /etc/ansible/facts.d/
14 | mode: 0755
15 | register: fact_setup
16 |
17 | - name: Re-read facts
18 | setup:
19 | when: fact_setup|changed
20 |
21 | - name: Fetch tools install
22 | get_url:
23 | url: "http://{{ bootstrap_svr }}/{{ bootstrap_dir }}/{{ xentools_archive }}"
24 | dest: "{{ tmp }}"
25 | sha256sum: "{{ xentools_sha256 }}"
26 | when: (not ansible_local.xentools.installed) or xentools_force
27 | register: fetch
28 |
29 | - name: Unarchive tools dist
30 | unarchive:
31 | src: "{{ tmp }}/{{ xentools_archive }}"
32 | dest: "{{ tmp }}"
33 | copy: no
34 | creates: "{{ tmp }}/Linux"
35 | when: fetch|changed
36 |
37 | - name: Installing tools
38 | shell: "{{ tmp }}/Linux/install.sh -n"
39 | when: (not ansible_local.xentools.installed) or xentools_force
40 | ignore_errors: true
41 |
42 |
--------------------------------------------------------------------------------
/roles/yum/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | Set up Yum repositories.
5 |
6 |
7 | Requirements
8 | ------------
9 |
10 | None. Other than the repositories must be defined in the yum_repos array.
11 |
12 | Role Variables
13 | --------------
14 |
15 | By default nothing is defined, you need to define yum_repos. This is an array of hashes, which go to populate /etc/yum.repos.d/* files. Here's an example of setting up EPEL:
16 |
17 | yum_repos:
18 | - label: epel
19 | name: "Extra Packages for Enterprise Linux 6"
20 | mirrorlist: https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
21 | enabled: True
22 | gpgcheck: True
23 | gpgkey: https://fedoraproject.org/static/0608B895.txt
24 |
25 | Take a look at the template.repo.j2 file to understand how this works.
26 |
27 | Dependencies
28 | ------------
29 |
30 | None.
31 |
32 | Example Playbook
33 | ----------------
34 |
35 | - hosts: servers
36 | roles:
37 | - { role: yum }
38 |
39 | License
40 | -------
41 |
42 | BSD
43 |
44 | Author Information
45 | ------------------
46 |
47 | Mark Phillips
48 |
--------------------------------------------------------------------------------
/roles/yum/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for yum
3 |
--------------------------------------------------------------------------------
/roles/yum/files/RPM-GPG-KEY-EPEL-7:
--------------------------------------------------------------------------------
1 | -----BEGIN PGP PUBLIC KEY BLOCK-----
2 | Version: GnuPG v1.4.11 (GNU/Linux)
3 |
4 | mQINBFKuaIQBEAC1UphXwMqCAarPUH/ZsOFslabeTVO2pDk5YnO96f+rgZB7xArB
5 | OSeQk7B90iqSJ85/c72OAn4OXYvT63gfCeXpJs5M7emXkPsNQWWSju99lW+AqSNm
6 | jYWhmRlLRGl0OO7gIwj776dIXvcMNFlzSPj00N2xAqjMbjlnV2n2abAE5gq6VpqP
7 | vFXVyfrVa/ualogDVmf6h2t4Rdpifq8qTHsHFU3xpCz+T6/dGWKGQ42ZQfTaLnDM
8 | jToAsmY0AyevkIbX6iZVtzGvanYpPcWW4X0RDPcpqfFNZk643xI4lsZ+Y2Er9Yu5
9 | S/8x0ly+tmmIokaE0wwbdUu740YTZjCesroYWiRg5zuQ2xfKxJoV5E+Eh+tYwGDJ
10 | n6HfWhRgnudRRwvuJ45ztYVtKulKw8QQpd2STWrcQQDJaRWmnMooX/PATTjCBExB
11 | 9dkz38Druvk7IkHMtsIqlkAOQMdsX1d3Tov6BE2XDjIG0zFxLduJGbVwc/6rIc95
12 | T055j36Ez0HrjxdpTGOOHxRqMK5m9flFbaxxtDnS7w77WqzW7HjFrD0VeTx2vnjj
13 | GqchHEQpfDpFOzb8LTFhgYidyRNUflQY35WLOzLNV+pV3eQ3Jg11UFwelSNLqfQf
14 | uFRGc+zcwkNjHh5yPvm9odR1BIfqJ6sKGPGbtPNXo7ERMRypWyRz0zi0twARAQAB
15 | tChGZWRvcmEgRVBFTCAoNykgPGVwZWxAZmVkb3JhcHJvamVjdC5vcmc+iQI4BBMB
16 | AgAiBQJSrmiEAhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRBqL66iNSxk
17 | 5cfGD/4spqpsTjtDM7qpytKLHKruZtvuWiqt5RfvT9ww9GUUFMZ4ZZGX4nUXg49q
18 | ixDLayWR8ddG/s5kyOi3C0uX/6inzaYyRg+Bh70brqKUK14F1BrrPi29eaKfG+Gu
19 | MFtXdBG2a7OtPmw3yuKmq9Epv6B0mP6E5KSdvSRSqJWtGcA6wRS/wDzXJENHp5re
20 | 9Ism3CYydpy0GLRA5wo4fPB5uLdUhLEUDvh2KK//fMjja3o0L+SNz8N0aDZyn5Ax
21 | CU9RB3EHcTecFgoy5umRj99BZrebR1NO+4gBrivIfdvD4fJNfNBHXwhSH9ACGCNv
22 | HnXVjHQF9iHWApKkRIeh8Fr2n5dtfJEF7SEX8GbX7FbsWo29kXMrVgNqHNyDnfAB
23 | VoPubgQdtJZJkVZAkaHrMu8AytwT62Q4eNqmJI1aWbZQNI5jWYqc6RKuCK6/F99q
24 | thFT9gJO17+yRuL6Uv2/vgzVR1RGdwVLKwlUjGPAjYflpCQwWMAASxiv9uPyYPHc
25 | ErSrbRG0wjIfAR3vus1OSOx3xZHZpXFfmQTsDP7zVROLzV98R3JwFAxJ4/xqeON4
26 | vCPFU6OsT3lWQ8w7il5ohY95wmujfr6lk89kEzJdOTzcn7DBbUru33CQMGKZ3Evt
27 | RjsC7FDbL017qxS+ZVA/HGkyfiu4cpgV8VUnbql5eAZ+1Ll6Dw==
28 | =hdPa
29 | -----END PGP PUBLIC KEY BLOCK-----
30 |
--------------------------------------------------------------------------------
/roles/yum/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for yum
3 |
--------------------------------------------------------------------------------
/roles/yum/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: your name
4 | description:
5 | company: your company (optional)
6 | # Some suggested licenses:
7 | # - BSD (default)
8 | # - MIT
9 | # - GPLv2
10 | # - GPLv3
11 | # - Apache
12 | # - CC-BY
13 | license: license (GPLv2, CC-BY, etc)
14 | min_ansible_version: 1.2
15 | #
16 | # Below are all platforms currently available. Just uncomment
17 | # the ones that apply to your role. If you don't see your
18 | # platform on this list, let us know and we'll get it added!
19 | #
20 | #platforms:
21 | #- name: EL
22 | # versions:
23 | # - all
24 | # - 5
25 | # - 6
26 | # - 7
27 | #- name: GenericUNIX
28 | # versions:
29 | # - all
30 | # - any
31 | #- name: Fedora
32 | # versions:
33 | # - all
34 | # - 16
35 | # - 17
36 | # - 18
37 | # - 19
38 | # - 20
39 | #- name: opensuse
40 | # versions:
41 | # - all
42 | # - 12.1
43 | # - 12.2
44 | # - 12.3
45 | # - 13.1
46 | # - 13.2
47 | #- name: Amazon
48 | # versions:
49 | # - all
50 | # - 2013.03
51 | # - 2013.09
52 | #- name: GenericBSD
53 | # versions:
54 | # - all
55 | # - any
56 | #- name: FreeBSD
57 | # versions:
58 | # - all
59 | # - 8.0
60 | # - 8.1
61 | # - 8.2
62 | # - 8.3
63 | # - 8.4
64 | # - 9.0
65 | # - 9.1
66 | # - 9.1
67 | # - 9.2
68 | #- name: Ubuntu
69 | # versions:
70 | # - all
71 | # - lucid
72 | # - maverick
73 | # - natty
74 | # - oneiric
75 | # - precise
76 | # - quantal
77 | # - raring
78 | # - saucy
79 | # - trusty
80 | #- name: SLES
81 | # versions:
82 | # - all
83 | # - 10SP3
84 | # - 10SP4
85 | # - 11
86 | # - 11SP1
87 | # - 11SP2
88 | # - 11SP3
89 | #- name: GenericLinux
90 | # versions:
91 | # - all
92 | # - any
93 | #- name: Debian
94 | # versions:
95 | # - all
96 | # - etch
97 | # - lenny
98 | # - squeeze
99 | # - wheezy
100 | #
101 | # Below are all categories currently available. Just as with
102 | # the platforms above, uncomment those that apply to your role.
103 | #
104 | #categories:
105 | #- cloud
106 | #- cloud:ec2
107 | #- cloud:gce
108 | #- cloud:rax
109 | #- clustering
110 | #- database
111 | #- database:nosql
112 | #- database:sql
113 | #- development
114 | #- monitoring
115 | #- networking
116 | #- packaging
117 | #- system
118 | #- web
119 | dependencies: []
120 | # List your role dependencies here, one per line. Only
121 | # dependencies available via galaxy should be listed here.
122 | # Be sure to remove the '[]' above if you add dependencies
123 | # to this list.
124 |
125 |
--------------------------------------------------------------------------------
/roles/yum/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for yum
3 | # vim: set ft=ansible:
4 |
5 | - block:
6 | - name: Ensure fastestmirror is disabled
7 | lineinfile:
8 | dest: /etc/yum/pluginconf.d/fastestmirror.conf
9 | regexp: '^enabled='
10 | line: 'enabled=0'
11 | state: present
12 |
13 | - name: Manage base repos
14 | template:
15 | src: CentOS-Base.repo.j2
16 | dest: /etc/yum.repos.d/CentOS-Base.repo
17 | owner: root
18 | group: root
19 | mode: 0644
20 |
21 | when: ansible_distribution == 'CentOS'
22 |
23 | - name: Put EPEL GPG key in place
24 | copy:
25 | src: RPM-GPG-KEY-EPEL-7
26 | dest: /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
27 | owner: root
28 | group: root
29 | mode: 0644
30 |
31 | - name: Enable extra Yum repositories
32 | template:
33 | src: template.repo.j2
34 | dest: "/etc/yum.repos.d/{{ item.label }}.repo"
35 | owner: root
36 | group: root
37 | mode: 0644
38 | with_items: "{{ yum_repos | default([]) }}"
39 |
--------------------------------------------------------------------------------
/roles/yum/templates/CentOS-Base.repo.j2:
--------------------------------------------------------------------------------
1 | # CentOS-Base.repo
2 | # {{ ansible_managed }}
3 |
4 | [base]
5 | name=CentOS-$releasever - Base
6 | mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
7 | #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
8 | gpgcheck=1
9 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
10 | enabled={{ yum_enable_base | default("0") }}
11 |
12 | #released updates
13 | [updates]
14 | name=CentOS-$releasever - Updates
15 | mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
16 | #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
17 | gpgcheck=1
18 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
19 | enabled=0
20 |
21 | #additional packages that may be useful
22 | [extras]
23 | name=CentOS-$releasever - Extras
24 | mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
25 | #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
26 | gpgcheck=1
27 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
28 | enabled=0
29 |
30 | #additional packages that extend functionality of existing packages
31 | [centosplus]
32 | name=CentOS-$releasever - Plus
33 | mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
34 | #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
35 | gpgcheck=1
36 | enabled=0
37 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
38 |
39 |
--------------------------------------------------------------------------------
/roles/yum/templates/template.repo.j2:
--------------------------------------------------------------------------------
1 | # {{ ansible_managed }}
2 | [{{ item.label }}]
3 | name={{ item.name }}
4 | {% if item.baseurl is defined %}
5 | baseurl={{ item.baseurl }}
6 | {% elif item.mirrorlist is defined %}
7 | mirrorlist={{ item.mirrorlist }}
8 | {% endif %}
9 | enabled={% if item.enabled %}1
10 | {% else %}0
11 | {% endif %}
12 | gpgcheck={% if item.gpgcheck %}1
13 | gpgkey={{ item.gpgkey }}
14 | {% else %}0
15 | {% endif %}
16 |
--------------------------------------------------------------------------------
/roles/yum/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for yum
3 |
--------------------------------------------------------------------------------
/scripts/ec2_bootstrap.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Inserted into ec2 instance user-data - so is executed on boot.
3 | # Nice way to bootstrap a vanilla ec2 AMI by talking to Ansible Tower.
4 | # To understand Tower callbacks see http://docs.ansible.com/ansible-tower/latest/html/userguide/job_templates.html#provisioning-callbacks
5 |
6 | # Enabled pipelining for Ansible
7 | /usr/bin/perl -ni -e 'print unless /^Defaults \s+ requiretty/x' /etc/sudoers
8 |
9 | # Tower callback
10 | domain=${DOMAIN:-bovine.cow}
11 | tower=$(dig +short _cm._tcp.${domain} srv | awk '/^0/ {print $4}')
12 | request=($(dig +short ${domain} txt | tr -d '"'))
13 | template_key=${request[0]}
14 | template_id=${request[1]}
15 |
16 | if [[ -z ${tower} ]]; then
17 | logger 'ansible: could not find tower host'
18 | exit 1
19 | fi
20 |
21 | retry_attempts=10
22 | attempt=0
23 | while [[ $attempt -lt $retry_attempts ]]
24 | do
25 | status_code=`curl -s -i --data "host_config_key=$template_key" http://$tower/api/v1/job_templates/$template_id/callback/ | head -n 1 | awk '{print $2}'`
26 | if [[ $status_code == 202 ]]
27 | then
28 | exit 0
29 | fi
30 | attempt=$(( attempt + 1 ))
31 | logger "bootstrap: ${status_code} received... retrying in 30 seconds (Attempt ${attempt})"
32 | sleep 30
33 | done
34 | exit 1
35 |
--------------------------------------------------------------------------------
/scripts/tower_setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | tower-cli project create --name Demos --organization "Default" --scm-type git --scm-url https://github.com/phips/ansible-demos --scm-update-on-launch 0
4 | tower-cli credential create --user admin --name vagrant-ssh --kind ssh --username vagrant --ssh-key-data=keys/vagrant_dsa
5 | tower-cli inventory create --name VMware --organization "Default"
6 |
7 | tower-cli group create --name Demo --inventory Local --source manual
8 | tower-cli job_template create --name "VMware - Ping" --description "Ping all hosts in inventory" --job-type run --inventory VMware --project Demos --playbook plays/ping.yml --machine-credential vagrant-ssh --forks 10 --verbosity default
9 |
--------------------------------------------------------------------------------