Commit Graph

37 Commits (e2d874c744698d97b603262a2f8a4d4d44c76782)

Author SHA1 Message Date
Dag Wieers 5553b20828 Collated PEP8 fixes (#25293)
- Make PEP8 compliant
2017-06-02 12:14:11 +01:00
Brian Coca 8f97aef1a3 Transition inventory into plugins (#23001)
* draft new inventory plugin arch, yaml sample

 - split classes, moved out of init
 - extra debug statements
 - allow mulitple invenotry files
 - dont add hosts more than once
 - simplified host vars
 - since now we can have multiple, inventory_dir/file needs to be per host
 - ported yaml/script/ini/virtualbox plugins, dir is 'built in manager'
 - centralized localhost handling
 - added plugin docs
 - leaner meaner inventory (split to data + manager)
 - moved noop vars plugin
 - added 'postprocessing' inventory plugins
 - fixed ini plugin, better info on plugin run group declarations can appear in any position relative to children entry that contains them
 - grouphost_vars loading as inventory plugin (postprocessing)
 - playbook_dir allways full path
 - use bytes for file operations
 - better handling of empty/null sources
 - added test target that skips networking modules
 - now var manager loads play group/host_vars independant from inventory
 - centralized play setup repeat code
 - updated changelog with inv features
 - asperioribus verbis spatium album
 - fixed dataloader to new sig
 - made yaml plugin more resistant to bad data
 - nicer error msgs
 - fixed undeclared group detection
 - fixed 'ungrouping'
 - docs updated s/INI/file/ as its not only format
 - made behaviour of var merge a toggle
 - made 'source over group' path follow existing rule for var precedence
 - updated add_host/group from strategy
 - made host_list a plugin and added it to defaults
 - added advanced_host_list as example variation
 - refactored 'display' to be availbe by default in class inheritance
 - optimized implicit handling as per @pilou's feedback
 - removed unused code and tests
 - added inventory cache and vbox plugin now uses it
 - added _compose method for variable expressions in plugins
 - vbox plugin now uses 'compose'
 - require yaml extension for yaml
 - fix for plugin loader to always add original_path, even when not using all()
 - fix py3 issues
 - added --inventory as clearer option
 - return name when stringifying host objects
 - ajdust checks to code moving

* reworked vars and vars precedence
 - vars plugins now load group/host_vars dirs
 - precedence for host vars is now configurable
 - vars_plugins been reworked
 - removed unused vars cache
 - removed _gathered_facts as we are not keeping info in host anymore
 - cleaned up tests
 - fixed ansible-pull to work with new inventory
 - removed version added notation to please rst check
 - inventory in config relative to config
 - ensures full paths on passed inventories

* implicit localhost connection local
2017-05-23 17:16:49 -04:00
Brian Coca 4319ddd5de allow users to control group var merge order (#22580)
* allow users to control group var merge order

With ansible_group_priority var at each group will determine merge order with siblings,
falling back to sorted names when priority is equal as it did before.

Parent/children relationships still work as they did and have higher precedence than priority

* move priority setting to groups, sourc indep

* now both inventory and play group follow priority

* removed double exception handling
2017-03-16 14:02:43 -04:00
Brian Coca 39ba55e5ac corrected host group ancestor management 2017-03-15 15:46:58 -04:00
Brian Coca c4cff44e77 fix 'ungrouped' issue with some inventory formats 2017-03-07 12:49:24 -05:00
James Cammarata 4cbe610263 Use a custom id generator over uuid4
>>> timeit.timeit("uuid.uuid4()", setup="import uuid")
9.518647909164429
>>> timeit.timeit("get_unique_id()", setup="from __main__ import get_unique_id")
0.40436601638793945

This will mainly be beneficial when a very large inventory is being
used, however it may also help with some very large playbooks.
2017-02-10 14:38:38 -06:00
James Cammarata a83b00bbc0 Properly sort groups by name as well as depth when getting vars
Fixes #17243
2016-11-18 22:57:52 -06:00
James Cammarata d2b3b2c03e Performance improvements 2016-08-08 15:58:46 -05:00
James Cammarata 879dc3a687 Mark implicitly hosts as such and exclude them from the all group
Fixes #16059
2016-06-04 18:53:47 -05:00
James Cammarata e546219426 Revert "Enable host_key checking at the strategy level"
This reverts commit 1a6d660d7e285cceec474952a33af4d8dffd0a8d.
2015-12-17 12:43:47 -05:00
James Cammarata e5c2c03dea Enable host_key checking at the strategy level
Implements a new method in the ssh connection plugin (fetch_and_store_key)
which is used to prefetch the key using ssh-keyscan.
2015-12-16 21:41:07 -05:00
James Cammarata 84507aedd4 Adding a uuid field so we can track host equality across serialization too 2015-12-04 13:33:27 -05:00
James Cammarata 750adbaa27 Changing up how host (in)equality is checked
Fixes #13397
2015-12-04 12:57:46 -05:00
James Cammarata ae9b34b1d9 Fix for equality checking in Host to make sure things are like types 2015-09-25 16:49:31 -04:00
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.
2015-09-24 12:46:06 +03:00
Marius Gedminas a2bc6b4b26 Bugfix: if you define __eq__, you should define __ne__ too 2015-09-24 12:43:33 +03:00
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.
2015-09-17 23:03:48 +05:30
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 f16b745f17 now properly uses default port if defined 2015-07-31 12:01:58 -04:00
James Cammarata 49a6601856 Further cleanup of internal use of ansible_ssh_host 2015-07-27 10:42:39 -04:00
Dann Bohn 3e79bfa2d6 only set ansible_ssh_host if not already set 2015-07-20 15:43:55 -04:00
Gerard Lynch d23ab261e1 fixes 11607, allows ansible_ssh_port to be overridden from group or host_vars 2015-07-16 23:00:17 +01: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
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 ce3ef7f4c1 Making the switch to v2 2015-05-03 21:47:26 -05: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 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
Michael DeHaan 10350d1639 Update various copyrights. Not complete, but sufficient. 2014-01-04 13:32:04 -05:00
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
2012-11-23 00:20:52 +01:00
Michael DeHaan 6ba30170dd Make group_vars and host_vars available to usr/bin/ansible, and make vars_plugins exist 2012-10-26 19:55:59 -04:00
Dave Peticolas 08272dc25d Remove unused imports. 2012-08-09 21:35:22 -07:00
Michael DeHaan faed4b5a33 whitespace + remove deprecated YAML parser (migration script lives in examples/scripts and warning was added
in 0.6 release)
2012-08-06 20:07:02 -04:00
Derek Carter 547395a2be added inventory_hostname_short varible 2012-07-30 13:26:48 -04:00
Michael DeHaan 57f12ac9e3 Using __slots__ in more places, in particular, hosts and groups, where we are apt to create a fair amount of objects. 2012-07-22 11:40:02 -04:00
Michael DeHaan 1754de3335 Misc code cleanup, mostly whitespace preferences, removing unused imports, plus a few fixes here and there. 2012-07-15 12:29:53 -04:00
Michael DeHaan 68a9adc1be Indentation cleanup (partial) 2012-07-15 09:32:47 -04:00
Michael DeHaan cf9ddf3a30 Reorganizing file structure. Not done. 2012-05-25 19:34:13 -04:00