1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
Commit graph

237 commits

Author SHA1 Message Date
Michael DeHaan
ef28d62846 Update TestUtils.py
tests shouldn't be making symlinks to system dirs, also fixes unit test report on OS X.
2013-09-28 11:01:21 -04:00
Jasper Capel
d4dec5f577 Allow creating empty inventory
Instantiating the Inventory class with host_list=None now results in an
empty inventory instead of an error.
2013-09-25 15:00:35 +02:00
Michael Scherer
399d57a651 add more tests :
- test part of ansible.runner.filter_plugins.core
 - test ansible.utils.unfrackpath
2013-09-21 13:00:11 +02:00
James Cammarata
3b801dec72 Merge branch 'failed_when' of https://github.com/hnakamur/ansible into hnakamur-failed_when 2013-09-16 07:35:34 -05:00
James Cammarata
aac3090909 Merge branch 'play_remote_user' of https://github.com/bcoca/ansible into bcoca-play_remote_user 2013-09-16 05:55:14 -05:00
Hiroaki Nakamura
2357194b39 Add failed_when module variable.
Implementation note: Ternery operator trick for python prior to 2.5 is used.
(test and [when_true_value] or [when_false_value])[0]
http://stackoverflow.com/questions/394809/ternary-conditional-operator-in-python#comment1466794_394887
2013-09-10 08:34:01 +09:00
James Cammarata
8d0487c31e Removing broken tests for now 2013-09-09 15:16:17 -05:00
Brian Coca
d47c48e30a Added remote_user to plays
Still compatible with user: but deprecating it so we can have
a matching remote_user: in tasks, cannot be user: because of the
module of the same name. #3932

Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2013-09-07 16:34:22 -04:00
Michael Scherer
a0b73b18c3 add one last test, for combined range, which make ansible.inventory.expand_hosts
covered to 100%
2013-08-23 13:06:31 +02:00
Michael Scherer
64d35cb3b6 test that using non ordered range of char send a exception 2013-08-23 12:58:10 +02:00
Michael Scherer
4f69b63fec add test for incorrect format in range host 2013-08-23 12:51:17 +02:00
Michael Scherer
835fdd1ec2 add test for missing end in host range 2013-08-23 12:42:26 +02:00
Michael Scherer
2aea8a6368 add a test to verify ansible detect invalid range 2013-08-23 12:29:38 +02:00
Michael Scherer
7fec9c3eba add a test to cover bound stepping in inventory 2013-08-23 12:00:39 +02:00
James Cammarata
157b697a83 Merge branch 'always_run-6' of https://github.com/stoned/ansible into stoned-always_run-6 2013-08-22 12:10:28 -05:00
Michael Scherer
ddd582269c increase test coverage of inventory by around 5% according to nose 2013-08-21 08:03:41 +02:00
Stoned Elipot
f0743fc32a Introduce the 'always_run' task clause.
The 'always_run' task clause allows one to execute a task even in
check mode.

While here implement Runner.noop_on_check() to check if a runner
really should execute its task, with respect to check mode option
and 'always_run' clause.

Also add the optional 'jinja2' argument to check_conditional() :
it allows to give this function a jinja2 expression without exposing
the 'jinja2_compare' implementation mechanism.
2013-08-20 23:09:44 +02:00
Petr Svoboda
e3adfbf5f8 Add tests for undefined variable detection
Tests `test_playbook_undefined_varsX_fail` check if ansible detects
undefined variables when `error_on_undefined_vars` is enabled. These
tests fail without "Improve behavior with error_on_undefined_vars
enabled" patch.

Tests `test_playbook_undefined_varsX_ignore` check if ansible ignores
undefined variables when `error_on_undefined_vars` is disabled.

