Commit Graph

49 Commits

Author SHA1 Message Date
Monty Taylor 92d5d596b9
Update yaml style to be consistent with infra yaml
Infra has adopted the approach of indenting lists an extra level
instead of starting their '-' at the same level as the parent element.
Additionally, Infra uses .yaml extensions instead of .yml extensions.
This role predates Infra having enough ansible to have opinions, so
update it to match current practice.

Also, while we're in there, update when clauses that have an 'and' in
them to just use the list form of when, and change 'include:' to
'include_tasks:'.

Change-Id: Icbeaf99c4d103091ee094e2fa219d7e16229b998
2018-08-09 09:04:06 -05:00
Monty Taylor 57873cfa78
Allow explicit override for mgmt_hieradata
ansible-role-puppet attempts to infer where it should copy hieradata
from based on puppet3 or puppet4. However, for hosts that are not
running puppet themselves this isn't going to work very well. Allow a
user to set mgmt_hieradata explicity.

Change-Id: Ie533da9af71ab84ce6e95dc63ceb8426740f53a3
2018-08-07 17:23:43 -05:00
Monty Taylor 24eb60b34d
Reorganize hieradata to match ansible variables
We are already organizing our hiera content basically the same way as
ansible needs for variables to be provided. If we reorganize the
directories slightly (to be coordinated with dirs on puppetmaster)
then we can have a single directory do double-duty.

Change-Id: I6ac90a7439ed8a5d9433d9526f37e44668b360ff
2018-08-02 13:11:29 -05:00
Clark Boylan 7fbe25598b Fix hieradata lookup paths
This requires we get the magical symlink between hieradata in
/opt/system-config to line up with the actual on disk environment
specific hiera location which differs between puppet 3 and 4.

Change-Id: Id4d7a0af72efddb758d94c6437bb1c331d12f406
2018-04-25 12:25:59 -07:00
Clark Boylan c95f026c14 Add some missing /'s and +'s to fix hieradata pathing
These were missed when the puppet4 support was added.

Change-Id: I7f7153093aaf46d5bbdb620228cf1c7fce3650e1
2018-04-25 11:32:57 -07:00
Colleen Murphy 4d64868882 Don't hardcode puppet-3-specific config paths
This patch ensures that hiera data and puppet modules, and puppet config
are copied to the right directory depending on the current puppet
version. Since it's possible for the ansible management server and the
managed nodes to have different puppet versions, we need to account for
the possibility that the source and destination paths might be
different. We also don't need to hardcode the various config paths in
config or manage environments since we're using the defaults and
hardcoding them would make them incorrect for one or the other puppet
versions.

Change-Id: I164f91f9a7942e8c5f059652634ec1078ae41aae
2018-04-22 00:13:21 +02:00
Paul Belanger edb0e245d5 Expose puppet_timeout variable
It is possible we want our puppet role to run longer then 30mins,
expose the ability for a user to change it.

Change-Id: Id42ba80a5118a9f93e45619ac6ecc5baa774549a
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-01-12 14:14:56 -05:00
James E. Blair fccf47a713
Add debug argument
To run puppet in debug mode.

Change-Id: I00baef254db2f9eaee23fb9eacded8efc5a2afc4
2016-10-01 08:11:13 -07:00
James E. Blair b4f591b72d
Add noop argument
check_mode causes other things that we may want to actually happen
(such as setting up hiera) not to run.  This way we can do all of
those but still run puppet in noop.

Change-Id: I32f07a032d28f5c5d04e9eeb50b94f7c0a57ce53
2016-10-01 08:11:12 -07:00
Monty Taylor e46f449ca5
Pass environment to puppet module
Change-Id: I6be88234eab32844f395df7658952b1cef944bd8
2016-10-01 08:11:12 -07:00
Paul Belanger 330bfde495 Remove connection: localhost
We are running into OOM issues on puppetmaster.o.o and our current
thought process is because we are using connection: local, this is
causing ansible to fork many times over, which is an expensive task.

Change-Id: I3f2646765f0b442f7533aa7be44fc42b1916f172
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-05-02 17:36:05 +00:00
Jenkins f20c52a44b Merge "Don't post reports if there are no reports to post" 2016-03-09 16:42:03 +00:00
Monty Taylor 3408a8f0f5 Don't post reports if there are no reports to post
If we don't produce any reports, don't post them.

Change-Id: I06f0bf47a1761f90118ad45a99e33f112699a4c7
2016-03-09 10:23:45 -06:00
Clark Boylan 642add61b3 Always puppetboard upload if puppetboard defined
We should always upload to puppetboard (even when puppet fails) if the
puppetboard server is defined. This allows puppetboard to learn of both
successful and failed puppet runs.

Change-Id: I62a78200052443997baf549256c78b38bd37f63e
2016-03-07 21:40:11 -08:00
Jenkins d351b3e07e Merge "Safely fail when logs cannot be found" 2016-03-02 17:56:44 +00:00
Yolanda Robla 139ca911ab Safely fail when logs cannot be found
On first runs, this logfile is not going to be found. This
is causing ansible to crash and stop applying puppet in consecutive
nodes.

