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
Serge van Ginderachter
3a228b9d55
InventoryScript: better syntax checking for json stream
10 years ago
Serge van Ginderachter
a1f09bd89f
Merge variables for hosts instead of updating in get_variables()
10 years ago
Serge van Ginderachter
0ab721d51e
better logic for all-group variables for implicit localhost
10 years ago
Serge van Ginderachter
a2cfe8770b
Inventory: fix logic mistake in loading/retrieving variables for groups
10 years ago
James Cammarata
e3895840d1
Make sure group_vars/all is loaded for ungrouped hosts
...
Fixes #6563
10 years ago
James Cammarata
b4476c238f
Use match() instead of search() for pattern matching
...
Also related to f48fa3, fix for #8614
10 years ago
James Cammarata
f48fa3759a
Fix host pattern matching and enhance error detection
...
Fixes #8614
10 years ago
James Cammarata
bea0845322
Fix vault_password positional args error
10 years ago
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
10 years ago
Serge van Ginderachter
7c96f1d803
InventoryDir: fixing yet another corner case
10 years ago
Serge van Ginderachter
e8b45a9ef7
Invalidate host/group variables cache when loading
...
extra varsiables based on playbook basedir.
11 years ago
Serge van Ginderachter
d39ff55688
Fix logic bug when loading vars for a new playbook basedir.
11 years ago
James Cammarata
4e5eb7559e
Merge branch 'svg_and_inventory_refactor' into devel
11 years ago
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.
11 years ago
James Cammarata
aa261bdd14
Optimizing groups_for_host() lookup in inventory
11 years ago
James Cammarata
fe892fccb1
Merge remote-tracking branch 'svg/varsplugins_refactor' into svg_and_inventory_refactor
11 years ago
James Cammarata
11a5fc85f4
Merge branch 'inventory_refactoring' into svg_and_inventory_refactor
11 years ago
James Cammarata
bcf83cbc24
Merge branch 'sergevanginderachter-inventorytree' into svg_and_inventory_refactor
11 years ago
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.
11 years ago
James Cammarata
ff04b2b532
Allow empty yaml vars files
...
Fixes #7843
11 years ago
Michael DeHaan
c2ac8fda1e
Data from inventory scripts should be able to use nested Jinja2 expressions.
11 years ago
James Cammarata
8ed6350e65
When parsing json from untrusted sources, remove templating tags
11 years ago
James Cammarata
539426f612
Performance tuning inventory functions for large inventories
11 years ago
James Cammarata
d8a7b49b59
Merge branch 'inventorytree' of https://github.com/sergevanginderachter/ansible into sergevanginderachter-inventorytree
11 years ago
Kevin Bell
92bd755b47
Fixed extension filtering in InventoryDirectory
11 years ago
James Cammarata
393124e462
Add pyc/pyo to ignore list for inventory directories
...
Fixes #7308
11 years ago
Christian Berendt
6676720ce5
fixed typos found by RETF rules in PY files
...
rules are avaialble at https://en.wikipedia.org/wiki/Wikipedia:AutoWikiBrowser/Typos
11 years ago
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.
11 years ago
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.
11 years ago
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
11 years ago
Serge van Ginderachter
f8ea93c732
Move inventory.set_playbook_basedir from ansible-playbook to playbook constructor
11 years ago
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
11 years ago
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
11 years ago
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
11 years ago
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
11 years ago
Serge van Ginderachter
188375171e
Inventory: raise error when adding a group that already exists.
...
The parsers check if a group already exists.
11 years ago
Serge van Ginderachter
be58808fe4
inventory script parser: do not add all the groups to *all* group
11 years ago
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
11 years ago
Serge van Ginderachter
cc8efb4aab
inventory groups: make sure group.depth is updated on all grandchildren
11 years ago
Serge van Ginderachter
1c86909875
inventory group: add groups to parent_groups only once
11 years ago
Serge van Ginderachter
36f55d3549
inventory directory parser: add host to group only once
11 years ago
Serge van Ginderachter
8b215149d4
inventory directory parser: add groups to parent_groups non-recursively
11 years ago
Serge van Ginderachter
262ba0460a
inventory directory parser: add hosts to group non-recursively
11 years ago
Michael DeHaan
9da26da335
Merge branch 'ini_vars' of git://github.com/dmage/ansible into devel
11 years ago
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
11 years ago
Michael DeHaan
b41541c62a
Merge conflict.
11 years ago
Michael DeHaan
4a06954a13
Merge pull request #6390 from sergevanginderachter/group-varsdirs-svn
...
group_vars plugin: do not parse hidden files in subfolders
11 years ago
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>
11 years ago
Michael DeHaan
d5856bd475
Merge pull request #6391 from sergevanginderachter/hashmerge_inventoryscripts
...
Allow hash_behaviour=merge to be respected in core inventory
11 years ago
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.
11 years ago
Cristian Ciupitu
a7da5d8702
Micro-optimization of inventory.expand_hosts.detect_range
11 years ago
Serge van Ginderachter
6b1cb22fc3
Allow hash_behaviour=merge to be respected in core inventory
...
(For now, this means, enable it also for inventory scripts)
11 years ago
Serge van Ginderachter
29c60bdaff
group_vars plugin: do not parse hidden files in subfolders, e.g. avoid .svn/
11 years ago
James Cammarata
e3b887f770
Fix range issue in inventory and add additional error checking
...
Fixes #6331
11 years ago
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.
11 years ago
Michael DeHaan
94a7fb60fe
Allow escaped comments in inventory files.
11 years ago
Richard C Isaacson
b41d8106ff
Revert "Merge pull request #6287 from risaacson/fix_hash_in_var"
...
This reverts commit a808287451
, reversing
changes made to 6129ea7566
.
11 years ago
Richard C Isaacson
38abd5e20e
Break this out into a reusable function and document regex shortcomings.
11 years ago
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.
11 years ago
Jesse Keating
0c2c37a47a
Avoid range selection on empty groups
...
This prevents a traceback when the group is empty.
Fixes #6258
11 years ago
James Cammarata
f23ccebbdc
Merge branch 'issue_4620' of https://github.com/jimi-c/ansible into jimi-c-issue_4620
11 years ago
James Tanner
427b8dc78d
Ansible vault: a framework for encrypting any playbook or var file.
11 years ago
Ilya Kuznetsov
0658847ea6
Allow equal sign in single-line ini variables
11 years ago
James Cammarata
ca0ec800d8
Revising method for parsing ranges from --limit subsets
...
Also added a new test (test_subset_range) for future validation.
Fixes #4620
11 years ago
jctanner
a0f91f2aaa
Merge pull request #5576 from xyrix/symlink-bug-fix
...
fixed bug causing symlinks to fail in the host_vars, group_vars etc dire...
11 years ago
James Cammarata
f955d9db6a
Handle implicit localhost when using '-i host,' syntax
...
Fixes #5820
11 years ago
Rob Smith
761fe8cc04
Fix an issue where git-pull fails with AttributeError
...
As part of 94f3b9bfab
the code was changed to support dynamically adding localhost to the inventory. This change introduced an crash when run via ansible-pull
```
Starting ansible-pull at 2014-01-20 23:09:57
Traceback (most recent call last):
File "/tmp/ansible/bin/ansible", line 157, in <module>
(runner, results) = cli.run(options, args)
File "/tmp/ansible/bin/ansible", line 82, in run
hosts = inventory_manager.list_hosts(pattern)
File "/tmp/ansible/lib/ansible/inventory/__init__.py", line 372, in list_hosts
result = [ h.name for h in self.get_hosts(pattern) ]
File "/tmp/ansible/lib/ansible/inventory/__init__.py", line 136, in get_hosts
subset = self._get_hosts(self._subset)
File "/tmp/ansible/lib/ansible/inventory/__init__.py", line 177, in _get_hosts
that = self.__get_hosts(p)
File "/tmp/ansible/lib/ansible/inventory/__init__.py", line 198, in __get_hosts
hpat = self._hosts_in_unenumerated_pattern(name)
File "/tmp/ansible/lib/ansible/inventory/__init__.py", line 275, in _hosts_in_unenumerated_pattern
ungrouped.add_host(new_host)
AttributeError: 'NoneType' object has no attribute 'add_host'
```
The root cause is there is no group for the host to be added to. I fixed this case by creating the ungrouped group when it doesn't exist and then adding the host to the newly added group. This fixes the regression for me.
11 years ago
James Tanner
94f3b9bfab
Fixes #3129 Do not require localhost to be in inventory
11 years ago
James Tanner
559e89036b
Fixes #5631 Return a unique list of hosts when joining groups
11 years ago
jctanner
59d99c17b3
Merge pull request #5337 from bob-smith/bugfixFQDNParsing
...
Fix inventory parsing so that FQDN can be parsed without throwing ssh port error
11 years ago
jctanner
a6bc63512e
Merge pull request #5308 from zecrazytux/fix/hash_merge_dynamic_inventory
...
Let merge hash_bahaviour work with dynamic inventory
11 years ago
jay
e1f5b801cf
fixed bug causing symlinks to fail in the host_vars, group_vars etc directories
11 years ago
jctanner
21b4212ff5
Merge pull request #5517 from lichesser/fix_set_depreciation_warning
...
Fixes #5513 . set is built-in since 2.4 and deprecated since 2.6
11 years ago
James Tanner
ab51bd23a2
Fixes #5196 return a unique list of hostnames for a single host pattern
11 years ago
Michael DeHaan
227e8e31c9
Merge branch 'use_comps' of git://github.com/j2sol/ansible into devel
11 years ago
Michael DeHaan
10350d1639
Update various copyrights. Not complete, but sufficient.
11 years ago
Jesse Keating
23720ff19d
Use list comprehensions for efficiency
...
For loops can be inefficient, particularly when doing a dot command with
them. https://wiki.python.org/moin/PythonSpeed/PerformanceTips#Loops and
https://wiki.python.org/moin/PythonSpeed/PerformanceTips#Avoiding_dots ...
This patch makes use of list comprehensions to be as efficient as
possible while still retaining order. Efficiency was lost a bit when
switching away from sets() but this gains some of it back.
11 years ago
John Barker
4bf9f714d0
Fix inventory parsing so that FQDN can be parsed without throwing ssh
...
port parsing errors
Fixes problesm introduced by 948d019fef
Adds testcases to defend
11 years ago
Sébastien Bocahu
c8d5846ab9
Let merge hash_bahaviour work with dynamic inventory
11 years ago
Stoned Elipot
b00bf02129
Improve Group.get_hosts() performance.
...
- reduce hosts group list to unique elements faster
- add a cache of already computed hosts group list
11 years ago
jctanner
0f0a89b34e
Merge pull request #4758 from alanfairless/group-host-var-dirs
...
Support organizing group and host variables across multiple files in a directory
11 years ago
jctanner
9a7765daf7
Merge pull request #4351 from 2m/leading-range-fix
...
Allow leading ranges in the inventory host entries.
11 years ago
jctanner
0c29807ba3
Merge pull request #3993 from stoned/inventory-script-all-group-fix
...
Avoid duplicates of the 'all' group when using inventory script.
11 years ago
Alan Fairless
65e5331079
Allow organizing host/group vars in a directory
...
So instead of having:
group_vars/production.yml
A user could chose to reorganize to:
group_vars/production/staff.yml
group_vars/production/networks.yml
group_vars/production/dns.yml
(Backwards compatible.)
11 years ago
Alan Fairless
babde9a84c
refactor to catch edge cases, remove repeated code
...
- Move all the supported YAML file extensions into a constant
- Use helper functions to avoid duplicate code for group/host vars
- Catch and disallow some confusing situations, such as the presence of
multiple group/host vars files for the same group/host, but with
different extensions. For example having both group_vars/all.yml and
group_vars/all.yaml.
- Catch and report file system permission issues, symlink errors,
unexpected file system objects
- Trivial performance improvement from making fewer stat system calls
- Restructuring that makes it easy for a following patch to support
directory recursion
11 years ago
Michael DeHaan
b5c9d5a59b
Inventory directory should always be absolute. Fixes #4535 .
11 years ago
Michael DeHaan
c933a4c59a
Fix indentation depth.
11 years ago
Martynas Mickevicius
7ecb5fbc9c
Handle comment on inventory group line.
11 years ago
Martynas Mickevicius
44279ce34f
Allow leading ranges in the inventory host entries.
11 years ago
Michael DeHaan
1b2d4c328c
Cache patterns a bit higher up to make things a little more efficient. See #4469 .
11 years ago
Michael DeHaan
41aaad69aa
Make add_host clear the inventory pattern cache, add some more aliases. Fixes #4442 .
11 years ago
Serge van Ginderachter
c2e5f783da
Add caching to pattern enumeration
...
Inventory._hosts_in_unenumerated_pattern()
Was TODO: cache this logic so if called a second time the result is not
recalculated
11 years ago
James Cammarata
948d019fef
Detect IPv6 addresses in INI inventory
...
Prevents parts of the IPv6 address from being interpreted as a port
(for example, :80).
Fixes #3888
11 years ago
Michael DeHaan
8fc46a3a5a
Return inventory objects in the order they are presented. Additionally, fix host slicing such that it works on Python terms with
...
zero indexed lists and a non-inclusive final element.
11 years ago
James Cammarata
bff47df5ff
Fix issue with ast evaluation of strings
11 years ago
Brian Coca
771435deb4
now ini vars are typed
...
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
11 years ago
Jasper Capel
d4dec5f577
Allow creating empty inventory
...
Instantiating the Inventory class with host_list=None now results in an
empty inventory instead of an error.
11 years ago
Stoned Elipot
6cbd94dfae
Avoid duplicates of the 'all' group when using inventory script.
...
Do not recreate an 'all' group when it is in the inventory script's
output, but use the one created upfront.
11 years ago
James Cammarata
39628d012d
Minor fix to ipv6 detection for inventory with -i
...
For link-local addresses, it is sometimes necessary to append the
interface to use for the ipv6 address. This patch extends the ipv6
regex to allow for '%ifnameX' at the end.
See https://bugzilla.redhat.com/show_bug.cgi?id=136852 for more info
11 years ago
Michael Scherer
c9d28e10ad
add support for using a ipv6 in -i
...
testing with a ipv6 :
ansible -u misc -i '[2002::c23e]:22,' '*' -m ping
fail due to parsing of ':' as a separator of port/ip with ipv4.
This commit add support for properly parsing 2002::c23 and the
bracket notation [2002::ce]:2222
11 years ago
Matt Saunders
9fd1b174f5
Fixed tiny bug with _meta handling in external inventory scripts
11 years ago
ftao
51a180b150
fix inventory.basedir is not absolute path when hostfile is startswith "./"
11 years ago
Michael DeHaan
ee11d69697
Merge branch 'better_ini_errors2' of git://github.com/bcoca/ansible into devel
11 years ago
René Moser
e8272e365d
implemented 'inventory_file' variable. Closes GH-3789.
11 years ago
Serge van Ginderachter
40e60c947d
Host specifiers should be sorted
...
to ensure consistent behavior, hosts should look like this:
hosts: webservers:&boston:!rack42
So when applying the host selectors, run those without the "&" first,
then the &s, then the !s.
Closes #3500
11 years ago
Brian Coca
a937a6a66d
now bad ini entries will throw friendlier error
...
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
11 years ago
rishid
d18c90ed8f
Add support for INI comments that begin with '#' or ';'
...
Ini file format does not have a standard but ';' is used more often than '#' for comments
11 years ago
Michael DeHaan
8955ac1eda
If the result of a dynamic inventory script contains a "_meta" hash at top level
...
and the _meta hash contains a "hostvars", don't call --host hostname for any elements
and just serve them directly for performance enhancements with the external inventory
script and a large number of hosts.
11 years ago
Michael DeHaan
0335d05f43
Check against None around playbook basedir
12 years ago
Jonas Eriksson
16efb45735
Fix playbook-local host_vars when running from .
...
Since ansible 1.2, it became possible to place a host_vars
directory in the same directory as a playbook, making it possible
to keep host_vars local to that playbook there. However, due to
python's os.path.dirname, a action such as:
$ ansible-playbook pb.yml
..would not pick up the host_vars as os.path.dirname("pb.yml")
returns "", unlike the unix command dirname that would return
".". Substituting "pb.yml" on the command line with "./pb.yml"
would do the trick, but is not always intuitive. This patch
solves the problem until python solves issue18547 [1].
[1] http://bugs.python.org/issue18547
12 years ago
Michael DeHaan
3baa55a314
Merge branch 'devel' of git://github.com/sjmudd/ansible into sjmudd_ranges
12 years ago
martin f. krafft
fd02443d42
Enable negated patterns
...
A host pattern of the form '!foo' by itself does not work, but
'all:!foo' does. If the first pattern is a negation, this commit
automatically prepends 'all'.
Signed-off-by: martin f. krafft <madduck@madduck.net>
12 years ago
Rike-Benjamin Schuppner
71afb9e432
Use with guard for file reads.
12 years ago
Rike-Benjamin Schuppner
deaf499ba1
Remove duplicate host file reads by removing a legacy check.
...
This allows using a form such as
ansible -i <( arbitrary command ) all -m ping
12 years ago
Simon J Mudd
25822330a2
Add support for multiple ranges in a host
...
e.g. db[01:10:3]node-[01:10]
- to do this we split off at the first [...] set, getting the list
of hosts and then repeat until none left.
- also add an optional third parameter which contains the step. (Default: 1)
so range can be [01:10:2] -> 01 03 05 07 09
12 years ago
Chris Jacobs
588d4080df
don't want to ignore explicit cwd
12 years ago
Chris Jacobs
69db160e2f
Skip dotfile in hosts dirs
12 years ago
Serge van Ginderachter
f1cf81b086
optimization when adding child groups
12 years ago
Michael DeHaan
c52abd40b0
Fix for the directory inventory source where depth information on the group was being discarded
...
due to initial copy. New model will reuse the first object and copy attributes on the second.
12 years ago
Darryl Stoflet
c0baf10845
Support for all:vars in script inventories
12 years ago
Michael DeHaan
1f7c197a9d
os.path.dirname returns '' not None in some cases, handle this so inventory can be specified with ./
12 years ago
Michael DeHaan
6cd3ba5b06
Allow the group_vars and host_vars directories to be stored alongside the playbook as well as inventory.
12 years ago
Pol Llovet
4432c01ceb
Handle '#' in var strings by splitting on ' #'
...
If someone has a " #" in a quoted var string, it
will interpret that as a comment and refuse to
load the inventory file due to an unbalanced
quote. Noisy failure > unexpected behavior.
12 years ago
Pol Llovet
ba78360c52
Remove inline comments from inventory tokenizing.
12 years ago
Serge van Ginderachter
0c0d6c0b4e
performance optimization in inventory.groups_list()
...
don't calculate all hosts for every parent group of every group
when that parent group was already in the cache
12 years ago
Nicolas Grilly
7aee588918
Idiomatic Python: use in operator instead of method find
12 years ago
Nicolas Grilly
7babd30cf7
Idiomatic Python: use isinstance instead of type
12 years ago
Serge van Ginderachter
a6b827ca07
don't parse subdirs in host/group_vars
...
as those are not supported in
core vars_plugins/group_vars.py
but might be used by other vars_plugins
12 years ago
Michael DeHaan
50586928b2
No need for trailing semicolon.
12 years ago
Michael DeHaan
e4e6616169
Merge pull request #2872 from tima/fuzzy-match-localhost-127
...
Adds fuzzy matching of localhost to 127.0.0.1 host entries and vice versa
12 years ago
Timothy Appnel
20bf5f130d
Adds fuzzy matching of localhost to 127.0.0.1 host entries and vice versa.
12 years ago
Timothy Appnel
b15cc3e2b4
Fixed bug where a host entry in the inventory represented as a dict w/o a hosts or vars key was treated as a group and its vars essentially ignored.
12 years ago
Michael DeHaan
5a8dff5bce
Instantiate inventory plugins only once for efficiency reasons.
12 years ago
Michael DeHaan
87788b1d17
Ignore inventory config files when using an inventory directory.
12 years ago
Michael DeHaan
d8bf87b008
(A) include errors in inventory scripts should they occur.
...
(B) allow registration with ignore_errors: True
12 years ago
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
12 years ago
C. Morgan Hamill
863cb50530
Allow '.yml'/'.yaml' extension on group_vars files.
...
Look for a file with the base name of the group/host, first without
a file extension, then with a '.yml' extension, and, finally, with
a '.yaml' extension, loading vars from only the first one found.
12 years ago
Michael DeHaan
29209c4913
Style fixes so "make pep8" is clean.
12 years ago
Michael DeHaan
0d530f3bf0
Change the retry logic to write a limit file, able to source limit from files by indicating with @filename
12 years ago
Michael DeHaan
c695aa2d6a
When playbooks fail, attempt to create an inventory file in the inventory directory that allows rerunning
...
of the playbook against only the hosts that failed.
12 years ago
George Miroshnykov
6826aa7360
Tweaked merge_hash to also affect Runner behavior
12 years ago
Blair Zajac
36b3fc3acf
Fix for inventory scripts with no path prefix that are in CWD.
...
Without this, using '-i ec2.py' will not work if '.' is not in PATH.
12 years ago
Seth Vidal
2796b5ee2a
simple fix for issue 2564
...
when we encounter a group we've not seen before - we need
to make sure we make it a subgroup of 'all', no matter what
12 years ago
Stoned Elipot
86995d7786
Fix pathnames in comments
12 years ago
Rob Parrott
149f1f9f3c
invalidate group cache so that a group added by the add_host module will be relfected in the groups variable in later plays.
12 years ago
Daniel Hokka Zakrisson
1784fd80cc
When a host list is used, no parser is present
12 years ago
Daniel Hokka Zakrisson
2ff2f05a0f
host.get_variables includes too many variables, use host.vars instead
...
Not quite as attractive, but allows variable precedence and lazy
resolution to work as intended, rather than resolving them on a
per-inventory basis.
12 years ago
Daniel Hokka Zakrisson
f1eb195ff5
vars_loader should get the path to the inventory + vars_plugins
12 years ago
Daniel Hokka Zakrisson
ad08995989
Make inventory basedir for directory based inventory be the directory
...
This puts host_vars and group_vars inside of the directory, allowing you
to target a single inventory but still have access to the variables.
12 years ago
Daniel Hokka Zakrisson
d9c6b60b24
Allow inventory to be a directory containing other inventories
12 years ago
Daniel Hokka Zakrisson
647cd0141c
Move all inventory script code into the script parser
12 years ago
Nigel Metheringham
c0e28762f0
Allow end of line comments in inventory file
...
See github issue 2702
https://github.com/ansible/ansible/issues/2072
12 years ago
Michael DeHaan
0ad6ac4086
Fix group depth for nested groups
12 years ago
Michael DeHaan
a894791767
Slightly friendlier error on missing hosts file, slightly friendlier error on inventory script returning invalid syntax
...
(or if inventory is non-script and accidentally executable).
12 years ago
Brian Coca
ca5f52b825
now missing hosts file gives nice message and no traceback
...
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
12 years ago
Daniel Hokka Zakrisson
6f9099c51d
Merge pull request #1898 from silviud/fix_inventory_list_groups
...
Inventory class - lambda fails on attribute access - g.name is a string not the group obje...
12 years ago
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.
12 years ago
Silviu Dicu
f7694ac433
lambda fails on attribute access - g.name is a string not the group object
12 years ago
Daniel Hokka Zakrisson
c23eda82c2
Allow pattern[0] to address a single node
...
Replaces erroring out on it and requiring the abysmal pattern[0-0]
instead.
12 years ago
Michael DeHaan
04195e202d
Merge pull request #1747 from njharman/alpharange
...
Alphabetic inventory hostname patterns.
12 years ago
Michael DeHaan
4bcdd24688
Merge pull request #1776 from junegunn/inventory-group-var-ws
...
Allows whitespaces around assignment operators when defining group variables
12 years ago
Junegunn Choi
8896486606
Adds comments on handling quoted group vars
12 years ago
Junegunn Choi
7fbb7e079a
Fix hostname expansion bug in inventory parser
12 years ago
Junegunn Choi
daf797804b
Allows whitespaces around assignment operators
...
when defining group variables
12 years ago
Michael DeHaan
70bb7d1e54
Merge pull request #1696 from gregorg/enhance_limit
...
Allow regex to be used to select hosts in addition to fnmatch pattern
12 years ago
Daniel Hokka Zakrisson
54b45e9bd4
Allow intersecting host patterns by using &
...
This allows patterns such as webservers:!debian:&datacenter1 to target
hosts in the webservers group, that are not in the debian group, but are
in the datacenter1 group. It also parses patterns left to right.
12 years ago
Norman J. Harman Jr
6603737e4d
Alphabetic inventory hostname patterns.
...
- Code, docs, tests.
- Also added test of large range 000-142 to verify alpha range did not
break this.
12 years ago
Daniel Hokka Zakrisson
8d309e0fa3
Allow inventory scripts to define groups of groups and group vars
12 years ago
Gregory Duchatelet
dde01dabc3
Squashed commit of the following:
...
commit 48069adf0f
Author: Gregory Duchatelet <skygreg@gmail.com>
Date: Tue Nov 27 10:13:08 2012 +0100
Removing this plugin from this branch.
commit 15400fffe6
Author: Gregory Duchatelet <skygreg@gmail.com>
Date: Tue Nov 27 09:53:16 2012 +0100
Enhance _match function in inventory with regex.
--limit ~regex could be used to filter hosts or group with a regex.
Tested on cli and ansible-playbook.
commit 63c1b2e17e
Author: Gregory Duchatelet <skygreg@gmail.com>
Date: Tue Nov 27 09:03:41 2012 +0100
Revert pull request #1684
commit 7c2c6fee3a
Merge: f023a2f
dd5a847
Author: Gregory Duchatelet <skygreg@gmail.com>
Date: Tue Nov 27 08:52:53 2012 +0100
Merge remote branch 'upstream/devel' into devel
commit f023a2f3df
Author: Gregory Duchatelet <skygreg@gmail.com>
Date: Mon Nov 26 20:52:27 2012 +0100
Add an inventory plugin to fetch groups and host from our CMDB.
commit c64193b4c6
Author: Gregory Duchatelet <skygreg@gmail.com>
Date: Mon Nov 26 20:43:30 2012 +0100
Added possibility to filter hosts from a group, with a regex, separating
groupname and regex with a ~
Usage in group pattern: group~filterpattern
Samples:
ansible group~server-0[1236] -m ping
ansible web~proxy -m ping
ansible web~(proxy|frontend) -m ping
12 years ago
Daniel Hokka Zakrisson
0c70abfaa9
Make sure any existing groups gets reused
12 years ago
Daniel Hokka Zakrisson
5504f13c68
Create groups in the first run through the file
...
Fixes #1208 .
12 years ago
Daniel Hokka Zakrisson
2bfb7deec0
Set all in the returned dict
...
Otherwise the group is lost, and group_vars/all isn't used.
12 years ago
Daniel Hokka Zakrisson
715d875dcb
Group should only return its own variables
...
Otherwise, a host in two groups, A and B, using a variable defined
in group A and all will get the value of all, as B's variables will
include the all variable.
Partially fixes #1647 .
12 years ago
Daniel Hokka Zakrisson
bd7e02d629
Get all groups' variables in order of depth
...
Fixes all not being processed, as well as the order of the variable
precedence
12 years ago
Daniel Hokka Zakrisson
5dd2ec2cae
Add a way to add directories to just one type of loader
12 years ago
Daniel Hokka Zakrisson
17e4ce97a4
Create a set of all the hosts in a group to prevent duplicates
...
Fixes #1516 .
12 years ago
Dag Wieers
c9e62d7061
Fix for an exception when for whatever reason the inventory script fails
...
This avoids a traceback that gave no clue as to what was happening.
This is in line with the change from #1535
12 years ago
Dag Wieers
89206a6b68
Fix for an exception when for whatever reason the inventory script fails
...
This avoids a traceback that gave no clue as to what was happening.
12 years ago
Daniel Hokka Zakrisson
e05e514861
Create a plugin loader system
12 years ago
Michael DeHaan
c0747b7baa
pep8 fixes
12 years ago
Michael DeHaan
9a12873166
Merge pull request #1477 from skvidal/devel
...
add check that vars plugins are not handing back None
12 years ago
Seth Vidal
3fcc591f18
add check that vars plugins are not handing back None
12 years ago
Dag Wieers
3728b2f459
Missing errors-import causes traceback
12 years ago
Michael DeHaan
6ba30170dd
Make group_vars and host_vars available to usr/bin/ansible, and make vars_plugins exist
12 years ago
Seth Vidal
d63fa6f026
make --limit take a , as a separator as well as ; or :
12 years ago
Daniel Hokka Zakrisson
b8021f12e0
Raise error for missing hosts in inventory scripts as well
12 years ago
Michael DeHaan
a69e59ab2b
Allows delegate_to to use inventory host/port info.
12 years ago
Jeroen Hoekx
23a62f5a78
Return multiple groups from inventory API.
12 years ago
Peter Sankauskas
8a4e969b93
Getting negative host pattern matching to work with external inventory
...
(same as commit 4caf85e37b
, but for
excluded hosts as well as subsets)
12 years ago
Michael Lambert
29ac1a8efc
Replace os.access with stat calls for determining the executability of a given path.
12 years ago
Michael DeHaan
58ad934283
Merge pull request #1024 from tima/groups-pb
...
Made $groups and $group_names variables accessible in with_items
12 years ago
John Kleint
1f8696f5c1
Fix inventory.get_hosts when hosts is a list.
12 years ago
Timothy Appnel
20fc6a29d3
Made groups.groupname and group_names variables accessible in playbooks.
12 years ago
Michael DeHaan
f140332ff6
Make it possible in the inventory file to have spaces in host variables
12 years ago
Michael DeHaan
4caf85e37b
Fix --limit for external inventory scripts, slight variant on fix from pull #949
12 years ago
Michael DeHaan
898d7676f7
Adds the 'serial' keyword to a playbook which controls how many hosts can be running through a playbook at a single time.
...
The default is 0, which means all hosts. If set to 1, each host would run a playbook all the way through before moving
on the next host. Fact gathering is still parallel, regardless of the serial setting.
12 years ago
Michael DeHaan
6de8c27085
Load parent groups when processing group_vars
12 years ago
Michael DeHaan
9041adddaa
Add support for ranged patterns like webservers[0-49] for hitting the first 50 webservers.
12 years ago
Michael DeHaan
72faf8eb0a
fix indents
12 years ago
Michael DeHaan
d1ad1d2508
remove stray print
12 years ago