Commit Graph

29 Commits

Author SHA1 Message Date
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
Ian Wienand e9fc2df1bc Clear out old facts
In debugging why I631e3e3592a9be5c7da642cf34eec6d9758bf161 was not
rolling out to the zuul executors, I eventually found
/etc/facter/facts.d/ansible.json was present on a number of hosts and
effectively pinning the project-config checkout to an old reference.

Given the dates around file creation and the pinned change number, it
seems very likely something happened during the openstack->opendev
transition where some hosts had ansible run with a specific
project_config_ref set as a fact.  Although the fact is now unset,
nothing will ever clear the old ansible.json which keeps applying.

We could remove all stale files by hand; but a) it's not clear where
it ran (although likely only hosts starting with z*) and b) we leave a
chance for it to happen again.

We could clear this after every puppet run; but it seems like this
role should leave the system largely in the state it ran puppet in.

Thus this clears out the file before the puppet run if no facts are
given.  This should fix our immediate issue on all hosts.

Change-Id: I96adf4fb77f06b18fe73b6f10d1b07b7fe44385f
2019-05-30 07:35:21 +10:00
James E. Blair 8d0f0bfd0a Set facts type to dict
With newer versions of ansible, module arguments are assumed to
be strings unless otherwise specified.  Our 'facts' argument is
expected to be a dictionary, so tell ansible that.

Without this, the argument will arrive as a string and be written
to the facter file inside string quotes.  Facter will produce the
following error:

  undefined method `each' for #<String:0x000000016ee640>

Change-Id: Iea626466d0920349f434f678fe2f71cbee259383
2017-01-12 09:55:37 -08:00
Monty Taylor 1c69c305e7
Sync puppet module changes from upstream ansible
We keep a local copy of this file for operational purposes, but the
upstream one has grown a few things. Sync to make it easier to submit
our local changes upstream.

Change-Id: I84927750fce1a7c6101e8d5c131c0b13020bb6aa
2016-10-01 08:11:13 -07:00
James E. Blair e8632f41a4
Don't set detailed-exitcodes when noop
Change-Id: I3819ad5920a0a88b0b52ecb9b77a58c6d588fbdc
2016-10-01 08:11:13 -07: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
Clark Boylan 8cc1cd9126
Simplify puppet cmd generation
We were copy pastaing code in the puppet cmd generation for noop and
environment handling. Collapse that to make code easier to read and
hopefully avoid future bugs where only one side is edited.

Local testing shows that puppet parses commands like:

  puppet apply test.pp --noop

just fine.

Change-Id: Ie7665f72b9327b6b834d358699addf2c60a95ec0
2016-10-01 08:11:12 -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
James E. Blair 1a20bc89eb
Allow any logdest
Puppet's logdest option can also point to a file, so allow any
string through here.

Change-Id: I36fc99fa7e6169463acd24a5a6f4b54cf23849b7
2016-10-01 08:11:12 -07:00
Ramy Asselin 92737dfe27 Honor show-diff options with puppet apply
puppet apply ignores the show-diff option.
Update the code so that both puppet apply and puppet agent
support the show-diff option.

Change-Id: I5b59b8ba8e50a44458d01ec97113a2ce313c1d9a
2016-07-19 09:18:39 -07:00
Paul Belanger b6ebba9545
Call main() from a conditional
See ansible docs[1] for more information.

[1] http://docs.ansible.com/ansible/developing_modules.html

Change-Id: I21062e1eb47632ac39e35d7267dab96b62500743
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-05-26 13:31:11 -04:00
Jenkins 5af0d99453 Merge "The default for logdest needs to not be a list" 2016-02-24 19:37:51 +00:00
Monty Taylor fdc43c9f8a The default for logdest needs to not be a list
There are three possible values - none of them are a list.

Change-Id: Iade056998eeccb1845aa6232ea803073567add2f
2016-02-24 12:57:39 -06:00
Monty Taylor c64119b530 Sync with upstream ansible-modules-extras
The --show-diff option to puppet agent is show-diff, not show_diff.
Also, there is a doc string about which version logdest was added in.

These are not important for Infra. However, keeping in sync makes it
easier to track changes that might actually matter.

Change-Id: Id16b9d7510efa4b8f3645997617cd00ee870e83a
2016-02-24 08:57:45 -06: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
James E. Blair 403d157c45 Fix typo in puppet apply command
This was missing a terminal space which caused the command to be:

  --logdest syslog--no-noop

Change-Id: I13827a5ed30f782bdacc38acebf284d7226ebce9
2016-01-22 16:56:09 -08:00
James E. Blair 7fff1b962c Log puppet to syslog instead of json
Stop sending the complete puppet output back via json.  Do send
it to local syslog instead.

This is mostly because right now all of our puppet output is going
into a single very long json line in our log file.

Change-Id: Ie6d2d82def95ef2bb79ae862707218a44e0138ca
2016-01-21 18:07:37 -05:00
Monty Taylor e1c1430bd6 Sync with upstream ansible
The show_diff option is superseeded by a new built-in option in ansible
so does not need to be kept in the docs here.

Also, upstream needs the simplejson fallback. We do not, but keeping in
sync is easier.

Change-Id: I45a34614d08f4518f031c652915dae97cc3ccbed
2016-01-21 18:06:29 -05:00
Monty Taylor d049384a82 Don't use the timeout command if it's not there
The timeout command is there to improve life and workaround puppet
deficiencies. However, it's not working around deficiencies on systems
that do not have the timeout command if we blindly use it.

The puppet specific timeout options are more complex and out of scope of
this.

Issue: https://github.com/ansible/ansible-modules-extras/issues/1273
Change-Id: Id2afbe7a8d0a9b52295a36eb8bde4ffd40fa8c21
2015-11-27 17:57:17 +00:00
Monty Taylor ad8aab1470 The parameter is --server not -- server
We never noticed this because we have puppetmaster set in our
puppet.conf files.

Change-Id: Ic05896fecc08cc4143f878dd87189f0397252ebb
2015-11-25 08:40:18 -05:00
Monty Taylor b134ce47a8 Return stderr/stdout on changes too
If changes were made, you sometimes want info on what they were.

Change-Id: Ibdb662c0d66e73028211374ea58f106876d74b59
2015-11-25 08:40:18 -05:00
Monty Taylor 898ddbc0e3 Add space back
Change-Id: Ibf0d6f715e06a0f6d519a7be8a3166584bbc7217
2015-11-16 16:12:27 -05:00
Spencer Krum 854b97e9ea Fix pep8 warnings
Change-Id: I9f199dfa45885e51a925232fac54dabe7c844ed1
2015-11-12 22:43:52 -08:00
Joshua Hesketh 258d42aec6 Fix typos in documentation
Change-Id: If6a84b0f225a69183d0806fa55cea267475f7dc9
2015-10-28 11:47:04 +09:00
Monty Taylor 5259c2d672 Sync with ansible-modules-extras
The puppet module is now upstream. We'll keep a copy here until we've
installed 2.0 everywhere. But for now, just sync with what is
currently upstream.

Change-Id: I4ffe174f733f9392fb420e304c1b2a02860f9c39
2015-06-20 09:50:42 -04:00
Monty Taylor 5faac02239 Ensure filepath exists
Before we can write facter facts of hiera hieras, we need for the
directory to exist.

Change-Id: Id855da44d9e2cb06824ed3507158aeaa466768f7
2015-03-12 10:08:44 -04:00
Clark Boylan 226adc7f23 Its 0o not 0c to make an octal number
Change-Id: Ifa2fe70bbb170d2a9cffad5a5280dfa74b59230a
2015-03-11 14:22:34 -07: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