Commit Graph

36 Commits (7722b95dd4e340f5ac607c2047d5ca4de3ce86d0)

Author SHA1 Message Date
Matt Martz 3164e8b561 E501 fixes (#22879) 2017-03-22 20:50:28 -05:00
Robin Roth 3922328954 Allow unicode inventory filename
Fixes #17932
2016-10-15 16:54:51 -07:00
Toshio Kuratomi 23305540b4 Make ini parsing slightly more robust
Prior to this commit, the ini parser would fail if the inventory was
not 100% utf-8.  This commit makes this slightly more robust by
omitting full line comments from that requirement.

Fixes #17593
2016-10-04 11:24:50 -07:00
Brian Coca 74b7590211 better inventory error messages 2016-10-04 07:23:26 -07:00
Adrian Likins 2c54a8471f Improve inventory script error messages. (#17589)
When an inventory file looks executable (with a #!) but
isn't, the error message could be confusing. Especially
if the inventory file was named something like 'inventory'
or 'hosts'. Add some context and quote the filename.

This is based on https://github.com/ansible/ansible/pull/15758
2016-09-15 15:42:57 -04:00
Brian Coca 52a0165c77 skip non executable inventory when no shebang (#15969)
alternate fix #15934
2016-05-24 10:25:10 -04:00
Brian Coca 4561be00af simplified inventory error messaging 2016-05-10 17:16:26 -04:00
Brian Coca 1942cd33dc draft add group merge priority and yaml inventory
* now you can specify a yaml invenotry file

* ansible_group_priority will now set this property on groups

* added example yaml inventory

* TODO: make group var merging depend on priority

  groups, child/parent relationships should remain unchanged.
2016-04-07 16:22:36 -04:00
Toshio Kuratomi 17e8500202 Don't process the same host multiple times
Fixes #14259
2016-03-24 16:43:43 -07:00
James Cammarata 750adbaa27 Changing up how host (in)equality is checked
Fixes #13397
2015-12-04 12:57:46 -05:00
James Cammarata f467f1770f Properly compare object references for Hosts when adding new ones
Fixes #13397
2015-12-03 15:25:54 -05:00
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')
2015-09-29 18:16:05 +02:00
Brian Coca ee840f3029 fixed function signature 2015-09-17 07:47:51 -04:00
Victor Salgado 54f1560d3e Fix mutable default argument 2015-09-16 16:49:45 -03:00
James Cammarata c8f2483d6d Cleaning up default group creation in inventory parsers 2015-09-16 12:54:54 -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
Brian Coca 49d88cef9c meta: refresh_inventory and several inventory fixes 2015-08-12 10:35:12 -04:00
James Cammarata ce3ef7f4c1 Making the switch to v2 2015-05-03 21:47:26 -05:00
Serge van Ginderachter 7c96f1d803 InventoryDir: fixing yet another corner case 2014-08-08 08:54:11 +02: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
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
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 cc8efb4aab inventory groups: make sure group.depth is updated on all grandchildren 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
Chris Jacobs 588d4080df don't want to ignore explicit cwd 2013-06-04 21:06:49 -07:00
Chris Jacobs 69db160e2f Skip dotfile in hosts dirs 2013-06-04 18:16:09 -07:00
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.
2013-06-03 11:41:56 -04:00
Michael DeHaan 87788b1d17 Ignore inventory config files when using an inventory directory. 2013-04-20 09:10:19 -04:00
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.
2013-04-07 23:37:10 -04:00
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.
2013-03-02 10:26:26 +01:00
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.
2013-03-01 23:22:52 +01:00
Daniel Hokka Zakrisson d9c6b60b24 Allow inventory to be a directory containing other inventories 2013-03-01 23:22:52 +01:00