Commit Graph

559 Commits (0eb1c880ddac9547560040311739b5ca8291a642)

Author SHA1 Message Date
Seth Woodworth 1d5db30067 Updates loop warning, removes unnecessary c 2014-03-09 00:19:28 -05:00
James Cammarata 04a6dc6d12 Check for skipped tags in passed role variables before adding to them
Fixes #6330
2014-03-08 18:55:42 -06:00
James Cammarata b6056044b7 Partial revert of 73c883c due to issues with handlers in roles
Fixes #6322
2014-03-06 21:13:40 -06:00
Michael DeHaan a4d01b0891 Also search .json filenames 2014-03-06 21:47:49 -05:00
Brian Coca 79809b67dc fixed another line with same issues
Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
2014-03-06 08:43:24 -05:00
Brian Coca d3d5680d8f tags lists are properly uniqued and joined now, also avoids type issues when passed as list/set or strings
Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
2014-03-06 08:28:36 -05:00
James Cammarata 73c883c122 Keep track of role dependencies across plays
Also fixes a bug in which tags specified on top-level roles were
not being passed down to dependent roles.

Fixes #4656
2014-03-05 14:37:37 -06:00
Hagai 0e4b38ed5a Fix incorrect use of copy on list 2014-03-03 14:47:57 +02:00
James Cammarata b758ed9417 Merge pull request #6150 from hkariti/fix_join_bug
Fix incorrect use of .join on list causing a traceback
2014-02-26 12:50:07 -06:00
Hagai ae9c0d87a9 Fix incorrect use of .join on list 2014-02-24 19:48:55 +02:00
Veeti Paananen dd6f2e6bfa Show the offending file name with the include + with_items error 2014-02-23 20:51:57 +02:00
James Cammarata fa1ab231c9 Fixing bug in which playbook vars were not merged properly
This occurred when a hash would be passed in via extra args and the
hash variable behavior was set to 'merge', which resulted in the
variable from extra args replacing the playbook variable.
2014-02-20 15:25:52 -05:00
James Tanner 3fc87e011b Fix all other calls to yaml 2014-02-19 11:01:21 -05:00
James Tanner 427b8dc78d Ansible vault: a framework for encrypting any playbook or var file. 2014-02-18 15:35:12 -05:00
jctanner 28933de84d Merge pull request #5771 from bcoca/play_hosts2
added new play_hosts var
2014-02-05 23:52:20 -05:00
jctanner 253fe7be50 Merge pull request #5662 from RSpiertz/update_playbook_error
PlayBook: better error message
2014-02-04 11:16:44 -08:00
James Cammarata ae9843fccd Fix issue with handler notifications being sent out incorrectly
This is a partial revert of e8ad36c, which introduced the bug.

Fixes #5848
2014-02-03 10:10:45 -06:00
James Cammarata 75e3b59bbd Adding no_log: capability for tasks
Fixes #4088
2014-01-31 16:58:46 -06:00
James Cammarata 5cc354696d Build variable dictionary on included plays without using dict()
Using dict(k=v) means the key was always named 'k', as the variable
is not interpreted there.

Fixes #5801
2014-01-29 12:31:12 -06:00
Michael DeHaan d07a3b5e9b AnsibleWorks -> Ansible 2014-01-28 20:29:42 -05:00
James Cammarata 88e2595a90 Fixing bug relating to su without an su_pass 2014-01-27 16:27:02 -06:00
Brian Coca 59d5892fa3 added new play_hosts var
this variable has the 'current host list' to be executed over in the
play. Useful when using --limit to not iterate over hosts not included
in play in templates or with_items.

Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2014-01-25 18:43:15 -05:00
jctanner b2d594d24e Merge pull request #5724 from angstwad/su-tasks-fix
Fix bug where playbook tasks do not escalate privs with 'su'
2014-01-23 14:05:14 -08:00
jctanner 19e8742005 Merge pull request #5713 from angstwad/su-fix
Disallow su and sudo params in same play/task
2014-01-23 13:55:43 -08:00
Paul Durivage e875089eba Fix bug where self.su was being set by the sudo param in play tasks 2014-01-22 11:04:19 -06:00
Paul Durivage 01d1bd61e7 Disallow su and sudo params in same play/task 2014-01-22 10:55:45 -06:00
James Tanner 61d283e2ad Fix merge conflicts from #5519 2014-01-21 13:35:06 -05:00
Paul Durivage f72f5a20df Revert "Revert "Merge pull request #5325 from angstwad/add-su-support""
This reverts commit c17d0e0357.

Conflicts:
	lib/ansible/runner/connection_plugins/paramiko_ssh.py
2014-01-20 19:19:03 -06:00
Jesse Keating 6013f0738e Store the list of hosts to run on in runner object
This reduces the number of times inventory.list_hosts is called, which
can be costly. When coming from a playbook that data is already known.
2014-01-20 16:22:28 -08:00
Jesse Keating e8ad36c8d4 Store hosts for a play as a play attribute
Operate on that play attribute to make things faster for larger
inventories. Instead of making a round trip through inventory.list_hosts
and working through some lengthy list comprehensions over and over
again, calculate the potenital hosts for a play once, then reduce from
it the unavailable hosts when necessary.