Add a condition to safely fail, and abort play if no files can
be found.

Change-Id: I22a5ebbcaa603b25920fd638211f3663e81e09b0
2016-02-26 01:59:49 +01:00
Yolanda Robla a0faab2306 Force interpreting to boolean in manage_config
If not, it is picking a False value as string, and
is applying to all instances.

Change-Id: I0a102bcdfe59a9a9426ff46d2c164e15de6288fd
2016-02-25 22:58:20 +01:00
Jenkins ec4e488890 Merge "Fix deprecation warning" 2016-02-25 21:12:02 +00:00
Jenkins 9a2978476c Merge "Conditionally manage puppet config files" 2016-02-25 19:31:07 +00:00
Monty Taylor af32021ef2 Fix deprecation warning
Bare variables are deprecated in Ansible now, we should wrap them
in jinja stuff so that the deprecation warning goes away.

Change-Id: Ib2bd6ae508eacaa274c16e08fe3ef384e4700776
2016-02-25 11:10:50 -06:00
Monty Taylor 0545b55d8d Report as puppet_report_as instead of fqdn
We want to report as the puppetmaster, not as the host in question.

Change-Id: I0462a898502ad709e046be76c19c9e11f4617335
Depends-On: I290ad569283390bac2a74a9991331c9e86821ab7
2016-02-24 11:47:43 -06:00
Jenkins 54064729df Merge "Make puppet logout destination configurable" 2016-02-24 14:53:11 +00:00
Spencer Krum 9c526e11ce Ansible-puppet must create the reports dir
Previously the puppetmaster was creating reports directories. Now that
ansible is in charge, it must do it.

Change-Id: I26e1e2ebd45f0c7d75652f9acb9999aee8a3e40c
2016-02-23 15:11:00 -08:00
Monty Taylor d028a88572 Make puppet logout destination configurable
So that we can upstream this, make the log output from the puppet
command configurable with a default value being what it was for us
before. As part of that, restore returning stdout and stderr even though
they'll be empty.

Depends-On: I22b1d0e1fb635f2c626d75a11764725c8753bf24
Change-Id: I245ac8c3533cce4a598909c03e1f2ba0f7b06850
2016-02-09 10:36:16 -06:00
Spencer Krum 25cc2c9470 Conditionally manage puppet config files
Allows ansible-puppet to configure settings for
puppet when manage_config flag is set.

Co-Authored-By: Yolanda Robla <info@ysoft.biz>

Change-Id: I6cb8dff569f2cca8bca7359412d01cc7ec009c54
2016-02-05 09:22:47 +01:00
Monty Taylor f5ec19782a Don't try to make a link before the directory
We need to copy the puppet modules BEFORE we make a link to the
hieradata into the manifest_base directory. Doh.

Change-Id: Ic62f32f50012b9787773fb436ce50a616adf42f7
2016-01-22 18:55:57 -05:00
Monty Taylor d0854ce5d5 Properly suppress undefined warning
Although there is no harm in this case, the task in question has a
with_items on a variable that is not set because the previous task did
not run. In this case, it did not run because it's in a block with a
when that did not match - but in the context of a task, when is applied
after with_items and is applied to each with_item, rather than to the
task as a whole. To make the task complete, add a |default() jinja
filter so that the undefined variable is replaced with a defined but
empty value.

Change-Id: I2029b7cac3634a5fe7232f6f823e803e1f4250e6
2016-01-19 08:03:57 -05:00
Monty Taylor 69cf3cd23c module is a variable, not a name prefix
Turns out we want module.exit_json, not module_exit_json. Oops. Also,
two other small ansible task cleanups found looking at the runs.

Change-Id: I8737d5b1e675bfb89ee1db2f2c434c601d419f5e
2016-01-18 19:14:36 -05:00
Monty Taylor 8d50410c04 Rename hieraenvironment to puppet_environment
It's actually a puppet environment, not a hiera environment. So let's
call it that, otherwise nibalizer will be sad.

Change-Id: I0175596329e9f7eb7a079513bfa17dd18d53b753
2016-01-18 17:10:39 -05:00
Monty Taylor fe9ad5c0ea Collapse redundant hieradata tasks
We can make the task file slightly smaller by using a with_items.

Change-Id: I39f79730b56c40ed2dc0f00a0c354f6e16e12cda
2016-01-14 15:39:25 -05:00
Monty Taylor c25e5aa543 Perform filepath checking in python
Checking for all of the paths in ansible leads to a TON of skipped lines
in the ansible log. That's not good for anybody, and we're already
processing the paths in python - let's do a quick filter to check for
which ones exist before returning them.

Change-Id: Iddf3c56c802598329a18c374cf667a6f165f78ca
2016-01-14 15:39:25 -05:00
Monty Taylor 6260b48b9e Clean up codestyle in conditionals
Based on some earlier review feedback, add defaults for copy_puppet and
copy_hieradata so that we don't have to check if they are defined. Also,
split the and condition in when to be a list of conditions.

