Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

vars

jinj2 templates

ANSIBLE VERSION

# ansible --version
ansible 1.9.6
configured module search path = ./library:$ANSIBLE_HOME/library

CONFIGURATION

# env | grep ANSIBLE_
ANSIBLE_INSTRUMENT_MODULES=true
ANSIBLE_HOST_KEY_CHECKING=false
ANSIBLE_SSH_ARGS=-F /root/.axion/ssh_config
ANSIBLE_INVENTORY=/root/vFusion/ansible-systems/inventory/fusion/metapod/proxmox/
ANSIBLE_VAULT_PASSWORD_FILE=/root/.config/ansible-systems/vault-proxmox.pass
ANSIBLE_VAR_DEFAULTS_GLOB=/root/vFusion/ansible-systems/inventory/fusion/metapod/defaults/*.yml
ANSIBLE_VARS_PLUGINS=/root/vFusion/ansible-systems/plugins/vars

OS / ENVIRONMENT

Red Hat Enterprise Linux Server release 7.3 (Maipo)

SUMMARY

Duplicate variable names causes recursive loop in template string

STEPS TO REPRODUCE

Below is bug.yml:

- name: Task that causes recursive loop :)
hosts: all
vars:
hello: "{{ hello }}"

Below is the bug 😄.

# ansible-playbook -i my_inventory bug.yml
[WARNING]: non fatal error while trying to template play variables: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: recursive loop detected in template string: {{
hello }}

Fri 27 Jan 14:58:52.707379:
PLAY [Template string that causes recursive loop :)] **************************

PLAY RECAP ********************************************************************

Total elapsed wallclock time: 0.110759019852

EXPECTED RESULTS

No recursive loop in output:

# ansible-playbook -i my_inventory bug.yml

Fri 27 Jan 14:58:52.707379:
PLAY [Template string that causes recursive loop :)] **************************

PLAY RECAP ********************************************************************

Total elapsed wallclock time: 0.110759019852

ACTUAL RESULTS

# ansible-playbook -i my_inventory bug.yml
[WARNING]: non fatal error while trying to template play variables: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: Failed to template {{ hello }}: Failed to
template {{ hello }}: Failed to template {{ hello }}: Failed to template {{
hello }}: Failed to template {{ hello }}: Failed to template {{ hello }}:
Failed to template {{ hello }}: recursive loop detected in template string: {{
hello }}

Fri 27 Jan 14:58:52.707379:
PLAY [Template string that causes recursive loop :)] **************************

PLAY RECAP ********************************************************************

Total elapsed wallclock time: 0.110759019852

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

script

ANSIBLE VERSION

Latest unstable version:

ansible 2.5.0 (devel 1068aa3ce7) last updated 2017/11/01 11:34:22 (GMT +200)
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/actionmystique/Ansible/git-yang-networkop/ansible-101/library']
ansible python module location = /home/actionmystique/src/Ansible/git-ansible/lib/ansible
executable location = /home/actionmystique/src/Ansible/git-ansible/bin/ansible
python version = 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170118]

CONFIGURATION

inventory = ./hosts
library = /home/actionmystique/Ansible/git-yang-networkop/ansible-101/library
forks = 1000
gathering = explicit
gather_timeout = 30
roles_path = /home/actionmystique/Ansible/Roles/roles
private_role_vars = yes
hash_behaviour = merge
log_path = /var/log/ansible.log
retry_files_enabled = False
show_custom_stats = True
timeout = 120
pipelining = True
connect_timeout = 240
connect_retry_timeout = 180

OS / ENVIRONMENT

host: Ubuntu 17.04 4.10

targets:

NX-OSv 9k 7.0(3)I6(1)

paramiko: 2.0.6

SUMMARY

When the script module is run locally (no ssh) and returns an error, stderr is present but not stderr_lines.

STEPS TO REPRODUCE

Role:

- name: Checking for duplicate keys in json answer
local_action: script /home/actionmystique/Bash/Scripts/json-check-duplicate-keys.sh '"{{ uri_return.content }}"' 'false'
register: json_check_duplicate_keys
failed_when: json_check_duplicate_keys.stderr

EXPECTED RESULTS

stderr_lines

ACTUAL RESULTS:

fatal: [NX_OSv_9k_Spine_31 -> localhost]: FAILED! => {
"changed": true,
"failed_when_result": true,
"msg": "non-zero return code",
"rc": 2,
"stderr": "Checking /tmp/data.json...\n----\nDuplicate keys found in /tmp/data.json:\n* subinterface\n* subinterface\n* subinterface\n* subinterface\n* subinterface\n* subinterface\n* subinterface\n* subinterface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n* interface\n/root/.ansible/tmp/ansible-tmp-1509543791.83-202226908799664/json-check-duplicate-keys.sh: line 99: exit: return_code: numeric argument required\n",
"stdout": "-------------------------------------------------------------------\nChecking for duplicate keys in json file /tmp/fixed_json_data.json\n-------------------------------------------------------------------\n",
"stdout_lines": [
"-------------------------------------------------------------------",
"Checking for duplicate keys in json file /tmp/fixed_json_data.json",
"-------------------------------------------------------------------"
]
}