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

Loop label only renders first item when it uses based vars keywork variables #40474

Closed
juanvalino opened this issue May 21, 2018 · 2 comments
Closed
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@juanvalino
Copy link
Contributor

ISSUE TYPE
  • Bug Report
COMPONENT NAME

loop

ANSIBLE VERSION
ansible 2.5.2
  config file = /home/juanval/.ansible.cfg
  configured module search path = [u'/home/juanval/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/juanval/.local/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15 (default, May  9 2018, 11:18:37) [GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]
CONFIGURATION
ANSIBLE_SSH_ARGS(/home/juanval/.ansible.cfg) = -F /home/juanval/.ssh/config -o ControlMaster=auto -o ControlPersist=30m
ANSIBLE_SSH_CONTROL_PATH(/home/juanval/.ansible.cfg) = ~/.ssh/master-%%r@%%h:%%p
CACHE_PLUGIN(/home/juanval/.ansible.cfg) = memory
DEFAULT_ACTION_PLUGIN_PATH(/home/juanval/.ansible.cfg) = [u'/usr/share/ansible_plugins/action_plugins']
DEFAULT_CALLBACK_PLUGIN_PATH(/home/juanval/.ansible.cfg) = [u'/usr/share/ansible_plugins/callback_plugins']
DEFAULT_CONNECTION_PLUGIN_PATH(/home/juanval/.ansible.cfg) = [u'/usr/share/ansible_plugins/connection_plugins']
DEFAULT_FILTER_PLUGIN_PATH(/home/juanval/.ansible.cfg) = [u'/usr/share/ansible_plugins/filter_plugins']
DEFAULT_FORKS(/home/juanval/.ansible.cfg) = 5                                                                                                               
DEFAULT_GATHERING(/home/juanval/.ansible.cfg) = implicit                                                                                                    
DEFAULT_HOST_LIST(/home/juanval/.ansible.cfg) = [u'/home/juanval/srv/ansible/inventory']                                                                    
DEFAULT_LOG_PATH(/home/juanval/.ansible.cfg) = /home/juanval/.ansible/log/ansible.log                                                                       
DEFAULT_LOOKUP_PLUGIN_PATH(/home/juanval/.ansible.cfg) = [u'/usr/share/ansible_plugins/lookup_plugins']                                                     
DEFAULT_MANAGED_STR(/home/juanval/.ansible.cfg) = Ansible managed. Don't modify it directly.                                                                
DEFAULT_POLL_INTERVAL(/home/juanval/.ansible.cfg) = 15                                                                                                      
DEFAULT_ROLES_PATH(/home/juanval/.ansible.cfg) = [u'/home/juanval/srv/ansible/roles']
DEFAULT_TIMEOUT(/home/juanval/.ansible.cfg) = 10
DEFAULT_TRANSPORT(/home/juanval/.ansible.cfg) = smart
DEFAULT_VARS_PLUGIN_PATH(/home/juanval/.ansible.cfg) = [u'/usr/share/ansible_plugins/vars_plugins']
HOST_KEY_CHECKING(/home/juanval/.ansible.cfg) = False
INVENTORY_ENABLED(/home/juanval/.ansible.cfg) = ['host_list', 'script', 'yaml', 'ini']
OS / ENVIRONMENT

N/A

SUMMARY

When the label keyword of a loop uses variables defined in a vars block, and those variables points to attributes of the iteration item, the rendered output always shows to the first item of the sequence.

STEPS TO REPRODUCE
- name: bug use case
  hosts: localhost
  vars:
    my_list:
      - name: Luke
        surname: Skywalker

      - name: Darth
        surname: Vader

      - name: Han
        surname: Solo

    surname_var: "{{ item.surname }}"

  tasks:
    - debug: msg="item.name={{ item.name }} item.surname={{ item.surname }} surname_var={{ surname_var }}"
      loop: "{{ my_list }}"
      loop_control:
        label: "{{ item.name }} {{ surname_var }}"
EXPECTED RESULTS
PLAY [bug use case] *************************************************************

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

TASK [debug] ********************************************************************
ok: [localhost] => (item=Luke Skywalker) => {
    "msg": "item.name=Luke item.surname=Skywalker surname_var=Skywalker"
}
ok: [localhost] => (item=Darth Vader) => {
    "msg": "item.name=Darth item.surname=Vader surname_var=Vader"
}
ok: [localhost] => (item=Han Solo) => {
    "msg": "item.name=Han item.surname=Solo surname_var=Solo"
}

PLAY RECAP **********************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0  
ACTUAL RESULTS
PLAY [bug use case] *************************************************************

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

TASK [debug] ********************************************************************
ok: [localhost] => (item=Luke Skywalker) => {
    "msg": "item.name=Luke item.surname=Skywalker surname_var=Skywalker"
}
ok: [localhost] => (item=Darth Skywalker) => {
    "msg": "item.name=Darth item.surname=Vader surname_var=Vader"
}
ok: [localhost] => (item=Han Skywalker) => {
    "msg": "item.name=Han item.surname=Solo surname_var=Solo"
}

PLAY RECAP **********************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0  
@ansibot
Copy link
Contributor

ansibot commented May 21, 2018

Files identified in the description:
None

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. 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 May 21, 2018
@sivel
Copy link
Member

sivel commented May 21, 2018

Duplicate of #38899

@sivel sivel marked this as a duplicate of #38899 May 21, 2018
@sivel sivel closed this as completed May 21, 2018
@sivel sivel removed the needs_triage Needs a first human triage before being processed. label May 21, 2018
@ansible ansible locked and limited conversation to collaborators May 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

3 participants