Change-Id: I68bd332bdfae6880b582203161798f709dc45a45
2016-01-14 15:39:25 -05:00
Monty Taylor 368cbb2ba6 Update to use blocks from ansible 2.0
One of the cool shiny new features from ansible 2.0 are "blocks", which
allow you to group like tasks.

Change-Id: If0a7c07140db15c9ae7c1671e6181ac7a4553f25
2016-01-14 15:39:24 -05:00
Monty Taylor b53fca3ab7 Add puppet module sync to the role
If a host fails at copying the puppet, the host should likely not
run puppet.

Change-Id: I22b7a21778d514a0a1ab04a76f03fdc9c58a05b3
2016-01-14 15:38:45 -05:00
Monty Taylor 5155e7c3a1 Add whitespace between tasks for better readability
There are absolutely no substantive changes in this patch.

Change-Id: Ia1f3cf005f272b269093348507db4e38735e20d3
2015-12-01 10:31:36 -06:00
Monty Taylor f23f6d6d98 Clear up some issues with fqdm vs. hostname
When we're using openstack inventory, inventory_hostname is the uuid of
the openstack server, whereas ansible_fqdn is the actual fqdn of the
host. So for things where it's important that the variable resolve to
the hostname (like looking up puppet reports on disk, we need to use
nsible_fqdn). For things like looking up hostvars in the hostvars dict,
we nede to continue using inventory_hostname.

Further, when we _delegate_to_ like we do for the post-to-puppetdb step,
ansible_fqdn is the name of the host delegated to - so it's not needed
to pass in the whoami value.

Change-Id: I420112668a016988ddb397e798f6ba983291d2f8
2015-12-01 10:15:20 -06:00
Monty Taylor 92c56e9e99 Fetch puppet logs and facts after puppet run
After we run puppet, we should copy the puppet logs back to the
host so that we can inject them into puppetdb.

Change-Id: I51332b02950d6fb4d4ff0c1edeca774d84df4270
2015-11-25 08:40:18 -05:00
Monty Taylor 22e4e04224 Introduce space in a very important place
Change-Id: I8bf1170c1298d028cddc1a501a1e692b844a643d
2015-11-25 08:40:18 -05:00
Monty Taylor 64975e03e9 Test for copy_hieradata being set
Removing the default value from the variables file, while it allowed us
to set the value in our file, did not let the role run when the value
was not set. Test for being set.

Change-Id: Ibe3ccecdbb5ff31108c4a95c9f9a5ca367663603
2015-11-25 08:16:23 -05:00
Monty Taylor c904e4548a Remove stray debug lines
Change-Id: Ifc3682a491da1c5459f76661732bb02f95cf2901
2015-11-24 21:16:47 +00:00
Monty Taylor 560089427e Restrict the file list to when copy_hieradata
There is no need to run the file list when we're not copying hieradata.

Change-Id: I96fa275288f305c1821bf1355897db3ef4d1f3d8
2015-11-24 21:16:40 +00:00
Monty Taylor 43baef945f Use inventory_hostname to avoid fact gathering
ZOMG gathering facts takes FOREVER. Let's use inventory_hostname
instead of ansible_fqdn so that we don't have to gather them.

Change-Id: Ib531804a6c8a78f7a7f7d1b065295db5238912aa
2015-11-23 10:16:19 -05:00
Jenkins d48398a75a Merge "Copy in matching hiera files" 2015-11-23 09:37:24 +00:00
Monty Taylor c424d8b555 Copy in matching hiera files
Find any files that match common, $fqdn and $group in the hiera
structure and copy them to the target host's hiera structure so that
the puppet apply command can operate.

Change-Id: I833858e86b9e8fe0750642476f118ca7d0358380
2015-11-11 14:59:35 -08:00
Monty Taylor 23de9b1791 Default show_diff to false just for completeness
Change-Id: Ied12d4ad69f5e31da61b303a07adad6f47d237a1
2015-10-30 14:22:32 +09:00
Monty Taylor 3de3806503 Add support for running puppet apply
If a user passes in a path to a manifest file, run that instead of
running puppet agent.

Change-Id: I95f1cf59336869ec59a910baca95329698c7321f
2015-06-20 09:50:42 -04:00
Monty Taylor 4181ded937 Remove hiera data option
If you're passing in data directly from ansible, you're really passing
in facts. This will be followed by a patch that will copy hiera data
files.

Change-Id: Ib47347d7bbc5b9abeb71183be8e467a62f91d743
2015-06-20 09:50:42 -04:00
Monty Taylor eb5c691571 Add ability to run puppet with passed-in data
When we run puppet on the node, we may want to pass in parameters. There
are two different mechanisms that can be used for this, facter and
hiera. Allow users to pass in dictionaries of data containing key/value
pairs to either set ephemerally via facter environment variables, or
permanently by creating hiera files on disk so that subsequent runs will
keep those values.

Change-Id: Id99c3c2c20764ed4ba4259bd53f8067289374403
2015-03-11 11:13:01 -04:00
Monty Taylor 50173449a6 Add all of the files needed to make this a role
Similar to puppet modules, ansible roles can be uploaded to ansible
galaxy and can be consumed in a role-per-repo manner.
2015-02-22 22:59:39 -05:00