Commit Graph

475 Commits (3a92bb542807de3795702abe4e15ba65b38c9bf5)

Author SHA1 Message Date
James Cammarata 84507aedd4 Adding a uuid field so we can track host equality across serialization too 9 years ago
James Cammarata 750adbaa27 Changing up how host (in)equality is checked
Fixes #13397
9 years ago
Brian Coca 8d5f36a6c2 return unique list of hosts 9 years ago
James Cammarata f467f1770f Properly compare object references for Hosts when adding new ones
Fixes #13397
9 years ago
nitzmahone 349e072a74 fix for dynamic (add_host) hosts not available in hostvars
Looks like there are two pattern caches that need to be cleared for this to work- added the second one.
Added integration tests for add_host to prevent future regressions.
9 years ago
James Cammarata e56fd9e95d Make sure pattern cache components are converted to unicode 9 years ago
James Cammarata 0b999c602a Properly figure subset and restrictions into host cache pattern
Fixes #13111
9 years ago
James Cammarata c753ae6e22 Fixing up host pattern caching to avoid bugs
* Always cache and return unique list objects, so that if the list
  is changed later it does not impact the cached results
* Take additional parameters and the type of the pattern into account
  when building the hash string
9 years ago
James Cammarata 5040abaaf2 Merge branch 'devel_cache_for_do_template_call' of https://github.com/Yannig/ansible into Yannig-devel_cache_for_do_template_call 9 years ago
James Cammarata 63c47fb271 Fixing up performance 9 years ago
Brian Coca 483c25a609 Revert "switched host patterns to use sets, simplified logic which now uses buitins"
need this to be lists, for order and other considerations
This reverts commit 8e2f0b3f2c.
9 years ago
Brian Coca 88ba46aee0 Revert "fixed append to add"
good change on top of bad
This reverts commit 699f344e17.
9 years ago
Brian Coca 699f344e17 fixed append to add 9 years ago
Brian Coca 8e2f0b3f2c switched host patterns to use sets, simplified logic which now uses buitins 9 years ago
Yannig Perre e0aa3ff232 Cache against hosts pattern (fix a part of problem describe in https://github.com/ansible/ansible/issues/13023). 9 years ago
Brian Coca 13bf62d0e6 remove deprecation for :, add ; functionality (its deprecated but it should work) 9 years ago
James Cammarata 86de1429e5 Cleaning up FIXMEs 9 years ago
Toshio Kuratomi f34b55ac2b Add python3-compat boilerplate to all .py files in lib/ansible 9 years ago
Toshio Kuratomi a17ae6f07e Clean up pyflakes warnings in inventory 9 years ago
Brian Coca 6d87bd405d Merge pull request #12765 from bcoca/lookup_inventory_hostname
implemented inventory_hostname lookup in v2
9 years ago
Toshio Kuratomi baa309309d Bundle a new version of python-six for compatibility along with some code to make it easy for distributions to override the bunndled copy if they have a new enough version. 9 years ago
Brian Coca 9b088a1e40 implemented inventory_hostname lookup in v2 9 years ago
James Cammarata 91b0b4d40c Check is_directory() before not is_file() in inventory basedir
Fixes #12742
9 years ago
James Cammarata e6d3c6745f Revert to using local file/dir tests in inventory instead of loader's
Fixes #12719
9 years ago
Brian Coca c637d60a8d fixed deprecation message 9 years ago
James Cammarata 5a0f5f1254 Load vars for localhost when created implicitly
Fixes #12666
9 years ago
James Cammarata 57372906aa Pull host/group vars when adding hosts/groups
Fixes #12582
9 years ago
Abhijit Menon-Sen 93515468c4 Remove an unwanted FIXME annotation
<crab> jimi|ansible: do you think it should be possible to add both
       foo:22 and foo:23 to the inventory?
<jimi|ansible> no

…so we don't want an invitation to FIXME.
9 years ago
James Cammarata 40bdf09998 Merge pull request #12561 from srvg/anotherdirpy
Inject existing groups at InventoryDir initialization
9 years ago
Abhijit Menon-Sen 50d75f8d6d Bring groups handling in ini.py up-to-date
Since c8f2483d, ini.py expects to always be passed in a pre-created list
of groups, and can no longer deal sensibly with an empty list; this just
makes that expectation clear.
9 years ago
Serge van Ginderachter 7461ba9998 Inject existing groups at InventoryDir initialization
This fixes a corner case where ini files live in a subdir
of the main inventory directory.

Reproducing the original error:

mkdir -p inventory/ini
cat > inventory/ini/hosts << EOF
[www]
www1
EOF

$ ansible -i inventory/ all -m ping
ERROR! 'all'

(or without the [www] group, it would complain about 'ungrouped')
9 years ago
Abhijit Menon-Sen 8251ab2e37 Update outdated comment
Since #12165 was merged, hostnames are properly validated.
9 years ago
James Cammarata ae9b34b1d9 Fix for equality checking in Host to make sure things are like types 9 years ago
James Cammarata ccddda1ebc Merge pull request #12502 from mgedmin/py3k
Python 3: make test_variable_manager_precedence pass
9 years ago
James Cammarata 12df9f2e31 Make hostvars more dynamic again to improve performance with large inventories
Fixes #12477
9 years ago
Marius Gedminas 0624797375 Bugfix: if you define a custom __eq__, you must define a __hash__ too
Also, on Python 3 the stock object.__hash__ raises an error ("unhashable
type"), and we have code that uses Host instances as dict keys.
9 years ago
Marius Gedminas a2bc6b4b26 Bugfix: if you define __eq__, you should define __ne__ too 9 years ago
Marius Gedminas 5d29a2eabd Python 3: shlex.split() wants unicode
On Python 2, shlex.split() raises if you pass it a unicode object with
non-ASCII characters in it.  The Ansible codebase copes by explicitly
converting the string using to_bytes() before passing it to
shlex.split().

On Python 3, shlex.split() raises ('bytes' object has no attribute 'read')
if you pass a bytes object.  Oops.

This commit introduces a new wrapper function, shlex_split, that
transparently performs the to_bytes/to_unicode conversions only on
Python 2.

Currently I've only converted one call site (the one that was causing a
unit test to fail on Python 3).  If this approach is deemed suitable,
I'll convert them all.
9 years ago
Marius Gedminas 95e655eb67 Python 3: there's no basestring
Fixes one failing test.

The long series of module_utils/basic.py fixes were all because
module_utils/basic is imported in ansible/inventory/script.py.
9 years ago
Victor Salgado 20bbd66e85 Use dict.get() 9 years ago
James Cammarata 65bf14cbb0 Merge pull request #12431 from hslee16/devel
Stops using _groups_list to check for host when using 'add_host'
9 years ago
Abhijit Menon-Sen 2fcdb37e7b Support «hosts: groupname[1:]» notation (~= 'the rest of the group') 9 years ago
Alex Lee cf289191e5 return None if group does not exist in inventory groups 9 years ago
James Cammarata b386f0c64d Merge pull request #12423 from amenonsen/split-fixup
Remove deprecation warning; now handled in _split_patterns
9 years ago
James Cammarata a1fffff92c Merge branch 'addresses' of https://github.com/amenonsen/ansible into amenonsen-addresses 9 years ago
Abhijit Menon-Sen 62ca6b5e35 Remove deprecation warning; now handled in _split_patterns 9 years ago
Abhijit Menon-Sen 575a8b8c77 Merge Host.ipv[46]_address into .address
The earlier distinction was never used; .ipv6_address was always a copy
of .ipv4_address, and the latter was always used to set the remote_addr
field in the PlayContext.

Also uses the canonical ansible_host/ansible_port names when setting the
address and port from variables.
9 years ago
James Cammarata 951128d7a6 Merge branch 'hostpatterns' of https://github.com/amenonsen/ansible into amenonsen-hostpatterns 9 years ago
Victor Salgado 14fefebaad Modify _split_pattern to use map when working with list input 9 years ago
Abhijit Menon-Sen 2405861a9e Use ',' instead of ':' or ';' to separate host patterns
The earlier-recommended "pat1:pat2:pat3[x:y]" notation doesn't work well
with IPv6 addresses, so we recommend ',' as a separator instead. We know
that commas can't occur within a pattern, so we can just split on it.

We still have to accept the "foo:bar" notation because it's so commonly
used, but we issue a deprecation warning for it.

Fixes #12296
Closes #12404
Closes #12329
9 years ago
Brian Coca ee840f3029 fixed function signature 9 years ago
James Cammarata e97d448838 Cleanup one more missed inventory bug 9 years ago
James Cammarata 11c27078c0 Cleaning up inventory bugs from earlier group change 9 years ago
Victor Salgado 54f1560d3e Fix mutable default argument 9 years ago
James Cammarata c8f2483d6d Cleaning up default group creation in inventory parsers 9 years ago
Thomas Quinot c005f75469 Always create 'all' group
Create 'all' even if host_list is empty, as this group needs to exist
when creating the implicit 'localhost' host.

Fixes #12391
9 years ago
Abhijit Menon-Sen 065bb52109 Be systematic about parsing and validating hostnames and addresses
This adds a parse_address(pattern) utility function that returns
(host,port), and uses it wherever where we accept IPv4 and IPv6
addresses and hostnames (or host patterns): the inventory parser
the the add_host action plugin.

It also introduces a more extensive set of unit tests that supersedes
the old add_host unit tests (which didn't actually test add_host, but
only the parsing function).
9 years ago
Toshio Kuratomi fa2edfa1ef * Make sure we don't sometimes get byte strings instead of unicode strings
* Turn strings into byte strings before passing to shlex and turn them
  back into unicode strings after they are retyurned from there

  Fixes #12257
9 years ago
Toshio Kuratomi e67459df86 Fix docstring of parse_value() to be informative 9 years ago
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.
9 years ago
Marius Gedminas 823677b490 Replace .iteritems() with six.iteritems()
Replace .iteritems() with six.iteritems() everywhere except in
module_utils (because there's no 'six' on the remote host).  And except
in lib/ansible/galaxy/data/metadata_template.j2, because I'm not sure
six is available there.
9 years ago
Abhijit Menon-Sen 147b04b682 Remove duplicated function definition (fallout from earlier repeated merge) 9 years ago
Brian Coca b525eedb8e less misleading message for when someone looks up vars for a host not in inventory 9 years ago
James Cammarata 4c65306e73 Merge branch 'hostrange' of https://github.com/amenonsen/ansible into amenonsen-hostrange 9 years ago
Brian Coca 514fa73fcd galaxy fixes 9 years ago
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.
9 years ago
Ilya Epifanov 81bf88b6e0 fixed hostvars access in conjunction with --limit usage 9 years ago
Brian Coca b2ae6945c4 always load vars plugins
fixes #12104
9 years ago
Brian Coca 82603bb2a0 avoids running abspath on None 9 years ago
Abhijit Menon-Sen 8bf0dbb7a9 Use [x:y] host ranges instead of [x-y]
This commit deprecates the earlier groupname[x-y] syntax in favour of
the inclusive groupname[x:y] syntax. It also makes the subscripting
code simpler and adds explanatory comments.

One problem addressed by the cleanup is that _enumeration_info used to
be called twice, and its results discarded the first time because of the
convoluted control flow.
9 years ago
Abhijit Menon-Sen 73f10de386 Document the behaviour of _match_one_pattern in some detail
The possibilities are complicated enough that I didn't want to make
changes without having a complete description of what it actually
accepts/matches. Note that this text documents current behaviour, not
necessarily the behaviour we want. Some of this is undocumented and may
not be intended.
9 years ago
Abhijit Menon-Sen fa6ffa1dbd Remove & and ! pattern prefixes as early as possible
Now everything under _match_one_pattern can ignore them. This also means
that we can use the cache to return the same results for 'foo' and '!foo'.
9 years ago
Abhijit Menon-Sen 704c3815d3 Reorder functions into a logical sequence based on usage
There are no code changes; this is committed separately so as to make
the subsequent "real" diffs easier to read.
9 years ago
Brian Coca f1b8323b62 fixed host/group var loading when inventory is a directory 9 years ago
James Cammarata e282309f6d Make sure the inventory restriction is not None 9 years ago
Abhijit Menon-Sen 745ecd4845 Sanitize IPv6 hostname/port handling
Now we accept IPv6 addresses _with port numbers_ only in the standard
[xxx]:NN notation (though bare IPv6 addresses may be given, as before,
and non-IPv6 addresses may also be placed in square brackets), and any
other host identifiers (IPv4/hostname/host pattern) as before, with an
optional :NN suffix.
9 years ago
Abhijit Menon-Sen 74aab6f726 Use a self._raise_error helper and avoid passing the lineno around
Based on a patch by @Richard2ndQuadrant.
9 years ago
Abhijit Menon-Sen 9133cd409c Make _parse take an array of input lines as an argument
(There's no compelling reason to do this right now, but should be parser
need to be called multiple times in future, this makes it easier.)
9 years ago
Abhijit Menon-Sen 98a1905796 Rename 'section' to 'groupname' to better reflect its purpose 9 years ago
Abhijit Menon-Sen 1284c49bd7 Rewrite the INI InventoryParser
The new code parses INI-format inventory files in a single pass using a
well-documented state machine that reports precise errors and eliminates
the duplications and inconsistencies and outright errors in the earlier
three-phase parsing code (e.g. three ways to skip comments). It is also
much easier now to follow what decisions are being taken on the basis of
the parsed data. The comments point out various potential improvements,
particularly in the area of consistent IPv6 handling.

On the ornate marble tombstone of the old code, the following
inscription is one last baffling memento from a bygone age:

-    def _before_comment(self, msg):
-        ''' what's the part of a string before a comment? '''
-        msg = msg.replace("\#","**NOT_A_COMMENT**")
-        msg = msg.split("#")[0]
-        msg = msg.replace("**NOT_A_COMMENT**","#")
-        return msg
9 years ago
Brian Coca 961bee00d5 centralized the definition of 'localhost' 9 years ago
Abhijit Menon-Sen 2641f70e47 Reset self._groups_cache in refresh_inventory 9 years ago
Harald Laabs 73d6da757f Make get_group run in O(n*log(n)) instead of O(n^2) by using a cache 9 years ago
Will West b8865314ec improve ansible start up time for very large inventory
first off, we add an oddly slow basic test of 10k item inventory

Before:
```
Ran 229 tests in 13.214s

OK

real    0m13.403s
user    0m12.106s
sys 0m1.155s
```

After:
```
Ran 230 tests in 21.328s

OK

real    0m21.516s
user    0m20.099s
sys 0m1.275s
```

since that seems like a bit long for the test to add to runtime, lets profile

`python -m cProfile -s time ./bin/ansible all -i test/units/inventory_test_data/huge_range --list-hosts`

Before:
```
         1272607 function calls (1259689 primitive calls) in 8.497 seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    10000    4.393    0.000    4.396    0.000 __init__.py:395(_get_host)
    20000    2.695    0.000    2.697    0.000 __init__.py:341(__append_host_to_results)
    40369    0.113    0.000    0.113    0.000 {posix.lstat}
    50006    0.102    0.000    0.153    0.000 __init__.py:1490(combine_vars)
    40008    0.089    0.000    0.202    0.000 __init__.py:1546(_load_vars_from_path)
    20195    0.088    0.000    0.088    0.000 {posix.stat}
    10011    0.087    0.000    0.087    0.000 {posix.getcwd}
```

The top two lines are promising optimization targets

- populate Inventory's host cache more in _get_host, as we are looping
  over all the groups anyways.

- eliminate duplicate check of whether we've already included a host
  in the construction around __append_host_to_results we can infer
  presence of a host in the results list implies the presence of its
  name in the hostnames set, allowing us to only to the less expensive
  of the two checks

After:
```
         1252610 function calls (1239692 primitive calls) in 1.320 seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    40369    0.105    0.000    0.105    0.000 {posix.lstat}
    50006    0.094    0.000    0.141    0.000 __init__.py:1490(combine_vars)
    40008    0.081    0.000    0.184    0.000 __init__.py:1546(_load_vars_from_path)
    10011    0.080    0.000    0.080    0.000 {posix.getcwd}
    20195    0.074    0.000    0.074    0.000 {posix.stat}
    10002    0.069    0.000    0.261    0.000 __init__.py:1517(load_vars)
```
9 years ago
Abhijit Menon-Sen 8f231ec469 Tweak deprecation warning, and apply it to --limit also 9 years ago
James Cammarata 4dba30ccd0 Cleanup missed merge conflict sections 9 years ago
Abhijit Menon-Sen d41db8edd6 Don't accept undocumented "p1;p2" patterns; note in changelog
The correct (and now only) way to say p1 OR p2 is "p1:p2".
9 years ago
Abhijit Menon-Sen 1437b8e120 Introduce _split_pattern to parse an "x:y:z" pattern
This function takes a string like 'foo:bar[1:2]:baz[x:y]-quux' and
returns a list of patterns ['foo', 'bar[1:2]', 'baz[x:y]-quux'], i.e.
splits the string on colons that are not part of a range specification.
9 years ago
James Cammarata 32034feec5 Add deprecation warning regarding host patterns 9 years ago
Abhijit Menon-Sen 6bf6b9fdbb Rename some internal functions, clarify what they do
get_hosts → used externally, not changed
_get_hosts → _evaluate_patterns (takes a list, evaluates ! and &)
__get_hosts → _match_one_pattern (takes one pattern only, ignores !&)
9 years ago
Abhijit Menon-Sen eff33bac49 Don't accept undocumented "p1;p2" patterns; note in changelog
The correct (and now only) way to say p1 OR p2 is "p1:p2".
9 years ago
Abhijit Menon-Sen 8aaa06dd50 Introduce _split_pattern to parse an "x:y:z" pattern
This function takes a string like 'foo:bar[1:2]:baz[x:y]-quux' and
returns a list of patterns ['foo', 'bar[1:2]', 'baz[x:y]-quux'], i.e.
splits the string on colons that are not part of a range specification.
9 years ago
Abhijit Menon-Sen baf637b9ae Remove dead code: Inventory.also_restrict_to/lift_also_restriction
This was used earlier to implement serial, but that's now done using
restrict_to_hosts() (whose docstring is also suitably adjusted here)
and there are no more callers.
9 years ago
Brian Coca b905f51341 fixed typo 9 years ago
Brian Coca fbc7224066 Merge pull request #11643 from bcoca/meta_inventory_and_fixes
Meta inventory and fixes
9 years ago
Brian Coca 5fec11f513 capture parsing exceptions and give nice error and location 9 years ago
Brian Coca 49d88cef9c meta: refresh_inventory and several inventory fixes 9 years ago
Brian Coca 8e30e3791e Merge pull request #11811 from amenonsen/fixme-range
FIXME in host range parsing
9 years ago
James Cammarata 26d5a17b59 Make sure inventory loads files with non-relative paths
This is a slightly different fix than we originally committed, but fixes
the problem in a less invasive way (and I believe it's generally better
that we don't deal with relative paths internally past this point)

Fixes #11789
9 years ago
Brian Coca b9433650d1 Revert "Path of group_vars and host_vars were getting the basedir added twice."
in view of simpler solution incomming from james
This reverts commit bae7a02be5.
9 years ago
Toshio Kuratomi bae7a02be5 Path of group_vars and host_vars were getting the basedir added twice.
Fix inventory so this won't happen and fix DataLoader so that it will
test relative paths relative to self._basedir

Fixes #11789
9 years ago
Toshio Kuratomi f0431eaea9 Make ansible_python_interpreter work with synchronize
Fixes #11836
9 years ago
Abhijit Menon-Sen 7d9689c1c5 Slice ascii_letters directly instead of using 'for x in range()' 9 years ago
Abhijit Menon-Sen bfe708a189 Make host range parsing errors issue better messages
Now we always say "host range must …specific thing…"
9 years ago
Abhijit Menon-Sen 1413496292 Implement step for alphabetic ranges: [a:e:2] => a,c,e 9 years ago
Brian Coca f16b745f17 now properly uses default port if defined 9 years ago
Abhijit Menon-Sen 845784b572 Remove outdated FIXMEs; all use combine_vars already 9 years ago
Brian Coca 77fc3ce759 removed unused import 9 years ago
James Cammarata 49a6601856 Further cleanup of internal use of ansible_ssh_host 9 years ago
James Cammarata a1a8997e89 Merge pull request #11663 from whereismyjetpack/fix_ansible_ssh_host
only set ansible_ssh_host if not already set
9 years ago
James Cammarata 65ae9780fa Merge pull request #11079 from amegianeg/fix_broad_except_in_inventory
Avoid too broad except in Inventory
9 years ago
Dann Bohn 3e79bfa2d6 only set ansible_ssh_host if not already set 10 years ago
Gerard Lynch d23ab261e1 fixes 11607, allows ansible_ssh_port to be overridden from group or host_vars 10 years ago
James Cammarata 4e94bb64d8 Fix group/host var loading relative to playbook basedir 10 years ago
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
10 years ago
James Cammarata ff251a0dcc Catch runtime errors due to recursion when calculating group depth
Fixes #7708
10 years ago
Benno Joy f17bdc4d61 Set the ansible_ssh_port variable instead of saving it internally for Host
Fixes #11330
10 years ago
James Cammarata 87ca475704 Exclude the all/ungrouped groups from pattern matching results
Fixes #5375
10 years ago
James Cammarata 90445ee67d Add ::1 where we see 127.0.0.1, for better ipv6 support
Fixes #5764
10 years ago
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 ?
10 years ago
James Cammarata 30c1a2d861 Have group/host var file loading check for YAML extensions too
Fixes #11132
10 years ago
Toshio Kuratomi f9b56a5d7c Fix raising AnsibleError 10 years ago
Toshio Kuratomi 96836412aa Make error messages tell which inventory script the error came from 10 years ago
Toshio Kuratomi 1c8527044b Fix error handling when pasing output from dynamic inventory 10 years ago
James Cammarata 620fad9f8d Fixing an oops in inventory/__init__.py where the slots are incorrect 10 years ago
James Cammarata fe41f109a9 Merge branch 'v2_final' into devel_switch_v2 10 years ago
James Cammarata 4bc7703db3 Fixing some small bugs related to integration tests (v2) 10 years ago
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
10 years ago
alberto 37ae5aab31 Capture only IOError when reading shebang from inventory file, to avoid ignoring other possible exceptions like timeouts from a task 10 years ago
Brian Coca 0913b8263c made special treatment of certain filesystem for selinux configurable 10 years ago
Brian Coca e2de336a23 made special treatment of certain filesystem for selinux configurable 10 years ago
James Cammarata ce3ef7f4c1 Making the switch to v2 10 years ago
Brian Coca c3d34a5386 Merge pull request #8936 from srvg/inventoryscript_onlychildren
Allow InventoryScript JSON with childgroups only
10 years ago
Toshio Kuratomi 084fbbdea9 Reverse the conditional so there's one less return from this function 10 years ago
Alvaro Lopez Ortega 2e929cf0ce Fixes bug #10281 - Trailing zeros were truncated from strings 10 years ago
Alvaro Lopez Ortega a14248ffe1 Fixes bug #10281 - Trailing zeros were truncated from strings 10 years ago
Brian Coca 751701c6f2 Merge pull request #9672 from quinot/topic/lineno-in-inventory-err
Report location (filename and line number) for inventory syntax errors
10 years ago
Toshio Kuratomi a63e4c595f Another place that needs to be json_dict_bytes_to_unicode 10 years ago
Toshio Kuratomi 0f6b87d33e Revert "Fix import statements" -- those impotrt statements were right
before... something else is fishy

This reverts commit 8ab536fbf2.
10 years ago
Toshio Kuratomi 8ab536fbf2 Fix import statements 10 years ago
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
10 years ago
Brian Coca 2ef5d6be1e Merge pull request #9702 from bcoca/better_errors_on_delegate
better exception handling with delegated hosts
10 years ago
Brian Coca 6b3d0f4788 now captures returncode errors on inventory scripts 10 years ago
Brian Coca 61a30e5f49 better exception handling with delegated hosts 10 years ago
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.
10 years ago
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
10 years ago
Toshio Kuratomi a10d10f647 Workaround more python-2.6 shlex not being able to handle unicode strings 10 years ago
Toshio Kuratomi cef2a8795f Make dynamic inventory return byte str, not unicode 10 years ago
Michael DeHaan 26cdddaebf Tracebacks are now catchable with ignore_errors and have streamlined output. Also removes 'baby-JSON' for bash modules. 10 years ago
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
10 years ago