James Cammarata
4e94bb64d8
Fix group/host var loading relative to playbook basedir
2015-07-14 09:26:24 -04:00
James Cammarata
a9712bb0fb
Fixing some delegate_to bugs
...
* Moving connection creation until after the task is post_validated,
to make sure all fields are properly templated (#11230 )
* Fixing problems related to the connection method and remote address
lookup on the delegated-to host
Fixes #11230
2015-07-09 08:25:08 -04:00
James Cammarata
ff251a0dcc
Catch runtime errors due to recursion when calculating group depth
...
Fixes #7708
2015-06-22 02:06:07 -04:00
Benno Joy
f17bdc4d61
Set the ansible_ssh_port variable instead of saving it internally for Host
...
Fixes #11330
2015-06-22 00:38:41 -04:00
James Cammarata
87ca475704
Exclude the all/ungrouped groups from pattern matching results
...
Fixes #5375
2015-06-17 16:25:58 -04:00
James Cammarata
90445ee67d
Add ::1 where we see 127.0.0.1, for better ipv6 support
...
Fixes #5764
2015-06-17 16:03:19 -04:00
Marc Abramowitz
a385744426
Add inventory file to "Unable to find" error msg
...
E.g.:
$ ansible gabriel -m ping -i ssh_config.py
ERROR! Unable to find an inventory file (ssh_config.py), specify one with -i ?
2015-06-17 11:00:13 -07:00
James Cammarata
30c1a2d861
Have group/host var file loading check for YAML extensions too
...
Fixes #11132
2015-06-16 11:55:56 -04:00
Toshio Kuratomi
f9b56a5d7c
Fix raising AnsibleError
2015-06-05 11:41:23 -07:00
Toshio Kuratomi
96836412aa
Make error messages tell which inventory script the error came from
2015-06-03 11:51:33 -07:00
Toshio Kuratomi
1c8527044b
Fix error handling when pasing output from dynamic inventory
2015-06-03 11:29:20 -07:00
James Cammarata
620fad9f8d
Fixing an oops in inventory/__init__.py where the slots are incorrect
2015-06-01 20:02:15 -05:00
James Cammarata
fe41f109a9
Merge branch 'v2_final' into devel_switch_v2
2015-06-01 16:42:59 -05:00
James Cammarata
4bc7703db3
Fixing some small bugs related to integration tests (v2)
2015-06-01 16:42:10 -05:00
James Cammarata
2bad888f28
Merge branch 'v2_final' into devel_switch_v2
...
Conflicts:
lib/ansible/inventory/__init__.py
lib/ansible/modules/core
lib/ansible/utils/__init__.py
lib/ansible/utils/module_docs.py
2015-05-28 15:26:03 -05:00
alberto
37ae5aab31
Capture only IOError when reading shebang from inventory file, to avoid ignoring other possible exceptions like timeouts from a task
2015-05-28 12:19:32 +02:00
Brian Coca
0913b8263c
made special treatment of certain filesystem for selinux configurable
2015-05-15 13:52:27 -04:00
Brian Coca
e2de336a23
made special treatment of certain filesystem for selinux configurable
2015-05-15 13:19:15 -04:00
James Cammarata
ce3ef7f4c1
Making the switch to v2
2015-05-03 21:47:26 -05:00
Brian Coca
c3d34a5386
Merge pull request #8936 from srvg/inventoryscript_onlychildren
...
Allow InventoryScript JSON with childgroups only
2015-03-05 17:11:04 -05:00
Toshio Kuratomi
084fbbdea9
Reverse the conditional so there's one less return from this function
2015-02-26 22:50:11 -08:00
Alvaro Lopez Ortega
2e929cf0ce
Fixes bug #10281 - Trailing zeros were truncated from strings
2015-02-21 19:54:38 +01:00
Alvaro Lopez Ortega
a14248ffe1
Fixes bug #10281 - Trailing zeros were truncated from strings
2015-02-21 16:40:50 +01:00
Brian Coca
751701c6f2
Merge pull request #9672 from quinot/topic/lineno-in-inventory-err
...
Report location (filename and line number) for inventory syntax errors
2015-01-29 12:36:30 -05:00
Toshio Kuratomi
a63e4c595f
Another place that needs to be json_dict_bytes_to_unicode
2015-01-26 22:04:51 -08:00
Toshio Kuratomi
0f6b87d33e
Revert "Fix import statements" -- those impotrt statements were right
...
before... something else is fishy
This reverts commit 8ab536fbf2
.
2015-01-26 22:01:52 -08:00
Toshio Kuratomi
8ab536fbf2
Fix import statements
2015-01-26 21:49:09 -08:00
Toshio Kuratomi
915d232d5f
jinja2 cannot handle byte strs with non-ascii. So we need to transform potential byte str into unicode type. This fix is for dynamic inventory.
...
Fixes #10007
2015-01-26 20:39:09 -08:00
Brian Coca
2ef5d6be1e
Merge pull request #9702 from bcoca/better_errors_on_delegate
...
better exception handling with delegated hosts
2015-01-19 15:25:01 -05:00
Brian Coca
6b3d0f4788
now captures returncode errors on inventory scripts
2015-01-15 13:38:25 -05:00
Brian Coca
61a30e5f49
better exception handling with delegated hosts
2014-12-03 07:26:42 -05:00
Thomas Quinot
23d959db71
Report location (filename and line number) for inventory syntax errors
...
When AnsibleError is raised for a syntax error in an inventory file,
report filename and line number to help pinpointing the error.
2014-11-30 10:41:09 +01:00
James Cammarata
d19fe8d95d
Fetch vars for host directly when calculating the delegated user
...
This fixes the case in which the delegated to host may not be in the
specified hosts list, in which cases facts/vars for the host were
not available in the injected hostvars.
This also fixes the inventory variable fetching function, so that an
unknown host raises a proper error as opposed to a NoneType exception.
Fixes #8224
2014-10-10 01:18:18 -05:00
Toshio Kuratomi
a10d10f647
Workaround more python-2.6 shlex not being able to handle unicode strings
2014-10-08 14:30:36 -04:00
Toshio Kuratomi
cef2a8795f
Make dynamic inventory return byte str, not unicode
2014-10-02 20:27:06 -04:00
Michael DeHaan
26cdddaebf
Tracebacks are now catchable with ignore_errors and have streamlined output. Also removes 'baby-JSON' for bash modules.
2014-09-11 12:27:21 -04:00
Serge van Ginderachter
69740b86e8
Allow InventoryScript JSON with childgroups only
...
and without hosts and vars
Without this patch, the simplified syntax is triggered when a group
is defined like this:
"platforms": {
"children": [
"cloudstack"
]
}
Which results in a group 'platforms' with 1 host 'platforms'.
modified: lib/ansible/inventory/script.py
2014-09-09 11:37:54 +02:00
Serge van Ginderachter
3a228b9d55
InventoryScript: better syntax checking for json stream
2014-08-21 18:06:07 +02:00
Serge van Ginderachter
a1f09bd89f
Merge variables for hosts instead of updating in get_variables()
2014-08-20 01:54:46 -05:00
Serge van Ginderachter
0ab721d51e
better logic for all-group variables for implicit localhost
2014-08-19 16:41:51 +02:00
Serge van Ginderachter
a2cfe8770b
Inventory: fix logic mistake in loading/retrieving variables for groups
2014-08-19 16:34:26 +02:00
James Cammarata
e3895840d1
Make sure group_vars/all is loaded for ungrouped hosts
...
Fixes #6563
2014-08-18 12:29:46 -05:00
James Cammarata
b4476c238f
Use match() instead of search() for pattern matching
...
Also related to f48fa3, fix for #8614
2014-08-14 12:26:52 -05:00
James Cammarata
f48fa3759a
Fix host pattern matching and enhance error detection
...
Fixes #8614
2014-08-14 12:13:40 -05:00
James Cammarata
bea0845322
Fix vault_password positional args error
2014-08-14 10:28:08 -05:00
Michael DeHaan
8c4161d4a1
Merge branch 'retf_py' of git://github.com/berendt/ansible into devel
...
Conflicts:
lib/ansible/inventory/vars_plugins/group_vars.py
plugins/callbacks/mail.py
2014-08-08 12:17:37 -04:00
Serge van Ginderachter
7c96f1d803
InventoryDir: fixing yet another corner case
2014-08-08 08:54:11 +02:00
Serge van Ginderachter
e8b45a9ef7
Invalidate host/group variables cache when loading
...
extra varsiables based on playbook basedir.
2014-07-14 15:21:33 +02:00
Serge van Ginderachter
d39ff55688
Fix logic bug when loading vars for a new playbook basedir.
2014-07-14 15:12:53 +02:00
James Cammarata
4e5eb7559e
Merge branch 'svg_and_inventory_refactor' into devel
2014-07-10 14:43:07 -05:00
Dan Slimmon
307a3e8a9c
Fixed regex square-bracket bug.
...
Regexes were being parsed like ordinary ansible host patterns, so
square-bracket groups were getting interpolated wrongly.
2014-07-10 00:08:12 +00:00
James Cammarata
aa261bdd14
Optimizing groups_for_host() lookup in inventory
2014-07-07 21:08:39 -05:00
James Cammarata
fe892fccb1
Merge remote-tracking branch 'svg/varsplugins_refactor' into svg_and_inventory_refactor
2014-07-07 14:16:37 -05:00
James Cammarata
11a5fc85f4
Merge branch 'inventory_refactoring' into svg_and_inventory_refactor
2014-07-07 13:11:58 -05:00
James Cammarata
bcf83cbc24
Merge branch 'sergevanginderachter-inventorytree' into svg_and_inventory_refactor
2014-07-07 13:11:52 -05:00
Serge van Ginderachter
ff4119adc0
Performance optimization in resolving host patterns
...
Avoid resolving a pattern that is a plain host. When matching a hostname in the
hosts_cache, just use the host object from there.
When running a task on say 750 hosts, this yields a huge improvement.
2014-07-07 12:50:50 -05:00
James Cammarata
ff04b2b532
Allow empty yaml vars files
...
Fixes #7843
2014-07-04 23:10:32 -05:00
Michael DeHaan
c2ac8fda1e
Data from inventory scripts should be able to use nested Jinja2 expressions.
2014-07-03 16:11:14 -04:00
James Cammarata
8ed6350e65
When parsing json from untrusted sources, remove templating tags
2014-07-01 14:14:14 -05:00
James Cammarata
539426f612
Performance tuning inventory functions for large inventories
2014-06-26 23:15:39 -05:00
James Cammarata
d8a7b49b59
Merge branch 'inventorytree' of https://github.com/sergevanginderachter/ansible into sergevanginderachter-inventorytree
2014-06-24 15:21:08 -05:00
Kevin Bell
92bd755b47
Fixed extension filtering in InventoryDirectory
2014-05-14 23:43:14 -07:00
James Cammarata
393124e462
Add pyc/pyo to ignore list for inventory directories
...
Fixes #7308
2014-05-07 09:59:13 -05:00
Christian Berendt
6676720ce5
fixed typos found by RETF rules in PY files
...
rules are avaialble at https://en.wikipedia.org/wiki/Wikipedia:AutoWikiBrowser/Typos
2014-05-03 18:40:05 +02:00
Serge van Ginderachter
e36e2d38fe
InventoryDir: another fix for the host.groups list
...
In some cases, where a host is mentioned in multiple groups, and those
groups are referenced in multiple ini files, a group could still contain
multiple instances of a group in its host,groups list, where only one of them
is the right group, that exists in the inventory.
2014-04-04 09:27:44 +02:00
Cristian Ciupitu
96ff1444f0
Micro-optimization: replace s.find(x)==0 with s.startswith(x)
...
timeit shows a speedup of ~1.4x on Python 2.7.5 x86_64.
It also makes the code a bit shorter.
2014-03-27 20:35:20 +02:00
Serge van Ginderachter
d4634983f0
Move group/host_vars parsing into core inventory
...
modified: lib/ansible/inventory/__init__.py
deleted: lib/ansible/inventory/vars_plugins/group_vars.py
modified: lib/ansible/utils/__init__.py
2014-03-26 11:37:26 +01:00
Serge van Ginderachter
f8ea93c732
Move inventory.set_playbook_basedir from ansible-playbook to playbook constructor
2014-03-25 22:12:01 +01:00
Serge van Ginderachter
cc28fd891b
Introduce noop vars plugin.
...
In preparation to move the group_vars plugin code into core.
new file: lib/ansible/inventory/vars_plugins/noop.py
2014-03-25 22:12:01 +01:00
Serge van Ginderachter
f6a55a3552
Refactor vars_plugins (host/group_vars)
...
Split out parsing of vars files to per host and per group
parsing, instead of reparsing all groups for each host. This enhances
performance.
Extend vars_plugins' API with two new methods:
* get host variables: only parses host_vars
* get group variables: only parses group_vars for specific group
The initial run method is still used for backward compatibility.
Parse all vars_plugins at inventory initialisation, instead of
per host when touched first by runner. Here we can also loop through
all groups once easily, then parse them.
This also centralizes all parsing in the inventory constructor.
modified: bin/ansible
modified: bin/ansible-playbook
modified: lib/ansible/inventory/__init__.py
modified: lib/ansible/inventory/vars_plugins/group_vars.py
2014-03-25 22:12:01 +01:00
James Cammarata
846933dd53
Make inventory parsing error detection smarter
...
If something is executable but doesn't look like it should be, or if
something is NOT executable and DOES looks like it should, show a
more apropos error with a hint on correcting the problem
Fixes #5113
2014-03-25 11:41:00 -05:00
Serge van Ginderachter
d3eaa1b79e
InventoryDir: refactor logic
...
Make sure all hosts and groups are unique objects
and that those are referenced uniquely everywhere.
Also fixes test_dir_inventory unit tests which were broken after previous
patches.
modified: lib/ansible/inventory/dir.py
2014-03-25 12:45:00 +01:00
Serge van Ginderachter
188375171e
Inventory: raise error when adding a group that already exists.
...
The parsers check if a group already exists.
2014-03-25 12:45:00 +01:00
Serge van Ginderachter
be58808fe4
inventory script parser: do not add all the groups to *all* group
2014-03-25 12:45:00 +01:00
Serge van Ginderachter
0ceefbbf29
inventory ini parser: do not add all the groups to *all* group
...
but only those with lowest depth, so we keep a proper tree structure
2014-03-25 12:45:00 +01:00
Serge van Ginderachter
cc8efb4aab
inventory groups: make sure group.depth is updated on all grandchildren
2014-03-25 12:45:00 +01:00
Serge van Ginderachter
1c86909875
inventory group: add groups to parent_groups only once
2014-03-25 12:45:00 +01:00
Serge van Ginderachter
36f55d3549
inventory directory parser: add host to group only once
2014-03-25 12:45:00 +01:00
Serge van Ginderachter
8b215149d4
inventory directory parser: add groups to parent_groups non-recursively
2014-03-25 12:45:00 +01:00
Serge van Ginderachter
262ba0460a
inventory directory parser: add hosts to group non-recursively
2014-03-25 12:45:00 +01:00
Michael DeHaan
9da26da335
Merge branch 'ini_vars' of git://github.com/dmage/ansible into devel
2014-03-17 17:37:57 -04:00
Serge van Ginderachter
280498a7e5
Pass through vault_password when parsing host/group vars as directories.
...
Fixes a bug where vault_password parameter was not passed through in
_load_vars_from_folder()
modified: lib/ansible/inventory/vars_plugins/group_vars.py
2014-03-17 10:51:04 +01:00
Michael DeHaan
b41541c62a
Merge conflict.
2014-03-16 16:48:03 -04:00
Michael DeHaan
4a06954a13
Merge pull request #6390 from sergevanginderachter/group-varsdirs-svn
...
group_vars plugin: do not parse hidden files in subfolders
2014-03-16 14:44:17 -05:00
Oleg Bulatov
f6a4c20cc0
Make parsing variables for hosts and groups more consistent
...
This commit allows to specify arrays in [group:vars] block.
Signed-off-by: Oleg Bulatov <oleg@bulatov.me>
2014-03-16 21:47:26 +04:00
Michael DeHaan
d5856bd475
Merge pull request #6391 from sergevanginderachter/hashmerge_inventoryscripts
...
Allow hash_behaviour=merge to be respected in core inventory
2014-03-16 12:42:35 -05:00
Cristian Ciupitu
0749112286
Micro-optimization: replace s.find(x)!=-1 with x in s
...
timeit shows a speedup of ~3x on Python 2.7.5 x86_64.
It also makes the code a bit shorter.
2014-03-16 13:10:28 -04:00
Cristian Ciupitu
a7da5d8702
Micro-optimization of inventory.expand_hosts.detect_range
2014-03-16 13:10:28 -04:00
Serge van Ginderachter
6b1cb22fc3
Allow hash_behaviour=merge to be respected in core inventory
...
(For now, this means, enable it also for inventory scripts)
2014-03-11 12:49:54 +01:00
Serge van Ginderachter
29c60bdaff
group_vars plugin: do not parse hidden files in subfolders, e.g. avoid .svn/
2014-03-11 12:20:58 +01:00
James Cammarata
e3b887f770
Fix range issue in inventory and add additional error checking
...
Fixes #6331
2014-03-07 16:34:04 -06:00
Richard C Isaacson
16fe09eef8
Fixes related to uncommenting test_dir_inventory in TestInventory.
...
0. Uncomment the test.
1. Test fails.
2. Make vars unique per file in test inventory files.
3. Modify token addition to not ast.literal_eval(v) a variable containing a hash.
4. Modify vars to have an escape in test inventory file.
5. Catch exceptions explicitly. Any unknown exceptions should be a bug.
6. Test passes.
2014-03-06 12:09:53 -06:00
Michael DeHaan
94a7fb60fe
Allow escaped comments in inventory files.
2014-03-05 20:10:25 -05:00
Richard C Isaacson
b41d8106ff
Revert "Merge pull request #6287 from risaacson/fix_hash_in_var"
...
This reverts commit a808287451
, reversing
changes made to 6129ea7566
.
2014-03-05 14:49:30 -06:00
Richard C Isaacson
38abd5e20e
Break this out into a reusable function and document regex shortcomings.
2014-03-05 10:50:58 -06:00
Richard C Isaacson
49bd8b0b35
Fix inventory for test_dir_inventory
...
It came up that fixing this unit test may relate to another ticket that is open. This work allows us to uncomment this unit test by fixing how we pars variables allowing a quoted variable to contain a '#'.
Work also went into cleaning up some of the test data to clarify what was working.
Lastly work went into cleaning up formatting so that the code is easily read.
2014-03-04 18:31:49 -06:00
Jesse Keating
0c2c37a47a
Avoid range selection on empty groups
...
This prevents a traceback when the group is empty.
Fixes #6258
2014-03-03 13:23:27 -08:00
James Cammarata
f23ccebbdc
Merge branch 'issue_4620' of https://github.com/jimi-c/ansible into jimi-c-issue_4620
2014-02-24 20:30:25 -06:00
James Tanner
427b8dc78d
Ansible vault: a framework for encrypting any playbook or var file.
2014-02-18 15:35:12 -05:00
Ilya Kuznetsov
0658847ea6
Allow equal sign in single-line ini variables
2014-02-14 20:04:23 +07:00