Also modify PlayBook._run_task_internal() so error_on_undefined_vars is
testable.
2013-08-20 00:40:49 -05:00
Michael Scherer
b655d5798b add tests for the -i option when used with raw string for ipv4
and ipv6 addresses.
2013-08-19 15:27:21 -05:00
Michael DeHaan
4bdbe4dc4f Remove some test prints 2013-08-10 17:37:04 -04:00
Michael DeHaan
76fd769704 Merge pull request #3685 from mspaulding06/indexed_items
Indexed items lookup plugin
2013-08-03 11:36:51 -07:00
Michael DeHaan
3ebbb56479 Merge pull request #3654 from MaxIV-KitsControls/devel
Fix nested loop for more than 3 elements
2013-08-01 17:11:26 -07:00
Matt Spaulding
b7154cf2cf Add tests for indexed_items lookup plugin 2013-07-28 14:16:25 -07:00
Vincent Hardion
09ef7751e1 Fix nested loop for more than 3 elements
- combine flatten list for each nested level instead once at the end
2013-07-24 14:19:13 +02:00
Stoned Elipot
a1503c4d59 stringify conditional before handing it to Jinja2 for evaluation.
This should fix simple conditionals like:

    when: ansible_selinux

While here add tests for ansible.utils.check_conditional() in
"jinja2_compare mode".
2013-07-23 22:24:53 +02:00
Michael DeHaan
88720516a1 Merge branch 'changed_when' of git://github.com/stoned/ansible into changed_when 2013-07-21 10:14:03 -04:00
Tin Tvrtkovic
4a732c1e9f Enabled the use of extra vars in playbook file paths when including playbooks from other playbooks. 2013-07-18 22:45:18 +02:00
Stoned Elipot
eb45f07ae3 Introduce 'changed_when' keyword to override a task's changed status with the evaluation of a Jinja2 expression 2013-07-14 21:07:45 +02:00
Stoned Elipot
baf868f825 Add test for 'ignore_errors:' 2013-07-01 02:31:16 +02:00
Dale Sedivec
b32131c867 expanduser on each component of plug-in paths
ansible.constants was calling expanduser (by way of shell_expand_path)
on the entire configured value for the library and *_plugins
configuration values, but these values have always been interpreted as
multiple directories separated by os.pathsep.  Thus, if you supplied
multiple directories for one of these values, typically only the first
(at least on *nix) would have e.g. "~" expanded to HOME.

Now PluginLoader does expansion on each individual path in each of
these variables.
2013-06-22 17:01:12 -05:00
George Miroshnykov
c642ba77ae Added basic support for hash_behaviour=merge in roles
Dict vars passed to roles are now properly merged
instead of simply overriding dict vars that are
coming from vars_files.
2013-06-19 09:14:20 +03:00
Michael DeHaan
4ae3ef8af9 Disable inventory test 2013-06-03 11:52:42 -04:00
Pol Llovet
4432c01ceb Handle '#' in var strings by splitting on ' #'
If someone has a " #" in a quoted var string, it
will interpret that as a comment and refuse to
load the inventory file due to an unbalanced
quote. Noisy failure > unexpected behavior.
2013-05-31 12:34:45 -06:00
Pol Llovet
ba78360c52 Remove inline comments from inventory tokenizing. 2013-05-30 14:12:23 -06:00
Michael DeHaan
a9fcea5893 Merge branch 'escape' of git://github.com/ngrilly/ansible into repr 2013-05-29 18:29:16 -04:00
Dale Sedivec
611d56dc4c Plug-ins loaded from top-level plug-in directory
PluginLoader._get_paths, as of 391fb98e, was only finding plug-ins that
were in a subdirectory of one of the basedirs (i.e. in a category
directory).  For example, action_plugins/foo.py would never be loaded,
but action_plugins/bar/foo.py would work.

