Michael DeHaan
c41a23a35a
Complete removal/refactoring of conditional deprecations.
2014-01-03 19:23:19 -05:00
Michael DeHaan
8e5b7d3095
Remove code underlying when_* and only_if, which are deprecated features slated for removal in the 1.5 release.
2014-01-03 19:13:21 -05:00
Michael DeHaan
28b9fd4e30
We have had only_if, when_foo, etc, deprecated for a while and said they would be removed in 1.5. Now they are, with friendly error messages still.
...
Users of these features should use "when:" as documented at docs.ansible.com.
Similarly, include + with_items has been removed. The solution is to loop
inside the task files, see with_nested / with_together, etc.
2014-01-03 13:47:54 -05:00
James Tanner
21fdb2bbc7
Fixes #5200 Handle template contents with unicode strings better
2014-01-03 11:18:20 -05:00
Michael DeHaan
de2ffc1276
Don't need to document these guys.
2014-01-02 17:55:59 -05:00
Janez Nemanic
8752ae6909
Fix for issue #4730 - stacktrace when deferenencing a non-existent group
2013-12-02 18:25:43 +01:00
James Cammarata
9101c2af98
Fix traceback in template error detection code
...
Fixes #5081
2013-11-29 08:47:54 -06:00
James Cammarata
1f80aa768a
Fix bug in error detection code, where a zero-length string was causing a traceback
...
Fixes #5064
2013-11-27 11:57:15 -06:00
Antonio Zanardo
8dbd91b5ad
fix typo in deprecation warning
2013-11-23 19:15:51 -02:00
Michael DeHaan
fc909b453f
Make the legacy template detection system not hit a false positive when
...
replacing a \$ with $.
2013-11-18 17:51:57 -05:00
jctanner
8e8c8efc8f
Merge pull request #4769 from alanfairless/more-password-entropy-revised
...
Revised patch for more password entropy
2013-11-07 13:39:05 -08:00
jctanner
8d9b53b445
Merge pull request #4733 from sivel/4323-sudo-pass
...
Add ansible_sudo_pass hostvar support. Fixes #4323
2013-11-05 15:01:19 -08:00
Michael DeHaan
eab6737209
Clarify a warning message.
2013-11-03 12:47:07 -05:00
Alan Fairless
0824f004d9
Revised patch for more password entropy
2013-11-01 09:51:35 -05:00
Michael DeHaan
bbf212a268
Simplify the way the debug: var=varname plugin works.
2013-10-31 19:35:50 -04:00
Michael DeHaan
8b2cd6413b
When inside an apt or yum task account for multiple conditionals. Fixes 4745.
2013-10-31 17:19:58 -04:00
Michael DeHaan
90cce35919
This allows variable references in playbooks in a different way.
2013-10-30 21:26:16 -04:00
Matt Martz
ea2ec6237a
Add ansible_sudo_pass hostvar support
2013-10-30 13:18:35 -05:00
James Tanner
d154bf8781
Revert templating enhancements from 73dbab70
e6c28658
d409352c
9858b1f2
4587528b
9b1fe455
214b0b05
8d3db803
7f9504d1
5031104c
35cb9dc2
2bd8cb57
1e85c754
2013-10-30 10:50:16 -04:00
Michael DeHaan
73dbab702f
Don't run lookup plugins while trying to simplify the input datastructure.
2013-10-28 09:08:53 -04:00
Michael DeHaan
4587528b99
Fix typo in comment.
2013-10-26 19:32:07 -04:00
Michael DeHaan
d409352c85
Remove some interior imports in the code. Not really needed but nice to have them gone.
2013-10-26 19:26:43 -04:00
Michael DeHaan
e6c28658b4
Add in some code to pre-template datastructures prior to template usage. This prevents a certain class of error
...
where filter evaluations can happen too early due to the template engine recursion being a bit limited.
Addresses #4662
2013-10-26 19:11:13 -04:00
Michael DeHaan
9858b1f2f3
Enable imports to work on a snippet based system, allowing for instance a library of common EC2 functions
...
to be reused between modules. See library/system/service and library/system/ping for initial examples. Can
work the old way to just import 'basic', or can import the new way to import multiple pieces of code from
module_utils/.
2013-10-26 11:09:30 -04:00
James Tanner
9b1fe455c6
Fixes #4549 Do not call lookup plugins when templating a task's name
2013-10-25 10:27:38 -04:00
James Tanner
214b0b052c
Fixes #4608 add lookup to template globals to make plugins work again
2013-10-22 12:00:54 -04:00
Michael DeHaan
2bd8cb5790
Make the deprecation detector in templates more accurate. Fixes #4514 .
2013-10-19 14:14:16 -04:00
Michael DeHaan
64bbeb9d24
Suggest fixing unbalanced quotes in a bit less cases. Fixes #4501
2013-10-19 13:57:28 -04:00
Michael DeHaan
7f9504d14d
Fix a typo.
2013-10-19 13:52:48 -04:00
Michael DeHaan
8d3db80370
Some misc cleanup and removal of unused imports.
2013-10-19 13:50:14 -04:00
Michael DeHaan
5031104c3a
Finishing touches on template cleanup.
2013-10-19 11:40:48 -04:00
Michael DeHaan
1e85c7544b
Further WIP on template cleanup.
2013-10-19 11:39:52 -04:00
Michael DeHaan
35cb9dc22f
Work in progress about cleaning up template code.
2013-10-19 11:39:52 -04:00
jctanner
6480945184
Merge pull request #4541 from Kami/improve_template_render_error_messages
...
Make errors which get thrown during template rendering more user-friendly
2013-10-16 17:52:07 -07:00
Stoned Elipot
4430d0f5a6
when searching for a plugin only look for a regular file
2013-10-16 21:23:37 +02:00
Tomaz Muraus
922f61899e
Throw a more user-friendly exception during template rendering process.
2013-10-16 16:48:17 +02:00
Brian Coca
bd9acedb57
fixed name colision between warnings dict and module
...
Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
2013-10-15 14:58:15 -04:00
Michael DeHaan
e131de4de0
Added "debug: var=variableName" capability.
2013-10-14 21:01:38 -04:00
Michael DeHaan
c90a82fd52
Handle possible scenario where conditional might be an integer (whoa!) down the error path. Super rare but fixes #4483 .
2013-10-13 09:19:41 -04:00
Michael DeHaan
9ea54fcaaf
Fixes a dev branch glitch where a conditional could be applied to multiple tasks. Also improves the errors on parsing bad conditionals to make them less confusing to users.
2013-10-12 17:39:28 -04:00
Michael DeHaan
add45d2ca9
Fixup legacy var detector.
2013-10-11 19:16:36 -04:00
Michael DeHaan
a45494a896
Add warnings feature.
2013-10-11 19:04:26 -04:00
Michael DeHaan
9637f620d7
Deprecation warnings of several flavors, nice and purple and can be disabled
...
in ansible.cfg.
2013-10-11 18:37:39 -04:00
Michael DeHaan
a017a69bb3
Have the parser explain another type of YAML gotcha to reduce the need for users to ask how to resolve it.
2013-10-11 17:34:26 -04:00
Michael DeHaan
861f076df5
Tweak the syntax-detector-warning-suggester-message (SDWSM) a little.
2013-10-11 17:34:26 -04:00
Michael DeHaan
c69e19c6a6
Enhance references to logging functionality. Fixes #3431 .
2013-10-08 08:26:40 -04:00
Michael DeHaan
44e391fd8b
Merge pull request #4255 from mcodd/legacy_vars_fix
...
Fix for legacy_playbook_variables (should fix issue #4254 )
2013-10-07 05:44:06 -07:00
Michael DeHaan
ea73151757
Add automatic advice when folks hit one of two common but minor YAML gotchas, so they can be more easily correct them on their own.
2013-10-06 10:23:44 -04:00
Ustun Ozgur
977b31249a
Update cache check in find_plugin
...
I am not familiar with the internals, but this line looked suspicious.
2013-09-29 14:03:10 +03:00
Matt Coddington
7f7116de3b
commit 9db4f7a
made a change that also needed to include this to retain correct legacy_playbook_variables behavior
2013-09-25 23:22:09 -04:00
Andrey Shorin
fd101dd2d6
Encode to utf-8 only when needed
2013-09-25 09:29:57 +04:00
Andrey Shorin
21f5bc4242
Prevent UnicodeEncodeError: 'ascii' codec can't encode characters in position ...: ordinal not in range(128)
2013-09-25 09:29:56 +04:00
Alek Storm
3569a2ffee
Handle AnsibleUndefinedVariable's raised from lookup plugins like jinja2 UndefinedError's
2013-09-20 19:56:12 -05:00
James Cammarata
d5b96abd80
Added support for -vvvv to enable ssh connection debugging
...
This patch also checks specifically for a return code of 255, which
indicates an unknown SSH error of some kind. When that happens, ansible
will now recommend running with -vvvv (if not enabled) or show the
output from 'ssh -vvv' (when it is enabled)
2013-09-19 05:58:54 -05:00
James Cammarata
5b15010099
Merge branch 'issue_3312_role_links' into devel
2013-09-16 09:29:25 -05:00
James Cammarata
35d138a0d6
When checking conditionals, don't dereference when the variable contains dashes
...
Fixes #4104
2013-09-13 13:52:58 -05:00
James Cammarata
d0236f6ada
Check for link in path in utils.path_dwim_relative()
...
This allows an included path to be relative to a directory, if the
basedir of the original path is a symlink. In that case, the path
is normalized and the file is searched for in the normalized path.
Fixes #3312
2013-09-12 20:44:10 -05:00
James Cammarata
294451d002
Correctly handle variable issues when evaluating jinja2 when statements
...
Fixes #4025
2013-09-09 14:50:21 -05:00
James Cammarata
4e9dee6093
Use StringIO to feed md5 calculation to prevent unicode issues
...
Fixes #4014
2013-09-06 09:11:47 -05:00
James Cammarata
a202adcae1
Merge branch 'doublecallback' of https://github.com/sergevanginderachter/ansible into sergevanginderachter-doublecallback
2013-09-04 09:58:06 -05:00
James Cammarata
7c1c9b3d10
Fix message in utils related to python-keyczar and fireball/acc mode
2013-09-03 11:16:50 -05:00
James Cammarata
521e14a3ad
Fireball2 mode working!
2013-08-28 11:14:58 -05:00
James Cammarata
acc5d09351
Initial commit for the "fireball2" connection plugin
...
Still needs:
* chunked file transfer/receive
* should probably move all send/recv operations to separate
functions to reduce code duplication
* initial connection setup over ssh? or do we handle that in runner?
2013-08-28 11:14:58 -05:00
James Cammarata
fd2aabaa27
Initial work for the AES cipher class
...
This is based somewhat loosely on how Keyczar does things. Their
implementation does things in a much more generic way to allow for more
variance in how the cipher is created, but since we're only using one
key type most of our values are hard-coded. They also add a header to
their messages, which I am not doing (don't see the need for it
currently).
2013-08-28 11:14:58 -05:00
James Cammarata
88966e6558
Use AnsibleError instead of exit for errors in utils
2013-08-25 11:46:45 -05:00
James Cammarata
e11bb0cad4
Merge branch 'plugins-work' of https://github.com/ferringb/ansible into ferringb-plugins-work
2013-08-22 14:23:25 -05: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
James Cammarata
6bf5d19506
SSH connection plugin creates ControlPersist socket files in a secure directory
...
Files were being created in /tmp, but will now be created in $HOME/.ansible/cp/
Addresses CVE-2013-4259: ansible uses a socket with predictable filename in /tmp
2013-08-21 11:40:46 -05: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
fff4f1da33
Improve behavior with error_on_undefined_vars enabled
...
Pass fail_on_undefined flag to recursive calls to `template` function,
so more undefined variables are detected.
Works only for Jinja style variables. Undefined legacy variables are
never detected.
2013-08-20 00:40:49 -05:00
Brian Harring
902183ac0e
Enforce alphanumeric ordering for plugins grabbed via glob.
...
If this isn't done, it's left to directory ordering which can result
in indeterminent behaviour.
2013-08-19 19:48:17 -04:00
Serge van Ginderachter
173586b871
Ensure plugin_loader.all() only loads one instance
...
by ensuring all basedirs, plugin paths and extra
paths are handled as absolute paths and are checked
to not add any doubles.
This fixes the corner case where e.g. the user has
an additional plugin path configured to a dir
relative to his playbooks or inventory location,
which also matches the _plugin subdir relative to
one of the basedirs in the play.
For most plugins this doesn't show as an obvious issue
except for callback_plugins, which might fire more
than once. Other plugins (inventory and template
plugins) might unnecessarily be ran twice.
e.g. ansible.cfg has
callback_plugins = ./plays/callback_plugins
and plays/ contains a playbook file:
.
├── ansible.cfg
├── inventory
└── plays
├── callback_plugins
│ └── timestamp.py
└── site.yml
modified: lib/ansible/utils/plugins.py
2013-08-12 22:17:53 +02:00
Abhijit Menon-Sen
1a90d01ba9
Fix some typos discovered during casual reading
2013-08-11 18:41:23 +05:30
Brian Coca
581a0c9f59
now correctly 'types' value pairs that are passed as options to jinja
...
override
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2013-08-01 21:08:23 -04:00
Michael DeHaan
bdef7f1774
Merge pull request #3711 from ashorin/devel
...
Allow --diff on UTF-8 encoded files and templates
2013-08-01 17:16:32 -07:00
Michael DeHaan
daf5ecc7c9
Merge pull request #3684 from stoned/fix-3668
...
Add extra module path early during playbook parsing.
2013-08-01 17:14:35 -07:00
Andrey Shorin
664215eb02
Allow --diff on UTF-8 encoded files and templates
2013-07-31 15:58:32 +04:00
Stoned Elipot
841093921b
Add extra module path early during playbook parsing.
...
This should fix issue #3668
Also prevent an extra module path to be added multiple times.
2013-07-28 18:47:26 +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
0756aa406a
Change conditional operation workflow.
...
Conflicts:
lib/ansible/utils/__init__.py
2013-07-21 10:37:02 -04:00
Michael DeHaan
7f462a346a
Work in progress on merging changed_when.
2013-07-21 10:34:47 -04:00
Michael DeHaan
62b39d3de5
Fix for saving conditionals in variable expressions.
2013-07-21 08:52:00 -04:00
Stoned Elipot
2d88c70cd5
Introduce exception AnsibleFilterError and use it in Jinja filters. Ignore this exception when trying to find the name of a task for display (callback) purpose.
2013-07-07 19:18:32 +02:00
Ton Kersten
37ee361be1
Repair issue #3447
2013-07-05 19:10:36 +02:00
Michael DeHaan
9db4f7a9a6
Makes host key checking the default behavior but can be disabled in ansible.cfg or by environment variable.
2013-07-03 16:47:20 -04:00
Michael DeHaan
c2988dfdb0
Merge branch 'option-updates' of git://github.com/jlund/ansible into devel
...
Conflicts:
bin/ansible-pull
2013-06-30 19:31:37 -04:00
Michael DeHaan
98e7eaf07a
Merge pull request #3316 from dsedivec/devel
...
expanduser on each component of plug-in paths
2013-06-30 09:12:15 -07:00
Stoned Elipot
b7f89837bb
Remove redundant call to _get_path() in PluginLoader.find_plugin()
2013-06-30 16:38:26 +02:00
Joshua Lund
dc984d94ac
Updates to Ansible command options
...
* Moved the --list-hosts option that is common to both `ansible` and
`ansible-playbook` into utils/__init__.py (corrects a FIXME)
* Wrote new help text for the --list-hosts option that makes sense
for both of the commands that it applies to
* Changed the usage argument in `ansible-playbook` so that it is
setup in the base_parser method the same way that it is in
the `ansible` executable
* Updated the help text for several options to correct typos,
clarify meaning, improve readability, or fix grammatical errors.
In the case of `ansible-pull`, I changed the help text so that
it adheres to the same standards as the other executables.
2013-06-26 19:57:31 -06: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
132c89e681
Merge branch 'callbackinit' of git://github.com/sergevanginderachter/ansible into devel
2013-06-18 20:52:43 -04:00
Michael DeHaan
5a504e3a3b
Tweak error messages for undefined variables feature.
2013-06-18 13:30:02 -04:00
Michael DeHaan
637983cf31
cleanup example config file + Squashed commit of the following:
...
commit c36b66dc952dfff91043ecbca56cf3f1f8f00703
Merge: 240d7bf
f4cf934
Author: Michael DeHaan <michael@ansibleworks.com>
Date: Tue Jun 18 13:04:51 2013 -0400
Merge branch 'unevaluated-vars' of git://github.com/lorin/ansible into lorin_undefined
Conflicts:
lib/ansible/runner/__init__.py
commit f4cf93436767f73b62a16067ab5e628830045896
Merge: 2531440 07a1365
Author: Lorin Hochstein <lorin@nimbisservices.com>
Date: Thu Jun 6 11:07:41 2013 -0400
Merge branch 'devel' into unevaluated-vars
commit 253144045cbafd7d72836f1017c62ac4ba623186
Author: Lorin Hochstein <lorin@nimbisservices.com>
Date: Thu Jun 6 11:06:37 2013 -0400
Fail template from file on undefined vars
If config option is set, raise an exception if templating from a
file and a variable is undefined.
commit aecb71d8b75257f0f3e11a9b176fc3737aecef8d
Author: Lorin Hochstein <lorin@nimbisservices.com>
Date: Wed Jun 5 17:12:12 2013 -0400
Add fail_on_undefined flag
Add a fail_on_undefined flag to the template and template_from_string methods.
If this flag is true, then re-raise the ninja2.excpetions.UndefinedError instead of
swallowing it.
commit cbb1808f0585f01536240aee05a1bfd06c4b4647
Merge: d4bbf49 41425fb
Author: Lorin Hochstein <lorin@nimbisservices.com>
Date: Wed Jun 5 16:14:12 2013 -0400
Merge branch 'devel' into unevaluated-vars
commit d4bbf492b0b63c789d66ab60d0ec634d100fca82
Author: Lorin Hochstein <lorin@nimbisservices.com>
Date: Mon Jun 3 19:46:13 2013 -0400
template: Raise UndefinedError exception
In template_from_string, raise an undefined error if it occurs.
Have the caller catch it and throw an AnsibleUndefinedVariable
commit c94780280515f1f3756fdc429b2b1e87b365e9b7
Merge: 8d919d6 be33bcf
Author: Lorin Hochstein <lorin@nimbisservices.com>
Date: Mon Jun 3 10:09:43 2013 -0400
Merge branch 'devel' into unevaluated-vars
commit 8d919d6c97b28a42f47ca7248c542695baf6175f
Merge: 0f68ad8 b8630d2
Author: Lorin Hochstein <lorin@nimbisservices.com>
Date: Thu May 30 16:27:48 2013 -0400
Merge branch 'devel' into unevaluated-vars
commit 0f68ad8193ac17488e339a258f8c63fdae399c26
Author: Lorin Hochstein <lorin@nimbisservices.com>
Date: Thu May 30 14:32:03 2013 -0400
Optionally fail task on undefined variables
This patch introduces a new configuration option called
error_on_undefined_vars, which defaults to false.
If this option is set to true, then a task which has unevaluated
variables in its arguments will fail instead of running. Output looks
like this:
TASK: [set rabbitmq password] *************************************************
fatal: [10.20.0.7] => Undefined variables: rabbitmq_user, rabbitmq_password
2013-06-18 13:24:30 -04:00
trbs
a4223e119d
fixed x-bits in git
2013-06-16 22:22:16 -04:00
Serge van Ginderachter
2a7f9df109
add support for callback_plugins/ relative to playbook
2013-06-12 23:54:00 +02:00
Michael DeHaan
3d21dab705
Small fix so template plugins can see inject variables.
2013-06-10 14:23:48 -04:00
Michael DeHaan
3783dc42d4
normalize path
2013-06-03 09:57:02 -04:00
Michael DeHaan
b8a66ce5bb
Lookup plugins in included files now look in paths relative to their files, allowing role usage.
2013-06-01 18:15:38 -04:00
Michael DeHaan
44e32cc45e
Some formatting fixes so docs will build, etc.
2013-05-29 18:43:23 -04:00
Michael DeHaan
159ba7d68a
Merge pull request #2956 from akerl/unicodefix
...
ignore unicode errors in stdout
2013-05-24 19:46:25 -07: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
Michael DeHaan
753ebea186
Prefer categorized modules to uncategorized, such that if someone does an install on top of old content
...
the categorized modules will win over the 1.1 uncategorized modules, as the packages may not automatically
clean up the old content.
2013-05-19 20:09:44 -04:00
Michael DeHaan
cd57d59913
If ansible is configured to use a log file but cannot write to it, exit, but don't traceback.
2013-05-19 20:05:04 -04:00
Michael DeHaan
496f06c3c9
Pass variables to lookup function for those that want to use them.
2013-05-19 19:26:30 -04:00
Les Aker
1179d1bbd8
corrected indentation
2013-05-19 12:25:19 -04:00
Les Aker
2adc335481
ignore unicode errors in stdout
2013-05-19 11:57:08 -04:00
Michael DeHaan
f2a8c0d612
Fix listification inside of with_items so it runs more intelligently.
2013-05-13 21:31:45 -04:00
Michael DeHaan
9f47d13306
Misc identation.
2013-05-11 17:24:12 -04:00
Michael DeHaan
0a1657080b
Indentation fix
2013-05-11 17:23:45 -04:00
Michael DeHaan
3fdf15fa8a
template code fixes for 'make pep8'
2013-05-11 17:22:56 -04:00
Matt Coddington
542eeeb5d6
add option to ignore $legacy variable style substitution
2013-05-11 14:06:01 -04:00
Stoned Elipot
df3c4849e9
Also load Jinja2 extensions when processing template from string
2013-04-28 20:52:01 -04:00
Michael DeHaan
68f711d5ae
teach plugin loader to find modules in subdirectories
2013-04-28 15:22:46 -04:00
Michael DeHaan
391fb98ee2
Allow modules to be categorized, and also sort them when generating the documentation.
2013-04-28 15:03:45 -04:00
Michael DeHaan
224e20ca60
complex_arg templating should be smarter. Make it so!
2013-04-25 21:11:17 -04:00
Jeroen Hoekx
ac7a632711
Remove leftover debug statement in template code.
2013-04-25 08:47:38 +02:00
Michael DeHaan
6fdfbb1a34
Improve variable smushing so it only has to be done in one place. This is related to shlex.split being called
...
on untemplated variables in some rare cases.
2013-04-24 22:00:40 -04:00
Michael DeHaan
be947e5266
Resolve merge conflict
2013-04-22 23:57:20 -04:00
Michael DeHaan
e12f91799c
Allow args: var to be used to pass a variable in bare, and also templated versions should also DWIM.
2013-04-22 22:17:55 -04:00
Michael DeHaan
6c778acd91
Smush the braces in various places (hey, that rhymes) to avoid undo key=value splitting surprises
...
in new template system.
2013-04-22 22:05:06 -04:00
Michael DeHaan
d7623d1f91
Added a 'set_up' and 'tear_down' which are like tasks, but execute before and after roles.
2013-04-20 16:07:06 -04:00
Michael DeHaan
e6bf01a6b0
Make plugin loader path operations more efficient.
2013-04-20 12:31:14 -04:00
Michael DeHaan
817b0cdc80
Instantiate filter plugins only once to save some efficiency.
2013-04-20 09:51:20 -04:00
Michael DeHaan
53ac0bbec2
Instantiate callback plugins only once so we can set play/task objects on them and they'll stick.
2013-04-20 09:09:35 -04:00
Bernhard Weitzhofer
fb0a99e5d8
Fix if-statement that always evaluates True
2013-04-17 19:40:06 +02: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
Michael DeHaan
b54e955595
Remove a debug statement.
2013-04-16 19:09:12 -04:00
Michael DeHaan
86d47bce5f
Make more lookup plugins tolerant of new variable system, with a little better 'do what I mean' logic to resolving
...
what happens if you get a string back as a template result.
2013-04-16 19:07:19 -04:00
Michael DeHaan
c0f8af5202
Make more lookup plugins happy with newstyle variables. Not quite done, but this fixes up with_items/with_nested/file/fileglob.
2013-04-16 18:50:30 -04:00
Michael DeHaan
7a2d493e67
Teach lookup plugins that if they can't evaluate something they can wait and do it later.
2013-04-12 18:44:40 -04:00
Michael DeHaan
3f3b2a9448
Smush Jinja2 braces in playbooks so unresolved variables get parsed nicely
2013-04-12 18:38:48 -04:00
Michael DeHaan
793a3d3f76
More 1.2 templating development; for legacy when_string constructs don't quote the 'in' operator
2013-04-12 13:29:49 -04:00
Michael DeHaan
b8c5a58b7f
Avoid running through the legacy template code if no dollar signs are in strings.
2013-04-12 10:33:55 -04:00
Michael DeHaan
a05361f515
This is a fix on top of the 'airplane variable upgrade' commits that fixes legacy when_string so it evaluates correctly in the new eval construct.
2013-04-11 17:20:40 -04:00
Michael DeHaan
4e79bd0872
Remove unneccessary construction of Jinja2 environment object.
2013-04-11 12:59:33 -04:00
Michael DeHaan
2f5c1d3788
Merge pull request #2629 from stoned/fix-jinja2-filters-init
...
Fix Jinja2 filter plugins initialization
2013-04-11 09:57:04 -07:00
Michael DeHaan
695acc2de0
Make lookup plugins accessible in templates
2013-04-10 19:19:01 -04:00
Michael DeHaan
5b2035edd9
Changes for 'make pep8'
2013-04-10 19:12:10 -04: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
f0b21dcc0f
allow references to names of variables in with_items without needing to surround them with Jinja2 '{{' delimeters
2013-04-10 18:42:54 -04:00
Michael DeHaan
9ac25bb8f6
Minor formatting
2013-04-10 18:19:31 -04:00
Michael DeHaan
d7206d84bb
Allows Jinja2 that starts a YAML line to not cause a syntax error.
...
Technically this isn't quite valid YAML when this happens, so we make it valid. This means that if a future commander
API allows save/load it should make sure it does similar processing.
2013-04-10 18:07:19 -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
804056a563
Use Jinja2 strict undefined in string templating to allow the default filter to be used.
2013-04-10 16:45:53 -04:00
Michael DeHaan
998230a84a
Allow $foo and {{ bar }} to be used on the same line in playbooks.
2013-04-10 16:40:49 -04:00
Michael DeHaan
29209c4913
Style fixes so "make pep8" is clean.
2013-04-10 16:37:49 -04:00
Michael DeHaan
0113951580
Enable usage of when_set within new eval system.
2013-04-10 16:26:59 -04:00
Michael DeHaan
a83e10d77d
Use safe_eval vs eval.
2013-04-10 16:17:24 -04:00
Stoned Elipot
154f58f82d
Fix Jinja2 filter plugins initialization
...
_get_filter_plugins() checks FILTER_PLUGINS against None hence
the latter should be initialized to None.
2013-04-09 22:38:24 +02:00
Sébastien Bocahu
b94bf051d5
Makes $PIPE and $FILE macros accept utf-8 input
2013-04-06 23:28:15 +02:00
Michael DeHaan
892484812e
Much requested feature -- allows relative imports of content within roles or relative to any task or handler include (../templates for template ../files for copy)
2013-04-06 12:13:04 -04:00
Michael DeHaan
95f30f0def
Complete streamlining of vars handling in playbooks and how those are templated to avoid
...
repeat template calls at playbook intialization time.
2013-04-06 10:45:09 -04:00
Michael DeHaan
4cd69e81b9
Catch recursive templating errors and display what string caused them.
2013-04-06 09:55:31 -04:00
George Miroshnykov
6826aa7360
Tweaked merge_hash to also affect Runner behavior
2013-04-06 13:06:38 +03:00
Michael DeHaan
f585c4cde7
Upgraded variable support met with upgraded conditional support, see examples/playbooks/upgraded_vars.yml
...
for details!
2013-04-05 19:10:32 -04:00
Michael DeHaan
38c2b14339
Undefined Jinja2 statements are returned as they originally are so you can tell there are things to
...
correct.
2013-04-05 17:36:53 -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
Stoned Elipot
8edda38c61
exception safe list/tuple replacing for non-str values
2013-03-12 05:01:45 +01:00
Michael DeHaan
7ac5e462ef
Fixed a small buglet, if using with_items with yum and so on, only optimize the package list if the package list is all strings
2013-03-01 18:32:32 -05:00
Daniel Hokka Zakrisson
f1eb195ff5
vars_loader should get the path to the inventory + vars_plugins
2013-03-01 23:22:52 +01:00
Daniel Hokka Zakrisson
4807fbc8b7
Use regular strings to allow tests to work
2013-02-28 13:52:57 +01:00
Daniel Hokka Zakrisson
cedfec763a
jsonify needs to return a string of {}, rather than a dict
2013-02-27 19:46:31 +01:00
Daniel Hokka Zakrisson
bcf7a2c53a
Catch all exceptions coming from lookup plugins
...
Fixes using $TEMPLATE() and hostvars in a task without a name, among
other things.
2013-02-27 10:11:14 +01:00
Michael DeHaan
1366c663eb
Merge branch 'copy-diff-take2' of git://github.com/stoned/ansible into better_diff
...
Conflicts:
library/file
2013-02-26 20:51:32 -05:00
Stoned Elipot
8816dc7ca7
Make diff header lines more explicit about what the diff is about
...
This gives a more readable output when producing diff for a task
with multiple items (with_items).
2013-02-26 16:53:59 +01:00
Stoned Elipot
10e9f1fc1e
Implement --diff for the copy module.
2013-02-25 23:32:52 +01:00
Daniel Hokka Zakrisson
1df56c07d3
If expand_lists is true, make lookup plugin result into a string
...
Fixes #2196 .
2013-02-25 22:26:16 +01:00
Daniel Hokka Zakrisson
f03e845920
Allow hyphens in complex variables
...
Primarily to support ${hostvars.hostname-with-hyphens.<var>}.
2013-02-25 15:09:44 +01:00
Michael DeHaan
b75b9681a8
more places to use yaml.safe_load
2013-02-23 13:34:14 -05:00
Michael DeHaan
a9ea3136cf
Use yaml.safe_load as we are just using basic data structures
2013-02-23 13:33:21 -05:00
Michael DeHaan
e51707711c
Merge pull request #2120 from jpmens/doc_ex1
...
Add support for additional EXAMPLES string in Ansible modules
2013-02-23 08:58:34 -08:00
Stoned Elipot
9f2bba01ba
Fix diff output vertical spacing
2013-02-20 22:45:45 +01:00
Jan-Piet Mens
396a07bcc7
Add support for additional EXAMPLES string in Ansible modules
...
return DOC and EXAMPLES as a list
add moduledev explanation
more
2013-02-18 20:02:46 +01:00
Michael DeHaan
9cf66f4376
Fixes from 'make pep8'. Partial, more to come.
2013-02-17 19:40:38 -05:00
Michael DeHaan
61d01f549f
Show a nicer message when attempting to diff unicode files.
2013-02-17 19:32:28 -05:00
Michael DeHaan
1ecf4a6943
Working on complex argument support.
2013-02-17 15:01:49 -05:00
Michel Blanc
0cd0a7fda3
Fixes jina typos
...
Moved *jina* to *jinja2*
2013-02-16 13:32:48 -05:00
Michel Blanc
1c22f2146e
Adds configurable jinja2 extension loading
...
Jinja extensions adds features to the jinja2 templating engine. This
patch allows module loading for the templating engine vian an
ansible.cfg configuration key (jinja_extensions).
The default behaviour doesn't change (no module loading).
Requested modules can be added coma separated in ansible.cfg
Adds whitespace handling in jinja_extension config
Added whitespace handling in jinja_extension configuration directive, so
things stay safe if user adds spaces around comas in the directives
list.
Adds config example for jinja_extensions
Added config example with multiple extentions for jinja_extensions
2013-02-16 13:32:48 -05:00
Daniel Hokka Zakrisson
d632210941
Allow using other users' home directories as well
2013-02-11 23:43:30 +01:00
Daniel Hokka Zakrisson
c83e428a7e
Default expand_lists to True and set it to False for only_if
...
Fixes #2026 and #2027 .
2013-02-10 22:57:53 +01:00
Michael DeHaan
e6ead2ca74
make things like $FILE(/etc/path/foo.conf) and $ENV(HOME) work without having to use brackets to index them
2013-02-09 22:35:27 -05:00
Michael DeHaan
c692de6b80
Cleanup YAML parse error warning code a tiny amount.
2013-02-09 14:30:19 -05:00
Michael DeHaan
a9162a86f2
Very basic --diff option for showing what happens when templates change.
...
Probably output is not useful if not used with --limit
Works well with --check mode
2013-02-07 22:52:25 -05:00
Daniel Hokka Zakrisson
70d5dad726
Also catch NameErrors which would indicate missing quotes
2013-02-07 11:56:59 +01:00
Daniel Hokka Zakrisson
bc709e7b67
expand_lists should default to False
2013-02-07 11:56:59 +01:00
Rune Kaagaard
7a8b27f716
Fixing bug with unicode templates.
...
The utils.md5s() function would break when calculating checksums
for non-ascii characters. Convert to utf-8 first.
2013-02-05 14:49:59 +01:00
Daniel Hokka Zakrisson
c1b63d1500
Fix for when conditional is a simple bool already
...
Fixes #1983 .
2013-02-04 20:12:53 +01:00
Michael DeHaan
fed82c2188
This implements a basic --check mode which for now is only implemented on template & copy operations. More detail will be shared with the list
...
shortly.
2013-02-03 20:34:13 -05:00
Daniel Hokka Zakrisson
a79373f6b2
Make template_ds the only templater
...
Instead of having to remember when to use which one, rename template_ds
to template and move the last bit of code from template to varReplace
(which gets used for all string replacements, in the end).
This means that you can template any data type without worrying about
whether it's a string or not, and the right thing will happen.
2013-02-03 14:01:54 +01:00
Daniel Hokka Zakrisson
b79960e13b
If failed lookups are fatal, re-raise the exception
...
Fixes #1938 .
2013-01-29 10:31:33 +01:00
Daniel Hokka Zakrisson
5268d49bad
Add sudo_flags configuration option to alter sudo behaviour
...
Default to -H to set $HOME appropriately.
2013-01-28 17:41:43 +01:00
Michael DeHaan
36066d8664
Fixup ec2_facts docs parsing
2013-01-26 12:34:30 -05:00
Daniel Hokka Zakrisson
53fd85e2c4
Merge pull request #1903 from leucos/mergeable-hash-vars
...
Adds user-selectable hash merging support in vars
2013-01-25 08:29:05 -08:00
Daniel Hokka Zakrisson
864b75e54b
Override Jinja2 Template class to make {% include %} work again
...
Fixes #1908 .
2013-01-25 14:16:29 +01:00
Michel Blanc
8eb7d740b0
Fixes hash merging
...
No need for deep copy (vars are essentially immutable once loaded, there
should not be any modifications)
2013-01-24 00:53:12 +01:00
Michel Blanc
e28e538c6e
Adds user-selectable hash merging support in vars
...
Hash variables are currently overriden if they are redefined. This
doesn't let the user refine hash entries or overriding selected keys,
which can, for some, be a desirable feature.
This patch let the user force hash merging by setting the
hash_behaviour value to "merge" (without the quotes) in ansible.cfg
However, by default, ansible behaves like it always did and if any value
besides "merge" is used ("replace" is suggested in the example ansible.cfg
file), it will also behave as always.
2013-01-23 21:39:34 +01:00
Bowe Strickland
2b3d6d4545
protect PluginLoader._extra_dirs from appending None
...
PluginLoader.add_directory() can receive None from, for example,
Inventory.add_directory(self.basedir()) if host_list is a custom list.
None has no reasonable interpretation other than ignore it.
2013-01-23 13:55:12 -05:00
Daniel Hokka Zakrisson
a16ddb57c1
Default module search path is included already
...
Adding it to runner's module_path makes it override local modules.
2013-01-22 15:42:49 +01:00
Michael DeHaan
35c7ebf7a4
Revert "Update lib/ansible/utils/__init__.py"
...
Reported hanging of no-password sudo in some cases. Need to explore.
This reverts commit 87f6739e20
.
Conflicts:
lib/ansible/utils/__init__.py
2013-01-20 09:05:07 -05:00
ron1
280660b8a7
Support sudo alternatives that offer sudo-compatible interfaces
2013-01-19 08:40:32 -05:00
Michael DeHaan
c8fc353bc3
Merge pull request #1811 from fdavis/devel
...
add when_{failed,changed}, and extended when_{set,unset}
2013-01-18 15:18:00 -08:00
Michel Blanc
87f6739e20
Update lib/ansible/utils/__init__.py
...
Adds -i to make_sudo_cmd so target user's environment gets loaded when configurationslike this are used :
- hosts: ubuntu
name: Install ruby for the configured ruby user
sudo: True
sudo_user: rubyuser
# should be ${ruby_user}, but can't for now because of #1665
tasks:
- name: Gets current ruby version
action: shell rbenv version
register: ruby_current_version
2013-01-18 16:03:50 +01:00
Daniel Hokka Zakrisson
7ecab22302
Move sudo command making to one common function
2013-01-13 15:16:13 +01:00
Daniel Hokka Zakrisson
7782923ea2
Revert #1818 but avoid double-dwim, fixing relative fileglob
2013-01-09 14:52:52 +01:00
Daniel Hokka Zakrisson
87b2378e22
Resolve variable references inside variables
...
Fixes the case where variable x is '$y' and y is a dict(foo='bar') and
an attempt to access ${x.foo} is made.
2013-01-09 13:45:55 +01:00
fdavis
fe310dcff1
add when_failed, when_changed, and extended when_set/unset
...
This commit extends the 'when_' conditions to failed and changed
json results
Additionally it makes when_{set,unset,failed,changed,int,str,flt}
behave more similiarily in that they all except and/or/not logic
2013-01-08 19:51:48 -08:00
willthames
411b2bf7d9
Added additional template variables
...
Added two additional template variables
* template_fullpath - absolute path to the template
* template_run_date - date that the template was rendered
Documented these additional variables in the module documentation
2013-01-04 16:36:02 +10:00
Daniel Hokka Zakrisson
caee51e90e
Allow only_if/when_* on task includes and apply it on all tasks within
2013-01-04 00:15:13 +01:00
Stephen Fromm
2100a35663
Update path_dwim() to return absolute path
...
If path_dwim() is provided a relative path to a file, it will now return an
absolute path of the playbook directory + the relative file path.
2013-01-02 21:53:00 -08:00
Daniel Hokka Zakrisson
d4c63e3300
Ensure each basedir is only added to the search path once
...
Fixes #1790 .
2012-12-20 14:17:12 +01:00
Daniel Hokka Zakrisson
3a36c024da
Make lookups being fatal up to the caller
...
Fixes #1769 .
2012-12-19 19:19:04 +01:00
Daniel Hokka Zakrisson
0f1706220b
Add support for using the Jinja2 built-ins such as range
2012-12-19 09:42:15 +01:00
fdavis
7347e54b70
change error message on check_conditional when variable does not exist
2012-12-13 23:02:30 -08:00
Michael DeHaan
dbf5a57a5a
Merge pull request #1683 from bcoca/template_override
...
Template override
2012-12-02 10:15:10 -08:00
Jan-Piet Mens
17f31a2a79
CLI: ansible-doc shows lists of modules & module docs on command-line
...
check path is directory
added manpage & setup
small cleanup
shut up module_formatter in utils to avoid trace print on crud files in library
2012-11-30 21:57:25 -05:00
Brian Coca
d7f38d07b3
fixed bug for string size mismatch, now substring depends on size of match string Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
...
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2012-11-26 10:41:13 -05:00
Brian Coca
6a1e2aaff5
moved override matching string to variable changed test template to match Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
...
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2012-11-26 10:41:13 -05:00
Brian Coca
68f5d69365
added ability to override jinja enviornment from first line of template Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
...
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2012-11-26 10:41:13 -05:00
Daniel Hokka Zakrisson
047d089cea
Restore git output on --version
...
Broken by the move from utils.py to utils/__init__.py
2012-11-21 23:54:42 +01:00
Daniel Hokka Zakrisson
f95fefd8c5
Use plugin system to find modules
2012-11-18 19:09:21 +01:00
Daniel Hokka Zakrisson
5dd2ec2cae
Add a way to add directories to just one type of loader
2012-11-18 19:08:59 +01:00
Daniel Hokka Zakrisson
11175781b8
Use slurp for fetch is sudo is enabled and needed
...
Fixes #1020 .
2012-11-18 17:54:00 +01:00
Daniel Hokka Zakrisson
e74ffd6764
Lookup plugin arguments need to be templated
2012-11-14 11:17:30 +01:00
Daniel Hokka Zakrisson
c200c26ced
Keep hostvars from being templated
2012-11-13 11:34:34 +01:00
Daniel Hokka Zakrisson
25a8787e95
Template all variables before returning them to Jinja2
2012-11-13 02:39:33 +01:00
Daniel Hokka Zakrisson
d2dce1d63f
Make lookup plugin replacements part of the main variable logic
2012-11-13 02:18:05 +01:00
Daniel Hokka Zakrisson
a2bb3a09d2
Completely ignore stray $ in input
...
Previously, "a $ string $var" would not have gotten replaced at all.
2012-11-13 02:13:10 +01:00
Daniel Hokka Zakrisson
24b536d7ed
Add some comments to templating system
2012-11-13 02:13:04 +01:00
Daniel Hokka Zakrisson
233a36b9e8
Template using module_vars early
...
Since no basedir is available at that time, avoid invoking
lookup plugins since they assume it is present.
2012-11-12 16:53:24 +01:00
Michael DeHaan
c890ae18e7
Merge pull request #1575 from dhozac/parameterized-playbook-include
...
Add parameterized playbook includes
2012-11-12 05:17:38 -08:00
Daniel Hokka Zakrisson
9924555623
Add support for generic $XXX() to call $LOOKUP()
2012-11-10 23:46:37 +01:00
Jan-Piet Mens
e32f4a0564
Move get_docstring from module_formatter into ansible/utils
2012-11-09 17:15:41 +01:00
Daniel Hokka Zakrisson
383dc30560
Rename varReplaceWithItems to template_ds
2012-11-09 15:43:29 +01:00
Daniel Hokka Zakrisson
47082a9171
Add $LOOKUP(<lookup plugin>,<data>) as a templating option
...
Also moves file and pipe to lookup_plugins.
2012-11-07 23:17:29 +01:00
Jeroen Hoekx
8ffed6df75
Support custom jinja2 filters.
...
This uses the plugin framework to add filter plugins.
The previously hardcoded core filters are defined using the plugin
framework now.
2012-11-05 15:11:34 +01:00
Daniel Hokka Zakrisson
e05e514861
Create a plugin loader system
2012-11-02 01:24:14 +01:00
Daniel Hokka Zakrisson
000d3832cc
Make ansible.utils a package
2012-11-02 00:42:37 +01:00