Also moves how the %fail is done. The host count is a play level count
of available hosts, which then is compared after each task to the
current number of available hosts for the play. This used to get a new
count every task which was also time expensive.
2014-01-20 16:22:28 -08:00
James Tanner c17d0e0357 Revert "Merge pull request #5325 from angstwad/add-su-support"
This reverts commit 6f4bfa2cff, reversing
changes made to c91ba3a7c7.
2014-01-20 16:10:11 -05:00
Paul Durivage dec9131735 Ensure playbook support for su params 2014-01-20 11:46:56 -06:00
Paul Durivage d21281ff43 Resolve rebase conflicts 2014-01-20 11:46:05 -06:00
Paul Durivage 4088243deb Proposing fix for Issue #4324; adding support for su in connection plugins ssh, ssh_alt
Fixes for ssh_alt support, adding in references to in_data where appropriate
2014-01-20 11:25:10 -06:00
Rutger Spiertz dec6345fe6 PlayBook: better error message
When a PlayBook has missing arguments the error message now shows which ones are missing.
2014-01-17 10:30:57 +01:00
Matt Martz f99500d65c Expose the playbook to callback plugins 2014-01-08 14:40:37 -06:00
Michael DeHaan c039e276a2 Fact gathering on a second play against the same hosts should not be implicitly off since this is an undocumented beheavior and potentially
rather unwanted when a play could change a fact.

gather_facts: True/False can still be explicitly used per play.

Reverts 564a212b3c
2014-01-04 14:03:58 -05:00
Michael DeHaan 87258f6d42 Resolve merge commit 2014-01-04 14:03:42 -05:00
Michael DeHaan a3d90e8a87 Merge pull request #5498 from j2sol/exit_setup_early
Return early from setup step when possible
2014-01-04 10:47:35 -08:00
Michael DeHaan 10350d1639 Update various copyrights. Not complete, but sufficient. 2014-01-04 13:32:04 -05:00
Jesse Keating 35328ed503 Return early from setup step when possible
The _list_available_hosts call can be lengthy, and in the case where
gather_facts is disabled the call is pointless. So re-arrange the logic
to return early from _do_setup_step when gather_facts is false.
2014-01-03 16:39:13 -08:00
Michael DeHaan 8e5b7d3095 Remove code underlying when_* and only_if, which are deprecated features slated for removal in the 1.5 release. 2014-01-03 19:13:21 -05:00
Michael DeHaan 28b9fd4e30 We have had only_if, when_foo, etc, deprecated for a while and said they would be removed in 1.5. Now they are, with friendly error messages still.
Users of these features should use "when:" as documented at docs.ansible.com.

