Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment on task level doesn't override play level definition when used with loops #32685

Closed
msoltyspl opened this issue Nov 8, 2017 · 1 comment · Fixed by #32796
Closed
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@msoltyspl
Copy link

For example, the following yaml:

  environment:
    str: "play level"
  tasks:
    - name: test 1
      command: "/bin/echo $str"
      environment:
        str: "task level"
    - name: test 2
      command: "/bin/echo $str"
      with_items: [ 1, 2, 3]
      environment:
        str: "task level"

And execute: ansible-playbook bug.yml -v

Task 'test 1' will have 'task level' in stdout
Task 'test 2' will loop 3 times with 'play level' in stdout

IF environment is not defined on play-level, 'test 2' will use the task-level setting.


TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [localhost]

TASK [test 1] *************************************************************************************************************************************************************
changed: [localhost] => {"changed": true, "cmd": ["/bin/echo", "$str"], "delta": "0:00:00.001448", "end": "2017-11-08 15:36:32.769761", "failed": false, "rc": 0, "start": "2017-11-08 15:36:32.768313", "stderr": "", "stderr_lines": [], "stdout": "task level", "stdout_lines": ["task level"]}

TASK [test 2] *************************************************************************************************************************************************************
changed: [localhost] => (item=1) => {"changed": true, "cmd": ["/bin/echo", "$str"], "delta": "0:00:00.001317", "end": "2017-11-08 15:36:32.971494", "failed": false, "item": 1, "rc": 0, "start": "2017-11-08 15:36:32.970177", "stderr": "", "stderr_lines": [], "stdout": "play level", "stdout_lines": ["play level"]}
changed: [localhost] => (item=2) => {"changed": true, "cmd": ["/bin/echo", "$str"], "delta": "0:00:01.002670", "end": "2017-11-08 15:36:34.150920", "failed": false, "item": 2, "rc": 0, "start": "2017-11-08 15:36:33.148250", "stderr": "", "stderr_lines": [], "stdout": "play level", "stdout_lines": ["play level"]}
changed: [localhost] => (item=3) => {"changed": true, "cmd": ["/bin/echo", "$str"], "delta": "0:00:01.002600", "end": "2017-11-08 15:36:35.349230", "failed": false, "item": 3, "rc": 0, "start": "2017-11-08 15:36:34.346630", "stderr": "", "stderr_lines": [], "stdout": "play level", "stdout_lines": ["play level"]}

PLAY RECAP ****************************************************************************************************************************************************************
localhost                  : ok=3    changed=2    unreachable=0    failed=0   
ISSUE TYPE
  • Bug Report
ANSIBLE VERSION
ansible 2.4.1.0
@ansibot
Copy link
Contributor

ansibot commented Nov 8, 2017

@msoltyspl Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information.

Here are the items we could not find in your description:

  • component name

Please set the description of this issue with this template:
https://raw.githubusercontent.com/ansible/ansible/devel/.github/ISSUE_TEMPLATE.md

click here for bot help

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bug_report needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Nov 8, 2017
@s-hertel s-hertel removed the needs_triage Needs a first human triage before being processed. label Nov 10, 2017
@bcoca bcoca changed the title [2.4.1] environment on task level doesn't override play level definition when used with loops Environment on task level doesn't override play level definition when used with loops Nov 23, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants