Commit Graph

1119 Commits (97cc0cce7f53b704f8541530e42d5e515584cd95)

Author SHA1 Message Date
Brian Coca 01b75f966b fix include_role dynamic path
fixes #17966
8 years ago
Brian Coca 38d0f77a0f include_role now allows duplicates by default
setting is overridable by user
8 years ago
Aaron Bieber 3fc1b4da53 Remove -b option from pbrun.
The -b option reads as follows:
` The target job is directed to ignore hangup signals. This is particularly
useful for running the target program in the background.`

If needed, '-b' can be added to become_flags

Squashed commit of the following:

commit f2c9f5c011ae8be610301d597a34bfba1a391e08
Author: Aaron Bieber <aaron@bolddaemon.com>
Date:   Mon Oct 17 10:58:14 2016 -0600

    remove pbrun flags

commit f402679ac177c931ad64bd13306f62512a14fcd6
Author: Aaron Bieber <aaron@bolddaemon.com>
Date:   Fri Oct 14 15:29:29 2016 -0600

    use Password: vs assword: for matching pbrun prompt

commit cd2e90cb65854c4cc5dd8773404e520d40f82765
Author: Aaron Bieber <aaron@bolddaemon.com>
Date:   Fri Oct 14 15:28:58 2016 -0600

    move -b to pbrun_flags
8 years ago
Toshio Kuratomi f24c10c32b Fixes to handle non-ascii become passwords
Fixes for non-ascii passwords on
* both python2 and python3,
* local and paramiko_ssh (ssh tested working with these changes)
* sudo and su

Fixes #16557
8 years ago
Brian Coca ff1e52184f Better error for bad role def 8 years ago
Toshio Kuratomi 1efe782b46 Refactor parsing of CLI args so that we can modify them in the base class
Implement tag and skip_tag handling in the CLI() class.  Change tag and
skip_tag command line options to be accepted multiple times on the CLI
and add them together rather than overwrite.

* Make it configurable whether to merge or overwrite multiple --tags arguments
* Make the base CLI class an abstractbaseclass so we can implement
  functionality in parse() but still make subclasses implement it.
* Deprecate the overwrite feature of --tags with a message that the
  default will change in 2.4 and go away in 2.5.

