community.general/lib/ansible
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
..
callback_plugins update some of many copyright dates but we can just do this when editing each file, not super high priority 2013-02-16 15:32:01 -05:00
inventory don't parse subdirs in host/group_vars 2013-05-13 11:04:49 +02:00
playbook Fix bug with include-level vars and sudo_user. 2013-05-23 00:05:11 -05:00
runner Replace tab with spaces. 2013-05-19 19:26:30 -04:00
utils Prefer categorized modules to uncategorized, such that if someone does an install on top of old content 2013-05-19 20:09:44 -04:00
__init__.py Update release version. 2013-04-02 20:48:30 -04:00
callbacks.py If ansible is configured to use a log file but cannot write to it, exit, but don't traceback. 2013-05-19 20:05:04 -04:00
color.py Added a ANSIBLE_FORCE_COLOR env var, which forces the color output no matter what ncurses says. 2012-10-06 20:36:07 +02:00
constants.py More pep8 2013-05-11 17:26:06 -04:00
errors.py Add 'polite' YAML syntax validation and hinting. Closes #798 2012-08-07 18:24:47 -04:00
module_common.py Improve check mode reporting for directories and file modes. 2013-05-11 15:05:00 -04:00