Commit Graph

66 Commits

Author SHA1 Message Date
Ian Wienand e5e1127122 Add delete to synchronize
Since I53cb63ffa4ae50575d4fa37b24323ad13ec1bac3 some puppet runs are
failing because system-config:playbooks/roles/set-hostname moved to
roles/set-hostname and became a symlink.  rsync refuses to overwrite
the directory with a symlink because it seems to not be empty, because
we never removed the files in it.

Handle the possibility of things moving around like this by
specifying delete so old files are cleared out.

Finally set manifest_base dir ownership and mode to address linter E208.

Depends-On: https://review.opendev.org/762181
Change-Id: I249d713214d8383a3ccfe1a400404cbdcb97dcc6
2020-11-10 09:48:56 -08:00
Monty Taylor eafdbf9593 Add flag to control logging the rsyncs
rsyncing the puppet modules can be super chatty and not super
interesting. Add a flag to turn it off.

Change-Id: I7206955aeb335adafb8625c89d8b8a70078d666c
2020-04-30 08:45:59 -05:00
Monty Taylor 0505f79daa Add color parameter
When we're logging inside of ansible, turning off ansi colors can
be nice. Especially inside of Zuul.

Change-Id: I719ebb106fbb31795cc02c9504507bdae607bcdd
2020-04-21 16:04:48 -05:00
Zuul 7570d49d8e Merge "Revert "Don't log puppot module sync"" 2019-07-18 16:37:41 +00:00
Andreas Jaeger 7a9fd23801 Fix ansible-lint
The current tests never fail, change ansible-lint invocation so that it
fails - and fix problems.

Change-Id: I6aeb1e3a4c28af71a858ec83c21f4dbb5e7ef97f
2019-05-13 18:30:12 +02:00
Colleen Murphy ac51f0245b Revert "Don't log puppot module sync"
This reverts commit 7b47277e3e.

It turns out that for some reason this boring operation does actually go
wrong[1], and if logging doesn't happen then we don't know why.

[1] http://logs.openstack.org/00/616000/6/check/infra-puppet-apply-4-ubuntu-xenial/7379d8c/applytest/puppetapplytest44.final.out.FAILED

Change-Id: I2ce9c3d79385fc0a01b3a5fc85fa4bf4128c25bc
2019-01-03 15:09:50 +01:00
Clark Boylan 98b7ea710b Fix ansible block, always, when syntax
Newer ansible (2.7) is far more picky about always blocks being a part
of block blocks. This means you cannot have a set of when conditions
apply to a standalone always block. Fix our use of this by putting our
always block in the run puppet block then move the always tasks into a
block of their own with a condition set.

Change-Id: I50988b6b312e4d00b73ca4454e0420913d4ae181
2018-09-12 13:08:28 -07:00
James E. Blair 7b47277e3e Don't log puppot module sync
This is boring.  The output is voluminous.

Change-Id: Ib905311a2b3c4eb9a0316f3863aa688b9ed07c55
2018-08-17 14:02:48 -07:00
Zuul 3bf4b22034 Merge "Make sure target manifest directory exists" 2018-08-17 20:44:43 +00:00
Zuul a0ce4c7317 Merge "Allow overiding the remote hieradata link dest" 2018-08-17 20:44:43 +00:00
Monty Taylor ffbb43a218
Make sure target manifest directory exists
On a bare system, bridge.o.o will be trying to rsync /opt/system-config/
to /opt/system-config/production - but if /opt/system-config doesn't
exist on the remote host, the rsync will fail. Make sure we create the
directory.

Change-Id: Id56a537fe2352c099b81559eb4032138ba108bed
2018-08-17 13:58:25 -05:00
Monty Taylor 7fc585e1ab
Allow overiding the remote hieradata link dest
In order to support the layouts being different on the management server
and the remote nodes, we need to also be able to override the location
of the link that gets made. Add a variable that defaults to the old
value.

Change-Id: I7434c1b1a9d79f04b3e872e750057d69490e80e0
2018-08-17 13:43:46 -05:00
Zuul 6e8b8a56b9 Merge "Add ability to override mgmt manifest path" 2018-08-17 17:45:44 +00:00
Monty Taylor 0a3c32b5ac
Add ability to override mgmt manifest path
We have it currently hardcoded that the manifests on the management
server are going to have an environment path. Add a variable to allow
override of that idea.

Change-Id: I226c030332ff93c3ee74650c7ab725994971f007
Needed-By: https://review.openstack.org/592763
2018-08-17 05:21:53 -05:00
Zuul 05fb2ce4e4 Merge "Allow setting puppet_version explicitly" 2018-08-16 16:22:01 +00:00
Monty Taylor d8a1943081
Change include_tasks back to include
The ansible on puppetmaster is too old for this.

Change-Id: I49458188e5ddd61bba95c9eb28792364008389c6
2018-08-15 18:32:38 -05:00
Monty Taylor 745913a3c2
Allow setting puppet_version explicitly
If we set puppet_version as an inventory variable, then we can drive
behavior from that variable, including updating puppet. Add the ability
to set it here. A followup change in system-config will start setting
it, but starting off it should be a no-op.

Change-Id: I773ba3a2137b62ae2b3440dd02b3cdfb2099a62d
2018-08-15 14:24:33 -05:00
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