* Add documentation for merge_multiple_cli_flags
* Fix galaxy search so its tags argument does not conflict with generic tags
* Unit tests and more integration tests for tags
8 years ago
Strahinja Kustudic 9962245b92 Moves 'statically included' messages to -vv verbosity (#17918) 8 years ago
James Cammarata 0a86ddc251 Move searching for roles in the cur basedir to last
Searching the DEFAULT_ROLES_PATH and the roles basedir should come
before this, and it has been a long standing oversight.

Fixes #17882
8 years ago
Brian Coca 54ce6a9b7a fix for include_role conflating vars/directives 8 years ago
Brian Coca d4b2ea3ec8 include_role process name from options, not task 8 years ago
Brian Coca dfff608ceb dzdo prompt fix
fixed tests
dzdo has 2 paths now, with and w/o password
fixes #17838
8 years ago
James Cammarata e4ee9de3f4 Fixing parentage of include_role objects for param inheritance
Fixes #17686
8 years ago
Chris Houseknecht 8300e67cbe Use new YAML syntax in role dependencies. 8 years ago
Brian Coca 3c42651fc7 fixed typo 8 years ago
Gilles Gagniard da5b0c39c9 fixes #16865 : we should properly determine connection type for delegated task first, before overriding remote user for local connections (#17723) 8 years ago
Brian Coca 3550f73837 removed deprecated first available file from tasks (#17643)
https://docs.ansible.com/ansible/porting_guide_2.0.html#deprecated
8 years ago
Brian Coca 1b0b6b4c10 removed deprecated 'bare' templating environment (#17640)
https://docs.ansible.com/ansible/porting_guide_2.0.html#deprecated
8 years ago
Brian Coca 52bf021904 clarified `omit` intended usage
fixes #13986
8 years ago
Toshio Kuratomi 8aa8e07d13 Remove _load_hosts() from Play initialization as it's no longer needed and it breaks using extra_vars defining a list for hosts (#17699)
Thanks to @jimi-c for the solution

Fixes #16583
8 years ago
James Cammarata 1b54d3b6dc Merge branch 'threaded_receiver' into devel 8 years ago
James Cammarata 5a57c66e3c Moving result reading to a background thread 8 years ago
Toshio Kuratomi 2989527cd9 Fix dataloader using deprecated version of is_encrypted (#17615) 8 years ago
Brian Coca 60706cc12e doas update (#16997)
hopefully fixes #15597
8 years ago
Andrea Tartaglia ba28f1a2da Make ssh_executable available as ansible_ssh_* variable (#17450) 8 years ago
Toshio Kuratomi 4ed88512e4 Move uses of to_bytes, to_text, to_native to use the module_utils version (#17423)
We couldn't copy to_unicode, to_bytes, to_str into module_utils because
of licensing.  So once created it we had two sets of functions that did
the same things but had different implementations.  To remedy that, this
change removes the ansible.utils.unicode versions of those functions.
8 years ago
Brian Coca ff34f5548d Dynamic role include (#17401)
* dynamic role_include

* more fixes for dynamic include roles

* set play yfrom iterator when dynamic

* changes from jimi-c

* avoid modules that break ad hoc

TODO: should really be a config
8 years ago
Brian Coca 4457985062 added ability to use pure boolean in conditionals 8 years ago
Will Thames d54f5277d5 Add ksu privilege escalation (#17340)
Allow ksu privilege escalation to be used
as a standard become_method

https://web.mit.edu/kerberos/krb5-1.12/doc/user/user_commands/ksu.html
8 years ago
Brian Coca f39799fbcd implemented loop pausing (#17289)
* implemented loop pausing

- added loop pause to changelog
- only pause between iterations, avoid 1st/last
- added example to docs

* fixed note placement

* else

* added docs for loop_control: label
8 years ago
James Cammarata 9ecec6c28e Don't do parent stuff during serialize if squashed or finalized 8 years ago
James Cammarata cddf1cf98e Some further cleanup in the meta branch
* adds squashing to objects, which allows them to be squashed down
  to a final "view" before post_validate to avoid expensive evaluations
  of parent attributes
8 years ago
James Cammarata 96e2be9bf8 Selectively assign the getter for better performance
Introduces the `inherit` param for FieldAttributes, which is now used
in BaseMeta when constructing the getter property to enhance performance
by reducing the amount of work the getter generally has to do.
8 years ago
James Cammarata 3a51587220 Meta meta meta 8 years ago
Andrew Gaffney f65a3ce547 Support for specifying item label in a loop (#17294) 8 years ago
Michael Scherer e3f54cb798 Add support for become_flags on the task level (#17310)
Working on the test suite, I tried to replace a call to sudo to a
call to su, and found out that I can't change user to 'nobody'
without changing the option become_flags in ansible.cfg

As this would be dependent on the user and the task, it make more sense
to push the setting there.
8 years ago
Brian Coca 4e6a7a9e01 allow include_role to specify vars/defaults files 8 years ago
Brian Coca bd9094c925 include_role (role revamp implementation) (#17232)
* attempt #11 to role_include

* fixes from jimi-c

* do not override load_data, move all to load

* removed debugging

* implemented tasks_from parameter, must break cache

* fixed issue with cache and tasks_from

* make resolution of from_tasks prioritize literal

* avoid role dependency dedupe when include_role

* fixed role deps and handlers are now loaded

* simplified code, enabled k=v parsing

used example from jimi-c

* load role defaults for task when include_role

* fixed issue with from_Tasks overriding all subdirs

* corrected priority order of main candidates

* made tasks_from a more generic interface to roles

* fix block inheritance and handler order

* allow vars: clause into included role

* pull vars already processed vs from raw data

* fix from jimi-c blocks i broke

* added back append for dynamic includes

* only allow for basename in from parameter

* fix for docs when no default

* fixed notes

* added include_role to changelog
8 years ago
Michael Scherer a942758a07 Fix wrong error class (#17259)
AnsibleError is not imported in that file, and since that's
a parsing time issue, better raise AnsibleParserError like the
rest of the file.

Issue signaled on irc by gordon`
8 years ago
Toshio Kuratomi 44d979c8f5 Enable most unittests on python3 (just some vault unittests and a logging one left) (#17240)
Make some python3 fixes to make the unittests pass:

* galaxy imports
* dictionary iteration in role requirements
* swap_stdout helper for unittests
* Normalize to text string in a facts.py function
8 years ago
Toshio Kuratomi a22909c226 Migrate basestring to a python3 compatible type (#17199) 8 years ago
James Cammarata f4237b2151 Rework the way params are assigned to TaskIncludes when they're dynamic
Copying the TaskInclude task (which is the parent) before loading the blocks
makes the code much more simple and clean, and fixes a bug introduced during
the performance improvement changes (and specifically the change which moved
things to a single-parent model).

Fixes #17064
8 years ago
James Cammarata daf6eb97d3 Make sure includes for handlers in roles look in the correct subdir 8 years ago
James Cammarata 1c7e0c73c9 Several fixes for includes
* when including statically, make sure that all parents were also included
  statically (issue #16990)
* properly resolve nested static include paths
* print a message when a file is statically included

Fixes #16990
8 years ago
James Cammarata 57fca2dde2 Validate new blocks during copy
It is possible that a block is copied prior to validation, in which case
some fields (like when) which should be something other than a string might
not be. Using validate() in copy() is relatively harmless and ensures the
blocks are in the proper structure.

This also cleans up some of the finalized logic from an earlier commit and
adds similar logic for validated.

Fixes #17018
8 years ago
James Cammarata 7503875ed7 Mark playbook objects as finalized after post_validate
After post_validate() is called on an object, there should be no
need to continue looking up at parent attributes. This patch adds a
new flag (_finalized) which is set to True at the end of post_validate,
and getattr will not look beyond its own attributes from that point on.
8 years ago
James Cammarata 06d4f4ad0e Move tasks/blocks to a single parent model 8 years ago
James Cammarata d2b3b2c03e Performance improvements 8 years ago
James Cammarata 159aa26b36 FEATURE: adding variable serial batches
This feature changes the scalar value of `serial:` to a list, which
allows users to specify a list of values, so batches can be ramped
up (commonly called "canary" setups):

- hosts: all
  serial: [1, 5, 10, "100%"]
  tasks:
  ...
8 years ago
Robin Roth 2b28beb1d7 add check_mode option for tasks (#16056)
* add check_mode option for tasks

includes example testcases for the template module

* extend check_mode option

* replace always_run, see also proposal rename_always_run
* rename always_run where used and add deprecation warning
* add some documentation

* have check_mode overwrite always_run

* use unique template name to prevent conflicts

test_check_mode was right before, but failed due to using the same filename as other roles

* still mention always_run in the docs

* set deprecation of always_run to version 2.4

* fix rst style

* expand documentation on per-task check mode
8 years ago
Brian Coca 3c39bb5633 fixed lookup search path (#16630)
* fixed lookup search path

added ansible_search_path var that contains the proper list and in order
removed roledir var which was only used by first_found, rest used role_path
added needle function for lookups that mirrors the action plugin one, now
both types of plugins use same pathing.

* added missing os import

* renamed as per feedback

* fixed missing rename in first_found

* also fixed first_found

* fixed import to match new error class

* fixed getattr ref
8 years ago
jctanner fe8258a378 make timeout decorator for facts have a configurable duration (#16551)
* Add a gather_timeout parameter
* update example ansible.cfg
* fix play level fact gathering too
8 years ago
Matt Davis 30c63a41e9 Merge pull request #16555 from matsu-chara/fix-error-msg-default-to-defaults
fix default/main.yml to defaults/main.yml
8 years ago
James Cammarata 9248cde239 Force remote_user to be the currently user for connection=local
Fixes ansible-modules-core#4092
8 years ago
James Cammarata 930d090507 Fix the way handlers are compiled and found/notified
* Instead of rebuilding the handler list all over the place, we now
  compile the handlers at the point the play is post-validated so that
  the view of the play in the PlayIterator contains the definitive list
* Assign the dep_chain to the handlers as they're compiling, just as we
  do for regular tasks
* Clean up the logic used to find a given handler, which is greatly
  simplified by the above changes

Fixes #15418
8 years ago
James Cammarata 06379bb288 Prevent loop_control from being inherited via parent includes
Fixes #16542
8 years ago
matsu-chara 9f8b0cabcd fix default/main.yml to defaults/main.yml 8 years ago
Brian Coca 7c690f04e2 task get_path returns empty string when not in play 8 years ago
James Cammarata af249b83e6 Don't modify the original task ds when preprocessing data
In the case of using YAML anchors/aliases, YAML actually uses references
to the duplicated object so any modifications to the original impacts
later uses of the object.

Fixes #13575
8 years ago
James Cammarata 04fca42b62 Fixing issues with getattr caused by 5a3493b 8 years ago
James Cammarata 3e4755f7e4 Remove unnecessary role initialization and lookup stuff
* Remove unnecessary copying of values from parents to role deps, as
  this can cause problems when roles have multiple parents (or the same
  parents with different params speficied through deps)
* Since we're already checking the dep chain in the block for role
  things (which every task in a role should have), it is not necessary
  to check the role directly in case it improperly grabs something

Fixes #14438
8 years ago
nitzmahone ac04ffb9b1 apply @zazard's fix to parent attribute lookup 8 years ago
James Cammarata c24c0f5f6b Properly wrap objects using json default encoder
Our custom encoder for the to_json filter was simply returning the
object if it was not a HostVars object, leading in some cases to a
TypeError when the data contained an undefined variable. This lead
to an odd error message being propagated up, so we now properly catch
this as an undefined variable error.

Fixes #15610
8 years ago
James Cammarata ca6ee4c789 FEATURE: handler listeners
Fixes ansible/proposals#8
8 years ago
James Cammarata 8218591fec Track notified handlers by object rather than simply their name
Due to the fact that roles may be instantiated with different sets of
params (multiple inclusions of the same role or via role dependencies),
simply tracking notified handlers by name does not work. This patch
changes the way we track handler notifications by using the handler
object itself instead of just the name, allowing for multiple internal
instances. Normally this would be bad, but we also modify the way we
search for handlers by first looking at the notifying tasks dependency
chain (ensuring that roles find their own handlers first) and then at
the main list of handlers, using the first match it finds.

This patch also modifies the way we setup the internal list of handlers,
which should allow us to correctly identify if a notified handler exists
more easily.

Fixes #15084
8 years ago
Brian Coca 4acac55d23 add executable if none exists when become
this is needed as become adds commands that require shell
8 years ago
Brian Coca a529a60478 raw should not use default executable (#16085)
also removed unused cruft in script
8 years ago
jctanner 02e52c319c Force an include to be a static task if no vars or loops are being used. (#16192)
Fixes #15735
8 years ago
James Cammarata f9803bfcc9 Revert "don't tempalte register"
This reverts commit 7ba790bbaf.

Fixes #15700
8 years ago
James Cammarata 068e447fda Further tweaks to variable precedence to make it match our docs
Also removes looking at role variables from the Block, as those are
merged in separately via VariableManager
8 years ago
Ritesh Khadgaray ef9238ab85 set remote_user to default if none is found when using delegate_to (#16138) 8 years ago
James Cammarata e36b4014f5 Merge pull request #15958 from Schnitzel/taskinclude_handler
new HandlerTaskInclude Class which can run TaskIncludes inside Handlers
8 years ago
Toshio Kuratomi 5a3493be5f Port urls.py to python3 and other byte vs text fixes (#16124)
* Port urls.py to python3

Fixes (largely normalizing byte vs text strings) for python3

* Rework what we do with attributes that aren't set already.

* Comments
8 years ago
James Cammarata 733d017ad0 Save and restore the loader's basedir when loading playbooks
Fixes #15930
8 years ago
James Cammarata 72b29d122e When adding nested blocks, don't pass in any parent includes
We previously changed block behavior to prefer includes over parent
blocks, which broke inheritence in nested blocks.

Fixes #15926
8 years ago
Michael Schmid 566690a44a Fixes #15915: New HandlerTaskInclude Class which can run TaskIncludes inside Handlers 8 years ago
James Cammarata 4f0be29d65 Reworking retry/until logic to fix bugs
Prior to this patch, the retry/until logic would fail any task that
succeeded if it took all of the alloted retries to succeed. This patch
reworks the retry/until logic to make things more simple and clear.

Fixes #15697
8 years ago
James Cammarata ae09648068 Merge pull request #15812 from cThrice/patch-3
Fixes #15745 playbook include: Conditional scoping
8 years ago
Carl fefd87c61a Fixes #15745 playbook include: Conditional scoping
Fixes #15745
Applies conditional forwarding to all tasks/roles within the included playbook.
The existing line only applies forwarded conditionals to the main Task block, and misses pre_, post_, and roles.

Typo ::

Made a selection mistake when I copied over the one line change
9 years ago
James Cammarata 33de7707c9 Do not include params when getting role vars in certain situations
In VariableManager, we fetch the params specifically in the next step,
so including them in the prior step is unnecessary and could lead to things
being overridden in an improper order.

In Block, we should not be getting the params for the role as they are
included earlier via the VariableManager.

Fixes #14411
9 years ago
Martin Matuska 5ee38617b9 Treat "static: yes/no" with higher priority than "task_includes_static" in ansible.cfg 9 years ago
Martin Matuska 438ed70a43 Restore Ansible 2.0 compatibility for includes 9 years ago
René Moser 4e0013d161 playbook, include: fix Unexpected Exception: 'NoneType' object has no attribute 'strip' (#15574)
If `include:` statement is used without argument, we get a traceback.
9 years ago
Tegan Snyder bf0da4aa3c add centrify dzdo escalation (#15219)
add dzdo context, and test
9 years ago
Toshio Kuratomi 09605ce806 Fix facts for the FieldAttribute list change in 30a38f9 9 years ago
James Cammarata 30a38f94ce Create a special class of list FieldAttribute for splitting on commas
Which we're use on a case-by-case basis if we find people were actually
using comma-separated strings for list values outside of hosts. Support
for doing so is now deprecated and users should instead use the full
YAML syntax for lists of values.

Fixes #15291
9 years ago
James Cammarata 6eefc11c39 Make the loop variable (item by default) settable per task
Required for include+with* tasks which may include files that also
have tasks containing a with* loop.

Fixes #12736
9 years ago
James Cammarata 8ef564176b Handle includes which may have been created in the flow of the playbook
Since 2.0 made all includes dynamic, it is now possible to create and
include a file in the course of executing a playbook. However, with the
introduction of implicit static includes this can cause problems if an
include is thought to be static but does not yet exist. For now, we're
handling missing implicit static includes as a potential dynamic include
but also adding a deprecation message to show includes like this will
need to be marked as `static: no` in the future.

Fixes #15342
9 years ago
Toshio Kuratomi 4b0aa1214c Ziploader
* Ziploader proof of concept (jimi-c)

* Cleanups to proof of concept ziploader branch:

* python3 compatible base64 encoding
* zipfile compression (still need to enable toggling this off for
  systems without zlib support in python)
* Allow non-wildcard imports (still need to make this recusrsive so that
  we can have module_utils code that imports other module_utils code.)
* Better tracebacks: module filename is kept and module_utils directory
  is kept so that tracebacks show the real filenames that the errors
  appear in.

* Make sure we import modules that are used into the module_utils files that they are used in.

* Set ansible version in a more pythonic way for ziploader than we were doing in module replacer

* Make it possible to set the module compression as an inventory var

This may be necessary on systems where python has been compiled without
zlib compression.

* Refactoring of module_common code:

* module replacer only replaces values that make sense for that type of
  file (example: don't attempt to replace python imports if we're in
  a powershell module).
* Implement configurable shebang support for ziploader wrapper
* Implement client-side constants (for SELINUX_SPECIAL_FS and SYSLOG)
  via environment variable.
* Remove strip_comments param as we're never going to use it (ruins line
  numbering)

* Don't repeat ourselves about detecting REPLACER

* Add an easy way to debug

* Port test-module to the ziploader-aware modify_module()

* strip comments and blank lines from the wrapper so we send less over the wire.

* Comments cleanup

* Remember to output write the module line itself in powershell modules

* for line in lines strips the newlines so we have to add them back in
9 years ago
Brian Coca 92d154f4ef centralize path list handling
move it to constants and avoid duplicating code or misinforming
developers on the nature of the data
9 years ago
James Cammarata 2be1726350 Don't remove _raw_params from static include args 9 years ago
Thomas Steinbach 870160b8ed fixed some breaks after merging ansible/devel 9 years ago
Thomas Steinbach cd2c140f69 forwarded docker_extra_args to latest upstream/origin/devel 9 years ago
James Cammarata 2c20579a06 Add options to make includes 'static'
* Can be configured in the ansible.cfg for tasks/handlers individually
* If an included filename contains no vars or loops, it will be expanded
  in-place as if it were marked as static
9 years ago
James Cammarata f427955640 Make default var lookup for tasks follow the dep chain
Related to #14296 (@jjshoe's follow-up example on that issue)
9 years ago
Toshio Kuratomi ed9e164b80 Fix ansible_sudo_pass inventory variable so that it overrides setting of sudo password from the command line 9 years ago
James Cammarata 9d2fe2fb2c Fixing role param precedence issues
* Make role param resolution follow the role dependency chain, rather
  than using all roles within the play
* Also move params to be merged in after role vars in general, to match
  our variable precedence rules
* Changes to the way var lookup is done in role helper methods for
  get_vars(), get_inherited_vars(), and get_role_params() to make the
  above possible without trampling on previously merged vars

Fixes #14472
Fixes #14475
9 years ago
Toshio Kuratomi e25caebe7a Cleanups to docs and rename of inv var 9 years ago
Brian Coca db61e9be0c add ansible_executable inventory var
also handle the overrides appropriately
also new executable to set shell type
9 years ago
Brian Coca 292be944c6 ensure we use delegated vars on delegation
this prevents falling back to connection vars from the inventory_hostname
when matching connection var is not in delegated host.
9 years ago
Toshio Kuratomi 512825455e Make ohai and facter work via module_utils Fact classes rather than in the setup module 9 years ago
Toshio Kuratomi 5a1e35224b Make changes proposed during review of restrict fact gathering feature:
* Make documentation examples into code blocks
* Make code to call the subsets more general.
* Made min subset always execute (cannot disable it).
* Use a passed in modules parameter rather than global modules.  This is needed for ziploader
* Remove unneeded __init__()
* Remove uneeded multiple inheritance from a base class
* gather_facts is now a list type
9 years ago
Toshio Kuratomi d665911bab Allow FieldAttribute lists and sets to be set from a comma separated string 9 years ago
Yannig Perré 88772b6003 Add a way to restrict gathered facts in Ansible:
- Using gather_subset options
- By ignoring ohai/chef or facter/puppet facts
9 years ago
James Cammarata ccf646665b Revert "Removing explicit setting of failed/failed_when"
This reverts commit 4e528e9535.
9 years ago
James Cammarata 4e528e9535 Removing explicit setting of failed/failed_when 9 years ago
Brian Coca df1268ed69 Merge pull request #14892 from dagwieers/patch-14
Another misspelling
9 years ago
Dag Wieers a5e11b1325 Another misspelling
...while reading the source
9 years ago
Dag Wieers d7d04ad2cd Fix misspelling and some cosmetic change 9 years ago
Brian Coca 7067bb32b8 make all conditionals lists
this brings them to equivalence with when:
fixes #13905
9 years ago
James Cammarata 299d93f6e9 Updating unit tests for PlayIterator
This knowingly introduces a broken test, planning to fix that later.
9 years ago
John Barker 8b4ebd8e4a Make it easier to read error message 9 years ago
Brian Coca e762095497 better task parsing errors
fixes #14790
9 years ago
Brian Coca 7ba790bbaf don't tempalte register 9 years ago
夏恺(Xia Kai) d033c40e80 Make task repr really work for meta tasks.
Signed-off-by: 夏恺(Xia Kai) <xiaket@xiaket@gmail.com>
9 years ago
Brian Coca e2d2798a42 hosts can be list or string 9 years ago
Brian Coca 2d56293768 default play name to hosts entry
return to previous behaviour as now the name was left blank
9 years ago
James Cammarata da02aba173 Don't inject PlayContext properties as variables if they're None
Fixes bug introduced in 078ebb0
9 years ago
James Cammarata 078ebb0dec Don't re-inject become* variables as it causes problems when templating is involved
Prior to 75b6f61, we strictly limited variables we re-injected. After that
patch however, we re-injected everything which causes problems under certain
circumstances. For now, we'll continue to filter out some properties of
PlayContext for re-injection.

Fixes #14352
9 years ago
Brian Coca 3b3709e715 Merge pull request #14488 from bcoca/become_shell_fixes
shell + become fixes
9 years ago
James Cammarata 58a6cf822a Merge pull request #13203 from willthames/galaxy_10620
Allow tree-ish versions for ansible-galaxy
9 years ago
Brian Coca 6dc910c13a shell + become fixes
1 less level of shell + quoting
simplified become commands, less quote and shell
9 years ago
Brian Coca 0bb49090cf make some options not mandatory to pass
this should simplify api calls
9 years ago
James Cammarata 06b072c1f7 Fix bugs related to task_includes and dep chain inheritance
* Fix the way task_include fields were created and copied
* Have blocks get_dep_chain() look at task_include's blocks for proper
  dep chain inheritance
* Fix the way task_include fields are copied to prevent a recursive
  degradation

Fixes #14460
9 years ago
James Cammarata 275728e0f6 Fixing bugs related to nested blocks inside roles
* Make sure dep chains are checked recursively for nested blocks
* Fixing iterator is_failed() check to make sure we're not in a
  rescue block before returning True
* Use is_failed() to test whether a host should be added to the TQM
  failed_hosts list
* Use is_failed() when compiling the list of hosts left to iterate
  over in both the linear and free strategies

Fixes #14222
9 years ago
James Cammarata 75b6f61619 Fix the way we re-add variables from PlayContext to the variable dict
* If the internal value is None, do not add the variable
* Make sure all aliases for a given variable name are set (if they're
  not already set in the dictionary)

Fixes #14310
9 years ago
Brian Coca 28cf4bc00b fix incorrect environment processing
it was assumed it could only be a dict or string (it starts out as a list)
also a 2nd assumption that bare vars only would appear in one of the dict keys.

removed deprecation warnings from here as they should be signaled in the bare conversion itself.
9 years ago
Brian Coca 6bf2f45ff5 fix for so su works in more cases
should not fail anymore on csh, fish nor the BSDs
fixes #14116
9 years ago
James Cammarata 07a9a54b0e Fix lookup of parent attribute when parent doesn't have the attr
Fixes #14100
9 years ago
James Cammarata a8ffa02134 Make sure blocks use their parents dependency chains
Fixes a bug inroduced in fb797a9 where included tasks in a role
were not being executed because the child blocks had no dep chain
set.
9 years ago
James Cammarata 2b02e8e2b4 Allow certain base attributes to be used as role params
Role definitions typically require params to be different from those
which are specified as FieldAttributes on the playbook classes used
for roles, however a certain subset should be allowed (typically those
used for connection stuff).

Fixes #14095
9 years ago
James Cammarata fb797a9e77 Fixing role dependency chain creation
The dep chain for roles created during the compile step had bugs, in
which the dep chain was overwriten and the original tasks in the role
were not assigned a dep chain. This lead to problems in determining
whether roles had already run when in a "diamond" structure, and in
some cases roles were not correctly getting variables from parents.

Fixes #14046
9 years ago
James Cammarata e3a6accc1d Forward conditionals onto included plays when conditional eval errors
When using a playbook-level include, we now catch any errors raised during
the conditional evaluation step and set a flag to indicate we need to pass
those conditionals on to the included play (most likely because they contain
inventory variables for evaluation).

Fixes #14003
9 years ago
James Cammarata c8bbdd6b39 Don't assign both parent blocks and task includes to blocks
This causes problems when fetching parent attributes, as the include
was being skipped because the parent block would fetch the attribute
from the parent play first.

Fixes #13872
9 years ago
James Cammarata d07d974ad8 Revert "Properly look for parent become attribute"
This reverts commit 1b46a422aa.
9 years ago
James Cammarata 1b46a422aa Properly look for parent become attribute
Corrects inheritence of the boolean value, which needs some special
consideration from other (string/int) values.

Fixes #13872
9 years ago
James Cammarata 1af473548b Fix role hashing failure/traceback when params contain lists
Fixes #13857
9 years ago
James Cammarata 1733d434d1 Fix with loop + delegate issues
* Don't re-use the existing connection if the remote_addr field of
  the play context has changed
* When overriding variables in PlayContext (from task/variables),
  don't set the same attribute based on a different variable name
  if we had already previously set it from another variable name

Fixes #13880
9 years ago
James Cammarata 1825b4a9c7 Fix any_errors_fatal incorrect implementation in 2.0
Also adds that flag to blocks.

Fixes #13744
9 years ago
James Cammarata b58673289a Split up comma-separated tags properly
Fixes #13795
9 years ago
Thomas Quinot 2eb22d5536 Fix minor typo in comment 9 years ago
Brian Coca d3deb24ead output color is now configurable 9 years ago
Brian Coca 56454d6a91 added newer vars to 'reset_vars'
these vars pass back info to the task about the connection
moved to their own block at start at file for readability and
added the newer standard vars
9 years ago
Brian Coca 202b92179d corrected role path search order
the unfraking was matching roles in current dir as it always returns a full path,
pushed to the bottom as match of last resort
fixes #13645
9 years ago
Yannig Perré a4674906c6 Merge role params into variables separately from other variables
Fixes #13617
9 years ago
James Cammarata 3ec0104128 Fixing bugs in conditional testing with until and some integration runner tweaks 9 years ago
Toshio Kuratomi 224d596336 Remove args from get_name() as we can't tell if any of the args are no_log 9 years ago
James Cammarata a3dcb910b8 Fixing bugs with {changed,failed}_when and until with registered vars
* Saving of the registered variable was occuring after the tests for
  changed/failed_when.
* Each of the above fields and until were being post_validated too early,
  so variables which were not defined at that time were causing task
  failures.

Fixes #13591
9 years ago
James Cammarata 15135f3c16 Make sure we're using the original host when processing include results
Also fixes a bug where we were passing an incorrect number of parameters to
_do_handler_run() when processing an include file in a handler task/block.

Fixes #13560
9 years ago
James Cammarata 6a252a3f77 Preserve the cumulative path for checking includes which have parents
Otherwise, each relative include path is checked on its own, rather
than in relation to the (possibly relative) path of its parent, meaning
includes multiple level deep may fail to find the correct (or any) file.

Fixes #13472
9 years ago
Brian Coca d9e510b192 narrow down exception catching in block builds
this was obscuring other errors and should have always been narrow scope
9 years ago
Brian Coca ae2447df91 attribute defaults that are containers are a copy
This is simpler way to prevent persistent containers across instances
of classes that use field attributes
9 years ago
Brian Coca 2820b4c243 removed default from hosts to make it requried
prevents writing a play w/o a hosts entry which would default to
all/empty
9 years ago
Brian Coca c64298de02 Revert "avoid persistent containers in attribute defaults"
This reverts commit 87969868d4.
found better way to do it
9 years ago
Brian Coca 87969868d4 avoid persistent containers in attribute defaults
moved from the field attribute declaration and created a placeholder
which then is resolved in the field attribute class.

this is to avoid unwanted persistent of the defaults across objects which introduces
stealth bugs when multiple objects of the same kind are used in succession while
not overriding the default values.
9 years ago
James Cammarata 398f6bbb89 Fix typo from 5ae850c 9 years ago
James Cammarata de690445bc Make fact delegating configurable, defaulting to 1.x behavior 9 years ago
Brian Coca d4ccb0be59 have always_run override check mode for a task
Fixes #13418
9 years ago
James Cammarata 540cbe0f64 Merge pull request #13445 from n-st/tasks-string-repr
More meaningful string representation for meta tasks (like 'noop' and 'flush_handlers')
9 years ago
Brian Coca 955710267c only set become defaults at last possible moment
tasks were overriding commandline with their defaults, not with the
explicit setting, removed the setting of defaults from task init and
pushed down to play context at last possible moment.
fixes #13362
9 years ago
Nils Steinger a1f6d17e37 More meaningful string representation for meta tasks (like 'noop' and 'flush_handlers') 9 years ago
Thomas Steinbach 349fb42f54 Allow setup of docker remote connections 9 years ago
James Cammarata 5f83a6aeda Properly default remote_user for delegated-to hosts
Fixes #13323
9 years ago
James Cammarata 5f1f2acfea Merge pull request #13405 from sivel/v2-playbook-on-start
Get v2_playbook_on_start working
9 years ago
Matt Martz 384b2e0234 Get v2_playbook_on_start working
* Move self._tqm.load_callbacks() earlier to ensure that v2_on_playbook_start can fire
* Pass the playbook instance to v2_on_playbook_start
* Add a _file_name instance attribute to the playbook
9 years ago
Matt Martz ce54a59cdc Catch additional assertion errors for load_list_of_blocks 9 years ago
Brian Coca 53cd802251 better error on invalid task lists 9 years ago
Brian Coca b92cb93539 unconditionally set vars on init to avoid issues with var precedence 9 years ago
Brian Coca a6f6a80caa avoid inheritance issues with default=dict declaration at class level
this should avoid the issue of subsequent plays not prompting for a var
prompted for in a previous play.
9 years ago
James Cammarata dc0fae1af7 Also make sure remote_user is defaulted correctly for delegated hosts
Fixes #13323
9 years ago
James Cammarata cc36eedf76 Ensure port is (re)set for delegated-to hosts
Fixes #13265
9 years ago
Toshio Kuratomi 1b743436b9 Do not double transform to unicode 9 years ago
Chrrrles Paul 157230c3e8 Merge pull request #13257 from chrrrles/utf8
fixing error with using non-ascii values for ask-sudo-password
9 years ago
Charles Paul 1e5a205389 fixing errors with utf-8 values
removing utf-8 stanza

changing cast to binary_type instead

using to_unicode
9 years ago
James Cammarata e06b107d2d Template (and include vars) PlaybookInclude paths
Fixes #13249
9 years ago
James Cammarata 91500f8f5f Fix include param precedence in variable manager 9 years ago
Mick Bass 9761250a4b Allow tree-ish to be used for galaxy role version
Ensure that ansible-galaxy version can be a branch, a tag, or any tree-ish
supported by git including specific commit IDs.  For git scm roles, adds an
explicit git checkout of the specified role_version prior to the git archive.
This means that we'll always archive from HEAD of whatever role_version is
checked out. role_version can be a branch, a tag, or any <tree-ish> supported
by git including specific commit IDs.  These changes also ensure
ansible-galaxy works for scm clones when specified version differs from
repository default branch.
9 years ago
James Cammarata 984729016e Fix tag filtering on included files and add more debugging
Previously, we were filtering the task list on tags for each host
that was including the file, based on the idea that the variables
had to include the host information. However, the top level task
filtering is play-context only, which should also apply to the
included tasks. Tags cannot and should not be based on hostvars.
9 years ago
Brian Coca eeedaf2cbc fixed var name typo 9 years ago
Brian Coca e174247734 evaluate includes for skipped tags
cannot evaluate for include tags as underlying tasks might have them, but skips override so this should be a performance boost
9 years ago
Toshio Kuratomi 62979efa14 Finish up plugin porting to global display
Also remove display = display which does nothing
9 years ago
Toshio Kuratomi 7ecfa072da Move the rest of the playbook code to use global display 9 years ago
Toshio Kuratomi c7b69127ec Remove dead code 9 years ago
James Cammarata e36b4e2a13 Merge pull request #13072 from Yannig/devel_cache_optimization
Cache optimization
9 years ago
James Cammarata 76ae577519 Ensure environment is inherited properly (task->block/include->play) 9 years ago
Yannig Perré 12a6fb9633 Small speed improvement with huge inventory (100+ hosts). 9 years ago
Brian Coca 226c7f4c7b Revert "added setting of ansible_ssh_user to current user as backwards compatibilty issue"
scope was wrong, this var should not be 'reset' here.

This reverts commit c271c0eb04.
9 years ago
James Cammarata 299054852a Allow tags to be specified in included file params
Fixes #12940
9 years ago
Brian Coca b2fc5142eb moved sudo -S and -n into configurable flags as they might be absent in much older systems
if password is supplied exsiting -n would get remove from flags
9 years ago
Toshio Kuratomi 7334389de6 Merge pull request #12930 from ansible/dict-key-overwrite-warning
Break apart a looped dependency to show a warning when parsing playbooks
9 years ago
Toshio Kuratomi 4203850d1a Break apart a looped dependency to show a warning when parsing playbooks
Display a warning when a dict key is overwritten by pyyaml
Fixes #12888
9 years ago
James Cammarata 3fc2209ca0 Fixing retry/until logic and default value for retries
Fixes #12928
Fixes #12929
9 years ago
James Cammarata 1dc23ea779 Merge pull request #12866 from bcoca/more_inheritence
More inheritence
9 years ago
Brian Coca c271c0eb04 added setting of ansible_ssh_user to current user as backwards compatibilty issue 9 years ago
James Cammarata 677a2f95e5 Make sure Base attributes are copied cleanly
Fixes #12882
9 years ago
Lars Kellogg-Stedman 914f68f9af allow include: directive to work during exception processing
prior to this commit, an attempt to use the `include:` directive would
fail in a `rescue:` or `always:` block if there were failures in the
main block task list.

Resolves #12876.
9 years ago
James Cammarata 86de1429e5 Cleaning up FIXMEs 9 years ago
Brian Coca 54e821ca94 added deprecation warning to comma separated role spec 9 years ago
Brian Coca d861e7dd5d moved several directives so they are not settable at play, block, role and task levels 9 years ago
Will Thames 002972c6cf Allow meta/main.yml to include roles through spec file
ansible-playbook now works when run with a playbook
that includes a role that includes another role
specified using csv format

Updated one of the roles used in the tests to fix
broken tests - `make test_galaxy` now works

Fixes #11486. Also addresses the problem alluded to in #10620.
9 years ago
James Cammarata 2b3c5aa41e Support cmd param in Tasks by assigning it to _raw_params
Fixes #12856
9 years ago
Brian Coca 1ecad5aed2 now galaxy correctly detects empty requirements file
also allow for 'scm' and 'src' not to be populated in requirements entries
9 years ago
James Cammarata b46ce47a84 Don't use local transport for delegated hosts if the inventory_hostname isn't local
For some situations like Vagrant, the remote_addr may be a localhost addr, but ssh
is still desired. This corrects the assumption that any localhost remote_addr should
be using the local connection by checking the inventory_hostname value as well.

Fixes #12817
9 years ago
James Cammarata 3c87c44af5 Fixing bug in includes caused by 892d9b8
Fixes #12837
9 years ago
James Cammarata e5b6d802bf Removing some cruft related to _local_action value on Task, which was removed
Fixes #12819
9 years ago
Brian Coca 1280e2296c changed warning to debug and expanded info on what is really happening, it was a bit misleading 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
Marius Gedminas f03da5be42 Python 3: there's no iteritems() 9 years ago
James Cammarata 82e76e42e5 Tweak to the way serial percentages are handled 9 years ago
James Cammarata 63e288354e Fix bug in way omitted values were set 9 years ago
James Cammarata 4c85ae0712 Merge branch 'serial_should_be_string' of https://github.com/klshxsh/ansible into klshxsh-serial_should_be_string 9 years ago
klshxsh ac00c9ced7 changed 'string' to 'percent' for _serial
Note that this allows both integers (e.g. 3) and percentages (e.g. "30%")
Also changed default back to 0 rather than '0'
9 years ago
Brian Coca d24532757c remove fix for local_action/connection local that is now not needed 9 years ago
klshxsh 4a5e52b2d2 The serial keyword can be specified as a percentage, e.g '30%' or a number e.g. '3'; therefore it needs to be a string to allow both types 9 years ago
Brian Coca abf2e13955 Revert "Track local_action internally to prevent it from being overridden"
This reverts commit 49ca0eb797.
9 years ago
Brian Coca 101c8785ec removed changes to make local action equate connection=local and brought it back to equate delegate_to=localhost 9 years ago
Juraci 254d6be520 Adding get_path method to Task class 9 years ago
James Cammarata 7a815b7296 Force connection to local when localhost is delegated to 9 years ago
Toshio Kuratomi 4f6f2c21e8 range vs xrange doesn't matter here and six.moves.range isn't available in six-1.3.0 (rhel7) 9 years ago
James Cammarata d9b79b1bbc Also template the role name when loading roles
Fixes #12602
9 years ago
James Cammarata 9c9897805f More ansible-galaxy fixes for the old spec file format 9 years ago
James Cammarata 3b8eaf6128 Cleaning up some ansible-galaxy stuff 9 years ago
James Cammarata 284bd118a0 Properly switch to the default transport when delegating from localhost 9 years ago
Brian Coca f73329401b galaxy updates
better error reporting on fetching errors
use scm if it exists over src
unified functions in requirements
simplified logic
added verbose to tests
cleanup code refs, unused options and dead code
moved get_opt to base class
fixes #11920
fixes #12612
fixes #10454
9 years ago
James Cammarata 323012be2e Pop tags out of playbook include params
Fixes #12605
9 years ago
Abhijit Menon-Sen 1981bf2b95 Aggregate ssh arguments in PlayContext instead of the connection plugin
Using set_host_overrides() in the connection plugin to access the ssh
argument variables from the inventory didn't see group_vars/host_vars
settings, as noted earlier. Instead, we can set the correct values in
the PlayContext, which has access to all command-line options, task
settings, and variables.

The only downside of doing so is that the source of the settings is no
longer available in ssh.py, and therefore can't be logged. But the code
is simpler, and it actually works.

This change was suggested by @jimi-c in response to the FIXME in the
earlier commit.
9 years ago
Abhijit Menon-Sen 3ad9b4cba6 Rework additional ssh argument handling
Now we have the following ways to set additional arguments:

1. [ssh_connection]ssh_args in ansible.cfg: global setting, prepended to
   every command line for ssh/scp/sftp. Overrides default ControlPersist
   settings.
2. ansible_ssh_common_args inventory variable. Appended to every command
   line for ssh/scp/sftp. Used in addition to ssh_args, if set above, or
   the default settings.
3. ansible_{sftp,scp,ssh}_extra_args inventory variables. Appended to
   every command line for the relevant binary only. Used in addition to
   #1 and #2, if set above, or the default settings.
3. Using the --ssh-common-args or --{sftp,scp,ssh}-extra-args command
   line options (which are overriden by #2 and #3 above).

This preserves backwards compatibility (for ssh_args in ansible.cfg),
but also permits global settings (e.g. ProxyCommand via _common_args) or
ssh-specific options (e.g. -R via ssh_extra_args).

Fixes #12576
9 years ago
Brian Coca c27bd4fab0 {sudo,su}_user does not imply become 9 years ago
James Cammarata 8ef78b1cf8 Fixing accelerated connection plugin 9 years ago
Brian Coca ddafed4403 Merge pull request #12528 from bcoca/task_logging
task logging revamp
9 years ago
James Cammarata 3bd71d0619 Use delegated_to field for play context remote_addr, if none other exists
Fixes #12527
9 years ago
James Cammarata dfa33d0f23 Tweak variable manager use in role includes to avoid test failures 9 years ago
James Cammarata 7173f587ed Allow delegate_to on a role again
Fixes #12560
9 years ago
James Cammarata a3e913da62 Don't assume handlers exist in the same role (if any)
Fixes #12536
9 years ago
James Cammarata 79e364d98b Properly template role dependency names
Fixes #12505
9 years ago
Marius Gedminas 5edd6d9be4 Python 3: there's no basestring
Fixes another failing test.

(I don't want to do a global search/replace for 'basestring' because I
want to have unit tests covering each occurrence.  When I run out of
existing failing tests, I'll try to write new ones.)
9 years ago
James Cammarata ffdba96668 Save the included directory for playbook includes for use as the basedir
Fixes #12524
9 years ago
Abhijit Menon-Sen 565c6f1ae7 Make ansible_pipelining a connection variable
SSH pipelining can be a significant performance improvement, but it will
not work if sudoers is configured to requiretty. With this change, one
could have pipelining enabled in ansible.cfg, but use sudo to turn off
requiretty in a separate play (or task) where pipelining is disabled:

    - hosts: foo
      vars:
          ansible_pipelining: no
      tasks:
        - lineinfile: dest=/etc/sudoers line='Defaults requiretty' state=absent
          sudo_user: root

(Note that sudoers has a complicated syntax, so the above lineinfile
invocation may be too simplistic for production use; but the point is
that a separate play can do something to disable requiretty.)
9 years ago
James Cammarata 6dd38c2a10 Fix parent attribute lookup to be default
Fixes #12526
9 years ago
James Cammarata a1c38a3fda Adding delegate_to to Blocks 9 years ago
Abhijit Menon-Sen 6ff4d40d74 Update outdated comment
We now use "sudo -n" instead of "sudo -k && sudo …"
9 years ago
Brian Coca 37a918438b task logging revamp
* allow global no_log setting, no need to set at play or task level, but can be overriden by them
 * allow turning off syslog only on task execution from target host (manage_syslog), overlaps with no_log functionality
 * created log function for task modules to use, now we can remove all syslog references, will use systemd journal if present
 * added debug flag to modules, so they can make it call new log function conditionally
 * added debug logging in module's run_command
9 years ago
Toshio Kuratomi fa9ea32a86 Fix test of whether a result has a failed host 9 years ago
James Cammarata 31d5f88a1d Use the task loop to calculate multiple delegated hosts
Due to the way we're now calculating delegate_to, if that value is based
on a loop variable ('item') we need to calculate all of the possible
delegated_to variables for that loop.

Fixes #12499
9 years ago
James Cammarata c9a004227e Improve error catching from malformed playbook data
Fixes #12478
9 years ago
Abhijit Menon-Sen ac98fe9e89 Implement ssh connection handling as a state machine
The event loop (even after it was brought into one place in _run in the
previous commit) was hard to follow. The states and transitions weren't
clear or documented, and the privilege escalation code was non-blocking
while the rest was blocking.

Now we have a state machine with four states: awaiting_prompt,
awaiting_escalation, ready_to_send (initial data), and awaiting_exit.
The actions in each state and the transitions between then are clearly
documented.

The check_incorrect_password() method no longer checks for empty strings
(since they will always match), and check_become_success() uses equality
rather than a substring match to avoid thinking an echoed command is an
indication of successful escalation. Also adds a check_missing_password
connection method to detect the error from sudo -n/doas -n.
9 years ago
James Cammarata a22f7b883d Restrict role param vars to tasks within that role
Fixes #12460
9 years ago
James Cammarata 72769d1899 Merge pull request #12432 from mgedmin/py3k
Python 3: there's no xrange
9 years ago
James Cammarata 1f5584aa5b Refactoring delegate_to code
Now, instead of relying on hostvars on the executor side, we compile
the vars for the delegated to host in a special internal variable and
have the PlayContext object look for things there when applying task/
var overrides, which is much cleaner and takes advantage of the code
already dealing with all of the magic variable variations.

Fixes #12127
Fixes #12079
9 years ago
Marius Gedminas baf9320369 Python 3: there's no xrange
Use six.moves.range instead (aliased to xrange on Python 2, aliased to
range on Python 3).

Also I couldn't resist replacing the elaborate chr/ord/randrange dance
with the simpler random.choice(string.ascii_lowercase) that was already
used elsewhere in the Ansible codebase.
9 years ago
Marius Gedminas 8243954dcd Python 3: basestring in play_context.py 9 years ago