Commit Graph

41 Commits (be7bd392cb35a5e98c726fe4496b61f03e34e049)

Author SHA1 Message Date
James Cammarata 56d7f3889d Add new level of vars to deal with set_fact/register precedence rules 2015-09-09 12:21:07 -04:00
Victor Costan bd405169fb Fix #12258: don't wrap None in UnsafeProxy. 2015-09-08 04:02:04 -04:00
James Cammarata ac6f61ec7f Properly handle group/host_var files with dots in them
Fixes #12245
2015-09-08 03:20:09 -04:00
James Cammarata 1eb5b42705 Don't double proxy unsafe variables
Potential fix for #12260
2015-09-08 02:50:07 -04:00
James Cammarata ff9f5d7dc8 Starting to add additional unit tests for VariableManager
Required some rewiring in inventory code to make sure we're using
the DataLoader class for some data file operations, which makes mocking
them much easier.

Also identified two corner cases not currently handled by the code, related
to inventory variable sources and which one "wins". Also noticed we weren't
properly merging variables from multiple group/host_var file locations
(inventory directory vs. playbook directory locations) so fixed as well.
2015-09-04 16:41:38 -04:00
James Cammarata 87f75a50ad Use proxy class to mark variables unsafe for templating
Fixes #12191
2015-09-04 16:38:06 -04:00
Toshio Kuratomi aeff960d02 Cleanup combine_vars
* Dedupe combine_vars() code (removed from VariableManager)
* Fix merge_hash algorithm to preserve the type
* unittest combine_vars and merge_hash
2015-09-01 11:23:12 -07:00
James Cammarata a341a8a093 Make sure tasks from a role see their defaults above all others
Fixes #12081
2015-09-01 11:27:35 -04:00
Marius Gedminas 54dbfba8f8 Make combine_vars() compatible with Python 3
Fixes

  TypeError: unsupported operand type(s) for +: 'dict_items' and 'dict_items'

