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

Variables not interpolated in environment when using block #13123

Closed
aocole opened this issue Nov 10, 2015 · 6 comments
Closed

Variables not interpolated in environment when using block #13123

aocole opened this issue Nov 10, 2015 · 6 comments
Labels
bug This issue/PR relates to a bug.
Milestone

Comments

@aocole
Copy link

aocole commented Nov 10, 2015

Issue Type: Bug Report
Ansible Version:
ansible 2.0.0 (detached HEAD 76ae577519) last updated 2015/11/10 23:38:28 (GMT +000)
  lib/ansible/modules/core: (detached HEAD fde6ee15d6) last updated 2015/11/10 20:05:36 (GMT +000)
  lib/ansible/modules/extras: (detached HEAD 6cc43bbd56) last updated 2015/11/10 20:06:02 (GMT +000)
  config file = 
  configured module search path = Default w/o overrides
Ansible Configuration:

No changes

Environment:

Ubuntu 14.04.3

Summary:

When using an environment: section in a block, variables are not interpolated. This broke with commit 76ae577

Steps To Reproduce:
---
- name: Demonstrate variable interpolation in environment
  hosts: localhost
  connection: local
  gather_facts: false

  vars:
    foo: bar

  tasks:
  - block:
    - name: Print variable
      shell: "echo $baz"
      register: result
    - debug: var=result.stdout
    environment:
      baz: "{{ foo }}"
Expected Results:
ok: [localhost] => {
    "changed": false,
    "result.stdout": "bar"
}
Actual Results:
ok: [localhost] => {
    "changed": false,
    "result.stdout": "{# foo #}"
}
@aocole
Copy link
Author

aocole commented Nov 11, 2015

@jimi-c ^

@chrrrles
Copy link
Contributor

Hi aocole -- I ran this playbook on devel and got the expected output:


ok: [localhost] => {
    "changed": false, 
    "result.stdout": "bar"
}
 _____________________________ 

May you retry this using the latest devel?

@jimi-c jimi-c added this to the v2 milestone Nov 11, 2015
@aocole
Copy link
Author

aocole commented Nov 11, 2015

I have verified that the problem still exists on latest devel (see version below). Please note that it only occurs when using a block, as in my example playbook above.

ansible 2.0.0 (devel 1b7d3f2898) last updated 2015/11/11 17:50:21 (GMT +000)
  lib/ansible/modules/core: (detached HEAD 6e37f1dcef) last updated 2015/11/11 17:50:54 (GMT +000)
  lib/ansible/modules/extras: (detached HEAD 7d8dd6e210) last updated 2015/11/11 17:51:04 (GMT +000)
  config file = 
  configured module search path = Default w/o overrides

 [WARNING]: provided hosts list is empty, only localhost is available

 __________________________________________________________
< PLAY [Demonstrate variable interpolation in environment] >
 ----------------------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

 _______________________
< TASK [Print variable] >
 -----------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

changed: [localhost]
 ________________________________
< TASK [debug var=result.stdout] >
 --------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

ok: [localhost] => {
    "changed": false,
    "result.stdout": "{# foo #}"
}
 ____________
< PLAY RECAP >
 ------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

localhost                  : ok=2    changed=1    unreachable=0    failed=0

@jimi-c
Copy link
Member

jimi-c commented Nov 12, 2015

I'm able to reproduce this and am looking into it.

@wrouesnel
Copy link
Contributor

+1 - I've run into this with ansible devel head just today. Going back to commit 2e05304 fixes the problem.

@jimi-c jimi-c closed this as completed in 9b9fb51 Nov 17, 2015
@jimi-c
Copy link
Member

jimi-c commented Nov 17, 2015

Closing This Ticket

Hi!

We believe the above commit should resolve this problem for you. This will also be included in the next major release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved.

Thank you!

@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 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

5 participants