Similarly, include + with_items has been removed.  The solution is to loop
inside the task files, see with_nested / with_together, etc.
2014-01-03 13:47:54 -05:00
James Tanner 993e0f057e Allow for no role dependencies in role metadata 2013-12-19 14:19:14 -05:00
James Tanner 1ef9930b80 Addresses #5341 Expand home directories when searching for roles in ansible-playbook 2013-12-18 23:31:03 -05:00
Michael Vogt bef5ee2c3b improve error on invalid vars file (if its a list instead of a dict) 2013-12-12 09:56:30 +01:00
James Tanner dc41bb8085 Merge pull request #4207 from ashorin/ansible
Fail playbook when serial is set and hadlers fail on set.
2013-11-12 14:37:07 -05:00
Alan Descoins bb6f02d0e8 Support running handler parametrized by name. 2013-11-07 16:54:06 -02:00
James Tanner d93780bc8a Addresses #4635 add list instead of join 2013-11-05 14:44:27 -05:00
James Tanner 2b5005687a Fixes #4635 pass role conditionals to dependent roles 2013-11-05 14:38:21 -05:00
James Tanner 91aa7b51df Remove invalid ipv6 parameter from setup execution 2013-11-04 17:23:32 -05:00
James Tanner c1ed47933b Fixes #4485 add an ipv6 parameter to accelerate so that the daemon will bind to an ipv6 port instead of ipv4 2013-11-04 17:20:03 -05:00
James Tanner d154bf8781 Revert templating enhancements from 73dbab70 e6c28658 d409352c 9858b1f2 4587528b 9b1fe455 214b0b05 8d3db803 7f9504d1 5031104c 35cb9dc2 2bd8cb57 1e85c754 2013-10-30 10:50:16 -04:00
James Tanner 9b1fe455c6 Fixes #4549 Do not call lookup plugins when templating a task's name 2013-10-25 10:27:38 -04:00
Serge van Ginderachter 6277e770a1 include basedir as 'playbook_dir' variable
closes #4246
2013-10-25 07:53:52 +02:00
James Tanner 4f13967386 Fixes #4536 Get the remote_user from multiple sources in a preferred order 2013-10-21 12:07:51 -04:00
Michael DeHaan 60944b81f0 Provide warning about "with_items: '{{ loop }}'" being redundant only when {{ starts the expression value. Fixes #4582. 2013-10-19 14:24:12 -04:00
Michael DeHaan 4125b05bf3 Allow a defaults file to solely define a role. Some typo fixes. 2013-10-19 14:01:20 -04:00
Michael DeHaan 21d4400c96 Misc pep8 fixes 2013-10-19 13:03:15 -04:00
James Tanner 8478e82647 Fixes #4583 enforce that vars_files is a list 2013-10-18 11:19:16 -04:00
jctanner 69fa5954fd Merge pull request #3932 from jocelynj/devel
Add option remote_user to task level, to specify the ssh login user
2013-10-15 06:34:57 -07:00
Michael DeHaan 9ea54fcaaf Fixes a dev branch glitch where a conditional could be applied to multiple tasks. Also improves the errors on parsing bad conditionals to make them less confusing to users. 2013-10-12 17:39:28 -04:00
Thomas Omans 632232259a Adding config flag role_path for common/global roles
Using ANSIBLE_ROLE_PATH environment variable or role_path in ansible.cfg
can configure paths where roles will be searched for
extra paths will only be used as a backup once regular locations are exhausted
2013-10-12 10:15:30 -04:00
Michael DeHaan d168c709d5 Fix an issue where the ordering of an include statement is processed ahead of the conditional in the included statement,
which required a redundant check to see if a variable was defined rather than short circuiting.

Fixes #4469
2013-10-11 20:43:58 -04:00
Michael DeHaan 709ffda3d1 Tweak only_if deprecation detector. 2013-10-11 19:12:25 -04:00
Michael DeHaan a45494a896 Add warnings feature. 2013-10-11 19:04:26 -04:00
Michael DeHaan 9637f620d7 Deprecation warnings of several flavors, nice and purple and can be disabled
in ansible.cfg.
2013-10-11 18:37:39 -04:00
Michael DeHaan 6febc97104 Add a warning about include + with_items so nobody uses it. 2013-10-08 18:12:18 -04:00
James Cammarata 98f6bc1f63 Apply tags to dependent roles correctly
Fixes #4339
2013-10-08 15:13:02 -05:00
Michael DeHaan f081c68a65 Prevent duplicately loaded handlers from running more than once.
Fixes #3863
2013-10-07 17:15:19 -04:00
Michael DeHaan 5e30cd999c Make it possible to say:
tags: 42

And have the tag be a string, not an int, so --tags matches.

Fixes #4110
2013-10-07 15:19:30 -04:00
James Cammarata 912e3a7b0b Merge branch 'accelerate_improvements' into devel
Conflicts:
	library/utilities/accelerate
2013-10-01 21:22:17 -05:00
James Cammarata 8c17711247 Removing accelerate_timeout as a playbook option
This will remain in ansible.cfg only.
2013-10-01 15:33:18 -05:00
James Cammarata 59a5ce23d9 Adding an accelerate_timeout parameter for plays
This setting makes the timeout for each play configurable, rather than
hard-coding it at 300 seconds (now the default if left unspecified)

Fixes #4162
2013-10-01 15:26:50 -05:00
James Cammarata 8a3f8b757b Make sure yaml data loaded for role is valid before using it
Fixes #4322
2013-10-01 10:52:39 -05:00
James Cammarata 7aad576f5f Minor change to add a space around role name/task delimiter 2013-09-30 21:51:39 -05:00
bennojoy 482cb72128 role report fix 2013-09-26 19:20:14 +05:30
bennojoy 53e48b63a9 dountil feature commit 1 2013-09-24 13:59:38 +05:30
James Cammarata 47b9cc6311 Merge branch 'meta-roles' of https://github.com/eggsby/ansible into eggsby-meta-roles
Conflicts:
	lib/ansible/playbook/play.py
2013-09-20 16:17:40 -05:00
James Cammarata 27e8675277 Make the role_name in the task its own field for use in the callback 2013-09-20 15:46:34 -05:00
James Cammarata 98cfcec5e2 Correct role name detection 2013-09-20 12:10:24 -05:00
James Cammarata 8dcf386def Don't set the role name on handlers as this breaks notifications 2013-09-20 09:34:14 -05:00
James Cammarata a5ee6ff1e5 Display parent role name of tasks in the name line
Fixes #4076
2013-09-19 20:44:52 -05:00
Thomas Omans 91a4ba2248 allowing a roles to do be made out of dependencies alone 2013-09-18 21:29:37 -07:00
James Cammarata 458f71b53c Merge branch 'issue_4129_role_defaults_empty_yaml' into devel
Conflicts:
	lib/ansible/playbook/play.py
2013-09-16 16:21:06 -05:00
James Cammarata 091a90ee8b Allow includes to follow the standard format
Previously, includes had to receive variables via a special 'vars'
field. With this patch, the include syntax becomes a more natural
datastructure without special fields and is more akin to the way
role includes/dependencies work.

Tested with the following playbook:
---
- hosts: localhost
  connection: local
  tasks:
  - { include: inc1.yml, a: 1 }
  - include: inc2.yml
    b: 2
  - include: inc3.yml
    with_items:
    - x
    - y
    - z

Fixes #3481
2013-09-16 16:12:36 -05:00
James Cammarata c5bb1394b9 Check to make sure default_vars in the datastructure isn't empty
Fixes #4129
2013-09-16 13:16:06 -05:00
James Cammarata 3b801dec72 Merge branch 'failed_when' of https://github.com/hnakamur/ansible into hnakamur-failed_when 2013-09-16 07:35:34 -05:00
James Cammarata aac3090909 Merge branch 'play_remote_user' of https://github.com/bcoca/ansible into bcoca-play_remote_user 2013-09-16 05:55:14 -05:00
Hiroaki Nakamura 2357194b39 Add failed_when module variable.
Implementation note: Ternery operator trick for python prior to 2.5 is used.
(test and [when_true_value] or [when_false_value])[0]
http://stackoverflow.com/questions/394809/ternary-conditional-operator-in-python#comment1466794_394887
2013-09-10 08:34:01 +09:00
James Cammarata 75a9357e5e Fixing role variable precedence for top-level roles
Fixes #4026
Fixes #3989
2013-09-09 15:14:03 -05:00
James Cammarata bcc2a4b513 Minor fix so the any_errors_fatal value is checked properly 2013-09-09 10:20:41 -05:00
Brian Coca d47c48e30a Added remote_user to plays
Still compatible with user: but deprecating it so we can have
a matching remote_user: in tasks, cannot be user: because of the
module of the same name. #3932

Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2013-09-07 16:34:22 -04:00
Kavin Kankeshwar c24f6f438b Avoid ugly formatting due to a long if statement 2013-09-06 22:37:17 -07:00
kavink a075ec9831 Bug fix for a crash, when any_errors_fatal is true
Reported by Rumen:

TASK: [fail FAIL] *************************************************************
skipping: [hostname.com]
failed: [hostname.com] => {"failed": true}
msg: Failed as requested from task
Traceback (most recent call last):
  File "/usr/local/bin/ansible-playbook", line 268, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/usr/local/bin/ansible-playbook", line 208, in main
    pb.run()
  File "/Library/Python/2.7/site-packages/ansible/playbook/__init__.py", line 262, in run
    if not self._run_play(play):
  File "/Library/Python/2.7/site-packages/ansible/playbook/__init__.py", line 580, in _run_play
    if (hosts_count - len(host_list)) > int((play.max_fail_pct)/100.0 * hosts_count):
TypeError: object of type 'NoneType' has no len()
2013-09-04 18:30:33 -07:00
James Cammarata 7b13b1e03e Minor fix to dependency dupe patch 2013-09-04 11:26:49 -05:00
smoothify 5337397abd Second Attempt: Ensure duplicate roles are not loaded in the case of a missing meta/main.yml file. 2013-09-04 15:50:39 +01:00
smoothify 0411ea2867 Ensure duplicate roles are not loaded in the case of a missing meta/main.yml file. 2013-09-04 12:38:42 +01:00
James Cammarata 2e49d2003d Fix bug where accelerate keyword was not checked for boolean value
The play was just checking for the presence of the keyword in the
YAML datastructure, and not the value of the field, so doing something
like variable substitution was always causing the play to be accelerated
2013-09-03 14:20:56 -05:00
James Cammarata d05c61d1f0 Merge branch 'devel' into fireball2
Conflicts:
	lib/ansible/playbook/__init__.py
	lib/ansible/playbook/play.py
2013-09-02 21:54:02 -05:00
James Cammarata 50f54f6bda Making variable names more descriptive for the default variables work 2013-09-02 21:37:50 -05:00
James Cammarata 02b7b79d7e Re-adding capability of tasks to see a unique view of their own defaults 2013-09-02 21:37:50 -05:00
James Cammarata 266d2008d8 Reverting the role default variables change
Loading the default variables in _build_role_dependencies() lead to
a side-effect where those variables were over-riding inventory variables.
2013-09-01 08:53:59 -05:00
James Cammarata 47a89a57fa Fixing bug in playbook use of default variables in roles 2013-09-01 08:49:41 -05:00
James Cammarata e0df5b5888 A couple more tweaks to role default variables/dependencies
* Default variables are now fed directly into roles, just like the
  other variables, so that roles see their unique values rather
  than those set at the global level.

* Role dependency duplicates are now determined by checking the params used
  when specifying them as dependencies rather than just on the name of the
  role. For example, the following would be included twice without having
  to specify "allow_duplicates: true":

  dependencies:
  - { role: foo, x: 1 }
  - { role: foo, x: 2 }
2013-09-01 00:43:16 -05:00
James Cammarata 736c8b19d3 Added ability to limit role dependencies to just one inclusion 2013-08-30 12:42:27 -05:00
James Cammarata 25e3eed519 Fixing a bug in variable precedence for roles and dependencies 2013-08-30 01:20:45 -05:00
James Cammarata 637d3070dc Allow default variables to be overridden by inventory variables 2013-08-29 17:21:28 -05:00
James Cammarata f66683863e Merge branch 'defaults' of https://github.com/smoothify/ansible into smoothify-defaults 2013-08-28 16:24:37 -05:00
James Cammarata 959138d00d Added accelerate_port to plays, and made it configurable 2013-08-28 11:14:58 -05:00
James Cammarata 167f185092 Initial support for running gather_facts through fireball2 2013-08-28 11:14:58 -05:00
James Cammarata 521e14a3ad Fireball2 mode working! 2013-08-28 11:14:58 -05:00
Wincent Colaiuta fc4307a9c4 Fix minor typo in playbook error message 2013-08-25 11:29:07 -07:00
Jocelyn Jaubert 4cee6a5435 Add option remote_user to task level, to specify the ssh login user 2013-08-23 23:20:13 +02:00
James Cammarata 157b697a83 Merge branch 'always_run-6' of https://github.com/stoned/ansible into stoned-always_run-6 2013-08-22 12:10:28 -05:00
James Cammarata ed3e4aff84 Place retry file in the user's home dir instead of /var/lib/tmp
Addresses CVE-2013-4260: predictable filename used for failed results
in world writable directory.
2013-08-21 11:40:46 -05:00
Stoned Elipot f0743fc32a Introduce the 'always_run' task clause.
The 'always_run' task clause allows one to execute a task even in
check mode.

While here implement Runner.noop_on_check() to check if a runner
really should execute its task, with respect to check mode option
and 'always_run' clause.

Also add the optional 'jinja2' argument to check_conditional() :
it allows to give this function a jinja2 expression without exposing
the 'jinja2_compare' implementation mechanism.
2013-08-20 23:09:44 +02:00
Kavin Kankeshwar 7ac3bbc198 resolved #3609 Change max_fail_pct to max_fail_percentage as recommended 2013-08-20 13:55:34 -05:00
Kavin Kankeshwar 3f247fcbe3 fixes ansible/ansible#3609 Add max_fail_pct to playbook parameter, to complement serial option, So if total number of failures execeed max_fail_pct * total number of hosts, do not go to the next serial batch 2013-08-20 13:55:22 -05:00
smoothify 494043947d Add support for role defaults. These are variables on a per role basis with lowest precedence. 2013-08-20 10:11:39 +01:00
Petr Svoboda e3adfbf5f8 Add tests for undefined variable detection
Tests `test_playbook_undefined_varsX_fail` check if ansible detects
undefined variables when `error_on_undefined_vars` is enabled. These
tests fail without "Improve behavior with error_on_undefined_vars
enabled" patch.

Tests `test_playbook_undefined_varsX_ignore` check if ansible ignores
undefined variables when `error_on_undefined_vars` is disabled.

Also modify PlayBook._run_task_internal() so error_on_undefined_vars is
testable.
2013-08-20 00:40:49 -05:00
James Cammarata 5847720746 Fixing a small bug with the new role dependency feature
The block that added the original list of roles was indented too far,
and was only being reached if a role had dependencies. This resulted
in roles without dependencies from being added to the list of roles.

Credit goes to looped for reporting and diagnosing the issue.
2013-08-17 00:06:24 -05:00
James Cammarata d8a7a2d1b2 Adding evaluation of role vars as the dep tree is built
This allows variables to be inserted into the role scope specifically
while also being inserted into the global scope.
2013-08-15 20:53:23 -05:00
James Cammarata e12b99dba6 Small cleanup, no need to call _get_role_path a second time 2013-08-15 09:29:51 -05:00
James Cammarata 9a401e73a6 Adding support for role dependencies.
Fixes #3686

Dependencies are enabled by adding a new directory/file named
meta/main.yml to the role. The format of the dependencies are:

dependencies:
- { role: foo, x: 1, y: 2 }
- { role: bar, x: 3, y: 4 }
...

Dependencies inherit variables as they are seen at the time of the
dependency inclusion. For example, if foo(x=1, y=2) has a dependency
on bar(x=3,z=4), then bar will have variables (x=3,y=2,z=4).

Different roles can have dependencies on the same role, and this
variable inheritence allows for the reuse of generic roles quite easily.
For example:

Role 'car' has the following dependencies:
dependencies:
  - { role: wheel, n: 1 }
  - { role: wheel, n: 2 }
  - { role: wheel, n: 3 }
  - { role: wheel, n: 4 }

Role 'wheel' has the following dependencies:
dependencies:
- { role: tire }
- { role: brake }

The role 'car' is then used as follows:
- { role: car, type: honda }

And tasks/main.yml in each role simply contains the following:
- name: {{ type }} whatever {{ n }}
  command: echo ''

TASK: [honda tire 1]
TASK: [honda brake 1]
TASK: [honda wheel 1]
TASK: [honda tire 2]
TASK: [honda brake 2]
TASK: [honda wheel 2]
TASK: [honda tire 3]
TASK: [honda brake 3]
TASK: [honda wheel 3]
TASK: [honda tire 4]
TASK: [honda brake 4]
TASK: [honda wheel 4]
TASK: [I'm a honda]  <- (this is in roles/car/tasks/main.yml)
2013-08-15 09:29:51 -05:00
René Moser e8272e365d
implemented 'inventory_file' variable. Closes GH-3789. 2013-08-10 13:04:56 +02:00
James Cammarata ceff3b6ba3 Minor modification to set_fact with_items patch
Previous patch was reverted due to the fact that there was an issue
with the results not always being a dictionary (they're sometimes
a unicode string, ie. when the with_items is used with yum). This
minor change corrects that by checking for a dict object.
2013-08-09 07:52:14 -05:00
James Cammarata 8be2fc745b Revert "Check for ansible_facts in results for with_ tasks"
This reverts commit 1a4e6e415e.
2013-08-08 20:32:30 -05:00
Serge van Ginderachter 1a4e6e415e Check for ansible_facts in results for with_ tasks
that loop over a lookup plugin. Fixes #3704 and #3735
2013-08-08 12:30:32 -05:00
Michael DeHaan 4cbfe3be57 Merge pull request #3773 from cchurch/devel
Update callbacks used for async tasks
2013-08-06 13:32:53 -07:00
Michael DeHaan 99775176ff Merge pull request #3623 from ralph-tice/fix_3567_2
changed role path template to read all vars instead of just extra_vars
2013-08-06 13:26:59 -07:00
Chris Church 6ba4331161 Correctly check for failed status from an async task. Use runner_on_async_failed callback (instead of runner_on_failed) when an async task times out. Add runner_on_async_ok callback when a task is started in fire and forget mode. 2013-08-06 12:42:44 -04:00
Michael DeHaan 56a00e0667 Remove dead code. 2013-08-05 16:13:50 -04:00
Michael DeHaan dec43f7a2b PEP8 indent fix. 2013-08-03 14:54:37 -04:00
Stoned Elipot 841093921b Add extra module path early during playbook parsing.
This should fix issue #3668

Also prevent an extra module path to be added multiple times.
2013-07-28 18:47:26 +02:00
Ralph Tice 2383a8205c changed role path template to read all vars instead of just extra_vars 2013-07-22 09:59:26 -05:00
Michael DeHaan 88720516a1 Merge branch 'changed_when' of git://github.com/stoned/ansible into changed_when 2013-07-21 10:14:03 -04:00
Michael DeHaan f592340f7f Merge branch 'playbook-skip-tags' of git://github.com/dekked/ansible into skip_tags 2013-07-21 09:43:23 -04:00
Michael DeHaan bf70dfc1a0 When a role/include has a conditional, add that conditional ahead of any on the task, not behind, so it can short circuit. 2013-07-20 18:34:24 -04:00
Stoned Elipot e7a733a6be Quote pathnames of roles' tasks and handlers files so that _load_tasks() can tokenize them properly
With the help of AlejandroTrev's eagle eyes. Thanks !
2013-07-20 23:25:46 +02:00
Michael DeHaan 0f4229f6c4 Merge pull request #3462 from stoned/filtererror
Introduce exception AnsibleFilterError and use it in Jinja filters.  Ign...
2013-07-20 09:12:26 -07:00
Michael DeHaan c10c2cae4e Merge branch 'ansible_sudo_at_role_level' of git://github.com/jeromew/ansible into sudo_role 2013-07-20 11:05:38 -04:00
Michael DeHaan 7d2585caf7 Merge pull request #3577 from Tinche/extra-vars-in-playbook-includes
Enabled the use of extra vars in playbook file paths when including play...
2013-07-20 07:37:35 -07:00
Rodney Quillo a4e829c874 Allow roles to be interpolated from --extra-vars 2013-07-19 18:28:21 +08:00
jeromew de0bc96b70 Implement sudo/sudo_user at the include and role levels 2013-07-18 22:32:56 +00:00
Tin Tvrtkovic 4a732c1e9f Enabled the use of extra vars in playbook file paths when including playbooks from other playbooks. 2013-07-18 22:45:18 +02:00
Alan Descoins 04349ec362 Added --skip-tags option to ansible-playbook. 2013-07-16 19:43:58 -03:00
Stoned Elipot eb45f07ae3 Introduce 'changed_when' keyword to override a task's changed status with the evaluation of a Jinja2 expression 2013-07-14 21:07:45 +02:00
Stoned Elipot 2d88c70cd5 Introduce exception AnsibleFilterError and use it in Jinja filters. Ignore this exception when trying to find the name of a task for display (callback) purpose. 2013-07-07 19:18:32 +02:00
Ninety Thirty 7b1e87b62d Added flexible filename handling for main files
tasks, handlers, and vars main files can now be any of main, main.yml, or main.yaml
2013-06-20 22:03:17 -06:00
Michael DeHaan 010440dc47 Merge pull request #3114 from laggyluke/roles_combine_vars
Added basic support for hash_behaviour=merge in roles
2013-06-19 19:27:27 -07:00
Michael DeHaan d2721526de Small tweak, don't merge conditionals, just evaluate each in turn. 2013-06-19 21:18:05 -04:00
George Miroshnykov c642ba77ae Added basic support for hash_behaviour=merge in roles
Dict vars passed to roles are now properly merged
instead of simply overriding dict vars that are
coming from vars_files.
2013-06-19 09:14:20 +03:00
Michael DeHaan 132c89e681 Merge branch 'callbackinit' of git://github.com/sergevanginderachter/ansible into devel 2013-06-18 20:52:43 -04:00
David Golden d65f45f0b2 Expand sudo_user after variable merging
Previous commit c3659741 expanded sudo_user during task construction,
but this is too early as it does not pick up variables set during
the play.

This commit moves sudo_user expansion to the runner after variables
have been merged.
2013-06-14 09:59:31 -04:00
Serge van Ginderachter 2a7f9df109 add support for callback_plugins/ relative to playbook 2013-06-12 23:54:00 +02:00
Chris Church 3f17a39238 Set current play/task to None for callback context when finished running the current play/task. 2013-06-09 12:17:57 -04:00
Kent Frazier 4c6583bd00 Fix bug with include-level vars and sudo_user.
If a variable was provided for an include, in either of these ways:

    ---
    - hosts: all
      tasks:
      - include: included.yml param=www-data
      - include: included.yml
        vars:
          param: www-data

and then that param was used as the value of sudo_user in the included
tasks:

    ---
    - name: do something as a parameterized sudo_user
      command: whoami
      sudo: yes
      sudo_user: $param

you would receive a "failed to parse: usage: sudo" error back and the
command would not execute.

This seemed to be due to a missing call to template.template somewhere,
because the final value being passed through ssh was still `$param`.
After some digging, the issue seems to instead have been a problem with
providing the wrong context to the template for expansion. Inside the
`Task` logic, it was passing `play.vars` as the context, where
`module_vars` seemed more appropriate. After replacing it, my test case
above ran without issue. There was a comment above suggesting that the
template call might be unnecessary, but removing it made the original
error return, since it is not getting escaped later down the line. I
removed the comment since it was inaccurate.

I tried to actually incorporate my test case above into the test suite
as a regression test, but was unable to figure out how to structure it.
The existing test infrastructure seemed to only be testing for correct
number of counts in things (ok vs. changed, etc.), without regard for
whether the content generated by the command is correct. If there is an
example of a test similar to this one (where I would want to check the
JSON generated to make sure sudo_user had been converted), please let me
know and I will be happy to submit an additional patch.
2013-05-23 00:05:11 -05:00
Tim Habermaas 4d24faeeb1 Fix grammatical error in error message 2013-05-13 13:22:57 +02:00
Michael DeHaan 7117ca5395 Allow modules in a "./library" directory to be referenced by their shortforms "modulename:" instead of just "action: modulename" 2013-04-28 21:05:19 -04:00
Michael DeHaan a81089231e Register skipped tasks so we can at least check their changed/not-changed status. 2013-04-28 10:13:58 -04:00
Stoned Elipot 75b51f79b4 Add module path library/ if it exists in role directory 2013-04-27 18:43:56 +02:00
Michael DeHaan 75cf5c985b Allow playbook tags to be comma seperated strings as well as lists 2013-04-27 12:29:32 -04:00
Matt Coddington c83c534a7d Search for roles in the roles subdir first. Throw an error when no role .yml files are found. 2013-04-25 22:40:04 -04:00
Michael DeHaan 5af271911b Fix duplicate handler notification issue in 1.2 devel 2013-04-25 21:24:15 -04:00
Michael DeHaan 21fe750cef Flush handlers before pre and post task sections change, but not between task and roles, as this seems
to be confusing to people (and not usually neccessary)
2013-04-24 22:28:06 -04:00
Michael DeHaan 6fdfbb1a34 Improve variable smushing so it only has to be done in one place. This is related to shlex.split being called
on untemplated variables in some rare cases.
2013-04-24 22:00:40 -04:00
Michael DeHaan 6c778acd91 Smush the braces in various places (hey, that rhymes) to avoid undo key=value splitting surprises
in new template system.
2013-04-22 22:05:06 -04:00
Michael DeHaan 3e0c33c1fa Empty plays should still gather facts 2013-04-21 17:35:09 -04:00
Michael DeHaan b08181e9b4 Merge pull request #2731 from stoned/flush_handlers-cleanup
handlers must be run once
2013-04-21 14:14:04 -07:00
Michael DeHaan 08324cb5d7 Allow play tagging in context of new meta-tasks. 2013-04-21 17:12:12 -04:00
Stoned Elipot 747c7f0dff handlers must be run once
so remove all occurences of each host from the handlers notified by
lists
2013-04-21 17:23:13 +02:00
Michael DeHaan 32fb6c807c Allow handlers to run in between pre_tasks, roles, tasks, and post_tasks. 2013-04-20 18:03:03 -04:00
Michael DeHaan 37789a852a Rename set_up and tear_down to pre_tasks and post_tasks 2013-04-20 16:19:01 -04:00
Michael DeHaan d7623d1f91 Added a 'set_up' and 'tear_down' which are like tasks, but execute before and after roles. 2013-04-20 16:07:06 -04:00
Michael DeHaan 53ac0bbec2 Instantiate callback plugins only once so we can set play/task objects on them and they'll stick. 2013-04-20 09:09:35 -04:00
Michael DeHaan d8bf87b008 (A) include errors in inventory scripts should they occur.
(B) allow registration with ignore_errors: True
2013-04-17 22:27:00 -04:00
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
2013-04-16 20:06:06 -04:00
Michael DeHaan 0944e7d56a Make less template calls on playbook objects. 2013-04-12 21:48:01 -04:00
Michael DeHaan 44a9352338 Also template handlers only at the end. 2013-04-12 20:32:35 -04:00
Michael DeHaan e7f5186dec Merge pull request #2623 from willthames/when_set_bug
Prevent premature variable substitution in tasks
2013-04-12 17:19:25 -07:00
Michael DeHaan 3ab0ed5fd4 Allow 'when' and 'with_items' to be applied to roles. 2013-04-12 19:02:56 -04:00
willthames 377bc31311 Prevent premature substitution of variables into tasks
As documented in #2623, early variable substitution causes when_
tests to fail and possibly other side effects.

I can see the reason for this early substitution, likely introduced
in 1dfe60a6, to allow many playbook parameters to be templated.
This is a valid goal, but the recursive nature of the utils.template
function means that it goes too far.

At this point removing tasks from the list of parameters to be
substituted seems sufficient to make my tests pass. It may be the
case that other parameters should be excluded, but I suspect not.

Adding a test case. I would prefer to analyse not just the aggregate
statistics but also whether the results are as expected - I can't
see an easy way to do that with the available callbacks at present.
2013-04-12 09:17:03 +10:00
Michael DeHaan 7931597a6a Fix template call. 2013-04-11 12:15:13 -04:00
Michael DeHaan b09ef21ec9 Add code to flag legacy templating like $foo.{bar} as deprecated in favor of Jinja2 {{ foo.bar }} so we
can remove the legacy system at a later date.
2013-04-10 17:52:35 -04:00
Michael DeHaan 29209c4913 Style fixes so "make pep8" is clean. 2013-04-10 16:37:49 -04:00
Michael DeHaan c5d9823467 Fix some items related to playbook includes and indentation. 2013-04-10 15:04:41 -04:00
Michael DeHaan 290780d13f Playbook + with_items was an undocumented feature that was causing problems because it would
evaluate and replace '$item' with ''.  Really it doesn't make sense to include multiple playbooks
via a loop variable, as you can do this with task + with_items already (and it's a simpler code
path).  Given this is undocumented, this removes that feature, and we'll consider next how to
also add 'with_items' support directly to roles.
2013-04-09 20:13:55 -04:00
Michael DeHaan c64f19dc5f Don't set the item variable as eager template replacement will over-replace the variable as an empty string. 2013-04-09 19:57:53 -04:00
willthames 9d87733f98 Test case and fix for shlex.split unicode bug
When operating on a unicode string in python 2.6, shlex.split returns
a result that does not work with the file constructor.

To reproduce this requires a task include that is templated (this is
because the templated string is a unicode result, whereas a non-
templated string is a non-unicode string)

    [will@centos6.3] $ python
    Python 2.6.6 (r266:84292, Sep 11 2012, 08:34:23)
    [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import shlex
    >>> shlex.split(u'abc')
    ['a\x00\x00\x00b\x00\x00\x00c\x00\x00\x00']

    [will@fedora17] $ python
    Python 2.7.3 (default, Jul 24 2012, 10:05:38)
    [GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import shlex
    >>> shlex.split(u'abc')
    ['abc']

The proposed fix (coercing the include parameters to string before the
shlex.split) may not be ideal but it does fix the bug for my test case.
2013-04-08 14:47:43 +10:00
Michael DeHaan 61f2668b0a Don't include the '.yml' in the path to the retry files. 2013-04-08 12:38:05 -04:00
Michael DeHaan 0d530f3bf0 Change the retry logic to write a limit file, able to source limit from files by indicating with @filename 2013-04-08 12:36:01 -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
Stoned Elipot 1ed54b9b3a when: condition support for tasks include 2013-04-07 00:43:39 +02:00
Michael DeHaan fffb1a0a9d Loose tasks not in roles get executed after roles. 2013-04-06 18:36:25 -04:00
Michael DeHaan f044fc344b When using roles, or other includes, the path to DWIM inside is the path of the task include
file.
2013-04-06 18:32:36 -04:00
Michael DeHaan 5c4ed72571 Demo of parameterized roles! 2013-04-06 12:51:17 -04:00
Michael DeHaan f308194b9a Added examples of how roles work! 2013-04-06 12:35:35 -04:00
Michael DeHaan 892484812e Much requested feature -- allows relative imports of content within roles or relative to any task or handler include (../templates for template ../files for copy) 2013-04-06 12:13:04 -04:00
Michael DeHaan 95f30f0def Complete streamlining of vars handling in playbooks and how those are templated to avoid
repeat template calls at playbook intialization time.
2013-04-06 10:45:09 -04:00