This makes it so that "uncategorized" plug-ins in the top level of a
directory such as action_plugins will be loaded, though plug-ins in a
"category" subdirectory will still be preferred.  For example,
action_plugins/bar/foo.py would be preferred over action_plugins/foo.py.
2013-05-24 17:05:28 -05:00
Nicolas Grilly
75ceb80572 Escape args injected in new style modules 2013-05-24 01:01:07 +02:00
David Simon
190ce16bab Dealing with invalid symlinks and symlink permissions 2013-05-09 15:35:05 -04:00
Dale Sedivec
515fd9e915 copy action plug-in check mode respects force=no
The copy action accepts force=no, which tells it not to replace an
existing file even if it differs from the source.  The copy action
plug-in wasn't respecting this option when operated in check mode, so it
would report that changes are necessary in check mode even though copy
would make no changes when run normally.

Runner._remote_md5 was changed to make the logic for setting rc perhaps
a little more clear, and to make sure that rc=0 when the file does not
exist.
2013-04-16 20:22:51 -04:00
Michael DeHaan
7c6341718e Merge branch 'combine_vars' of git://github.com/laggyluke/ansible into exp
Conflicts:
	lib/ansible/inventory/vars_plugins/group_vars.py
	lib/ansible/runner/__init__.py
	lib/ansible/utils/__init__.py
	test/TestPlayBook.py
2013-04-16 20:06:06 -04:00
willthames
377bc31311 Prevent premature substitution of variables into tasks
As documented in #2623, early variable substitution causes when_
tests to fail and possibly other side effects.

I can see the reason for this early substitution, likely introduced
in 1dfe60a6, to allow many playbook parameters to be templated.
This is a valid goal, but the recursive nature of the utils.template
function means that it goes too far.

At this point removing tasks from the list of parameters to be
substituted seems sufficient to make my tests pass. It may be the
case that other parameters should be excluded, but I suspect not.

Adding a test case. I would prefer to analyse not just the aggregate
statistics but also whether the results are as expected - I can't
see an easy way to do that with the available callbacks at present.
2013-04-12 09:17:03 +10:00
Michael DeHaan
81a926547c Some continued work on new-style templates and associated test code changes. Legacy template functions
are marked with "legacy_" for possible future removal.
2013-04-10 19:09:57 -04:00
Michael DeHaan
b09ef21ec9 Add code to flag legacy templating like $foo.{bar} as deprecated in favor of Jinja2 {{ foo.bar }} so we
can remove the legacy system at a later date.
2013-04-10 17:52:35 -04:00
Michael DeHaan
e8085ad40c Since we removed the (undocumented) playbook include + with_items code, fix the tests to
compensate.
2013-04-10 15:08:18 -04:00
willthames
9d87733f98 Test case and fix for shlex.split unicode bug
When operating on a unicode string in python 2.6, shlex.split returns
a result that does not work with the file constructor.

To reproduce this requires a task include that is templated (this is
because the templated string is a unicode result, whereas a non-
templated string is a non-unicode string)

    [will@centos6.3] $ python
    Python 2.6.6 (r266:84292, Sep 11 2012, 08:34:23)
    [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import shlex
    >>> shlex.split(u'abc')
    ['a\x00\x00\x00b\x00\x00\x00c\x00\x00\x00']

    [will@fedora17] $ python
    Python 2.7.3 (default, Jul 24 2012, 10:05:38)
    [GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import shlex
    >>> shlex.split(u'abc')
    ['abc']

The proposed fix (coercing the include parameters to string before the
shlex.split) may not be ideal but it does fix the bug for my test case.
2013-04-08 14:47:43 +10:00
George Miroshnykov
6826aa7360 Tweaked merge_hash to also affect Runner behavior 2013-04-06 13:06:38 +03:00
Michael DeHaan
7116c83c4a Standardize test output 2013-04-05 13:13:33 -04:00
Michael DeHaan
2c783c7145 Disable a test temporarily 2013-04-05 13:12:46 -04:00
Michael DeHaan
cdaa2085ee Preliminary ability to use Jinja2 {{ }} to replace ${foo.bar} in playbooks. Can't use both at the same time per line. 2013-04-03 01:04:16 -04:00
tin
ca581840ef Added additional lineinfile documentation.
A little more unit testing.
2013-03-27 01:31:58 +01:00