on Python 3.
2015-09-01 09:39:59 +03:00
Marius Gedminas 0c6ce31f76 Use 'except ... as' syntax
This syntax works on Python 2.6 through 3.x.  lib/ansible/module_utils
(and lib/ansible/modules) need to support Python 2.4, so I didn't touch
those.
2015-08-27 22:15:04 +03:00
Brian Coca af06a97f17 kept vars as alias to hostvars[inventory_hostname] and avoid subtrees into themselves 2015-08-23 17:51:47 -04:00
James Cammarata 635fa0757b Several var fixes
* Fixes hostvar serialization issue (#12005)
* Fixes regression in include_vars from within a role (#9498), where
  we had the precedence order for vars_cache (include_vars, set_fact)
  incorrectly before role vars.
* Fixes another bug in which vars loaded from files in the format of
  a list instead of dictionary would cause a failure.

Fixes #9498
Fixes #12005
2015-08-21 12:02:23 -04:00
Brian Coca 36cbd771a4 changed fixme to deprecated 2015-08-19 15:49:37 -04:00
Brian Coca 70d024ffce show errors when missing vars file or when there is syntax issue in the file
fixes #11945
2015-08-12 22:39:06 -04:00
James Cammarata 38eb53de1d Fix bug in vars using correct temp value for vars
Fixes #11877
2015-08-11 21:23:37 -04:00
James Cammarata 4c733fe4b7 Fix issues with vars_prompt and vars_files
* Prompt had to be moved up, as it needed to be done before the first
  templating of the play occurs, otherwise vars_files won't be templated
  properly
* Fixed a bug related to an earlier fix of vars_files incorporating
  extra vars to do the templating of the file name

Fixes #11404
2015-07-21 14:52:57 -04:00
James Cammarata 7124504ccf Incorporate extra vars when templating vars_files
Fixes #11377
2015-07-21 02:10:26 -04:00
James Cammarata 9a586c3512 Properly catch AnsibleError and not all errors 2015-07-13 20:49:11 -04:00
Brian Coca e0632cb9a4 Merge pull request #11577 from srvg/yaml_file_extensions
Use YAML_FILENAME_EXTENSIONS for vars files.
2015-07-13 18:29:26 -04:00
Serge van Ginderachter d5fb11d89c Use YAML_FILENAME_EXTENSIONS for vars files.
The v2 codebase didn't use this previously introduced constant yet.

C.YAML_FILENAME_EXTENSIONS
2015-07-14 00:23:35 +02:00
Serge van Ginderachter 9c8f0da327 Do not combine group_vars with an empty file
This addresses a specific case with multiple vars files
in a group_vars/${groupname}/ directory where one of those files
is empty, which returns None instead of an empty dict.
2015-07-14 00:14:13 +02:00
James Cammarata c18fdd0c18 Re-implement "conditional imports" for vars_files 2015-07-13 15:18:23 -04:00
James Cammarata d977da5b41 Fixing up fact_cache use in VariableManager 2015-07-13 11:06:03 -04:00
James Cammarata cf2a66ef30 Add ansible_version magic variable
Fixes #11545
2015-07-10 03:22:37 -04:00
James Cammarata b520d5bc60 Lots of fixes for integration test bugs 2015-07-10 01:53:59 -04:00
James Cammarata f67949e42c Readd logic for ansible_managed to template action plugin
Fixes #11317
2015-07-07 16:48:19 -04:00
James Cammarata 38cc54b717 Make 'vars' a copy to prevent recursion issues 2015-07-04 23:34:07 -04:00
James Cammarata 38c5da9d2a Revert "Backing out vars magic variable due to failed tests"
This reverts commit 388e46a485.
2015-07-04 22:48:20 -04:00
James Cammarata 388e46a485 Backing out vars magic variable due to failed tests 2015-07-04 22:44:45 -04:00
James Cammarata 76c5be3a31 Add 'vars' to magic variables 2015-07-04 21:28:28 -04:00
James Cammarata b6c52ce115 Allow role variables to be optionally kept in a private scope 2015-07-01 11:33:14 -04:00
James Cammarata f433e709f2 Fix templating of hostvars values
Also adds play information into the hostvars creation, to assure the
variable manager used there has access to vars and vars_files

Fixes #9501
Fixes #8213
Fixes #7844
2015-06-27 21:04:16 -04:00
James Cammarata 0b16580567 Add in playbook_dir magic variable 2015-06-23 14:29:39 -04:00
James Cammarata 7490044bbe Implement play_hosts magic variable (and ansible_current_hosts)
Fixes #8073
2015-06-22 21:03:55 -04:00
Benno Joy 0d5b7ae669 fixes 11296 where the groups does not have all the groups 2015-06-17 19:18:19 +05:30
James Cammarata 30c1a2d861 Have group/host var file loading check for YAML extensions too
Fixes #11132
2015-06-16 11:55:56 -04:00
James Cammarata 48d62fd934 Cleaning up VariableManager tests (v2) 2015-05-14 20:10:31 -05:00
James Cammarata fd321355d6 Adding 'role_path' to VariableManager "magic" variables (v2) 2015-05-11 14:04:17 -05:00
James Cammarata daf533c80e V2 fixes
* PluginLoader class will now be more selective about loading some
  plugin classes, if a required base class is specified (used to avoid
  loading v1 plugins that have changed significantly in their apis)
* Added ability for the connection info class to read values from a
  given hosts variables, to support "magic" variables
* Added some more magic variables to the VariableManager output
* Fixed a bug in the ActionBase class, where the module configuration
  code was not correctly handling unicode
2015-05-11 11:29:48 -05:00
Toshio Kuratomi 7f21f270d9 Be more lenient in instance check: MutableMapping is more general than dict 2015-05-08 13:18:19 -07:00
James Cammarata ce3ef7f4c1 Making the switch to v2 2015-05-03 21:47:26 -05:00