Skip to content

'ansible_user' is undefined #23530

Description

@mhristof
ISSUE TYPE
  • Bug Report
COMPONENT NAME

ansible

ANSIBLE VERSION
ansible 2.3.0.0
  config file =
  configured module search path = Default w/o overrides
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
CONFIGURATION

vanilla vagrant box, ubuntu/xenial64

OS / ENVIRONMENT

Only tested ubuntu/xenial64

SUMMARY

ansible_user seems to be undefined.

STEPS TO REPRODUCE

Just fire up a vagrant box, install ansible via pip and check the ansible_user

ubuntu@ubuntu-xenial:~$ pip install ansible
Collecting ansible
  Downloading ansible-2.3.0.0.tar.gz (4.3MB)
    100% |████████████████████████████████| 4.3MB 320kB/s
Collecting jinja2 (from ansible)
  Using cached Jinja2-2.9.6-py2.py3-none-any.whl
Collecting PyYAML (from ansible)
Collecting paramiko (from ansible)
  Using cached paramiko-2.1.2-py2.py3-none-any.whl
Collecting pycrypto>=2.6 (from ansible)
Collecting setuptools (from ansible)
  Using cached setuptools-34.4.1-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from jinja2->ansible)
Collecting pyasn1>=0.1.7 (from paramiko->ansible)
  Using cached pyasn1-0.2.3-py2.py3-none-any.whl
Collecting cryptography>=1.1 (from paramiko->ansible)
Collecting appdirs>=1.4.0 (from setuptools->ansible)
  Using cached appdirs-1.4.3-py2.py3-none-any.whl
Collecting packaging>=16.8 (from setuptools->ansible)
  Using cached packaging-16.8-py2.py3-none-any.whl
Collecting six>=1.6.0 (from setuptools->ansible)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting ipaddress (from cryptography>=1.1->paramiko->ansible)
  Using cached ipaddress-1.0.18-py2-none-any.whl
Collecting idna>=2.1 (from cryptography>=1.1->paramiko->ansible)
  Using cached idna-2.5-py2.py3-none-any.whl
Collecting asn1crypto>=0.21.0 (from cryptography>=1.1->paramiko->ansible)
  Using cached asn1crypto-0.22.0-py2.py3-none-any.whl
Collecting enum34 (from cryptography>=1.1->paramiko->ansible)
  Using cached enum34-1.1.6-py2-none-any.whl
Collecting cffi>=1.4.1 (from cryptography>=1.1->paramiko->ansible)
  Using cached cffi-1.10.0-cp27-cp27mu-manylinux1_x86_64.whl
Collecting pyparsing (from packaging>=16.8->setuptools->ansible)
  Using cached pyparsing-2.2.0-py2.py3-none-any.whl
Collecting pycparser (from cffi>=1.4.1->cryptography>=1.1->paramiko->ansible)
Building wheels for collected packages: ansible
  Running setup.py bdist_wheel for ansible ... done
  Stored in directory: /home/ubuntu/.cache/pip/wheels/9e/36/1f/9281addf43ee457e2847b021ba41a5641de9c7f7f1aa68a5d5
Successfully built ansible
Installing collected packages: MarkupSafe, jinja2, PyYAML, pyasn1, appdirs, pyparsing, six, packaging, setuptools, ipaddress, idna, asn1crypto, enum34, pycparser, cffi, cryptography, paramiko, pycrypto, ansible
Successfully installed MarkupSafe-1.0 PyYAML-3.12 ansible-2.2.0.0 appdirs-1.4.3 asn1crypto-0.22.0 cffi-1.10.0 cryptography-1.8.1 enum34-1.1.6 idna-2.5 ipaddress-1.0.18 jinja2-2.9.6 packaging-16.8 paramiko-2.1.2 pyasn1-0.2.3 pycparser-2.17 pycrypto-2.6.1 pyparsing-2.2.0 setuptools-34.4.1 six-1.10.0
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
ubuntu@ubuntu-xenial:~$ ansible all -i 'localhost, ' -c local -m debug -a 'var=ansible_user'
localhost | SUCCESS => {
    "ansible_user": "VARIABLE IS NOT DEFINED!",
    "changed": false
}
EXPECTED RESULTS
localhost | SUCCESS => {
    "ansible_user": "ubuntu"
}
ACTUAL RESULTS
localhost | SUCCESS => {
    "ansible_user": "VARIABLE IS NOT DEFINED!",
    "changed": false
}

This works on 2.2.0.0

ubuntu@ubuntu-xenial:~$ ansible all -i 'localhost, ' -c local -m debug -a 'var=ansible_user'
localhost | SUCCESS => {
    "ansible_user": "VARIABLE IS NOT DEFINED!",
    "changed": false
}
ubuntu@ubuntu-xenial:~$ pip install ansible==2.2.0.0
Collecting ansible==2.2.0.0
Collecting PyYAML (from ansible==2.2.0.0)
Collecting setuptools (from ansible==2.2.0.0)
  Using cached setuptools-34.4.1-py2.py3-none-any.whl
Collecting jinja2 (from ansible==2.2.0.0)
  Using cached Jinja2-2.9.6-py2.py3-none-any.whl
Collecting paramiko (from ansible==2.2.0.0)
  Using cached paramiko-2.1.2-py2.py3-none-any.whl
Collecting pycrypto>=2.6 (from ansible==2.2.0.0)
Collecting appdirs>=1.4.0 (from setuptools->ansible==2.2.0.0)
  Using cached appdirs-1.4.3-py2.py3-none-any.whl
Collecting packaging>=16.8 (from setuptools->ansible==2.2.0.0)
  Using cached packaging-16.8-py2.py3-none-any.whl
Collecting six>=1.6.0 (from setuptools->ansible==2.2.0.0)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from jinja2->ansible==2.2.0.0)
Collecting pyasn1>=0.1.7 (from paramiko->ansible==2.2.0.0)
  Using cached pyasn1-0.2.3-py2.py3-none-any.whl
Collecting cryptography>=1.1 (from paramiko->ansible==2.2.0.0)
Collecting pyparsing (from packaging>=16.8->setuptools->ansible==2.2.0.0)
  Using cached pyparsing-2.2.0-py2.py3-none-any.whl
Collecting ipaddress (from cryptography>=1.1->paramiko->ansible==2.2.0.0)
  Using cached ipaddress-1.0.18-py2-none-any.whl
Collecting idna>=2.1 (from cryptography>=1.1->paramiko->ansible==2.2.0.0)
  Using cached idna-2.5-py2.py3-none-any.whl
Collecting asn1crypto>=0.21.0 (from cryptography>=1.1->paramiko->ansible==2.2.0.0)
  Using cached asn1crypto-0.22.0-py2.py3-none-any.whl
Collecting enum34 (from cryptography>=1.1->paramiko->ansible==2.2.0.0)
  Using cached enum34-1.1.6-py2-none-any.whl
Collecting cffi>=1.4.1 (from cryptography>=1.1->paramiko->ansible==2.2.0.0)
  Using cached cffi-1.10.0-cp27-cp27mu-manylinux1_x86_64.whl
Collecting pycparser (from cffi>=1.4.1->cryptography>=1.1->paramiko->ansible==2.2.0.0)
Installing collected packages: PyYAML, appdirs, pyparsing, six, packaging, setuptools, MarkupSafe, jinja2, pyasn1, ipaddress, idna, asn1crypto, enum34, pycparser, cffi, cryptography, paramiko, pycrypto, ansible
Successfully installed MarkupSafe-1.0 PyYAML-3.12 ansible-2.2.0.0 appdirs-1.4.3 asn1crypto-0.22.0 cffi-1.10.0 cryptography-1.8.1 enum34-1.1.6 idna-2.5 ipaddress-1.0.18 jinja2-2.9.6 packaging-16.8 paramiko-2.1.2 pyasn1-0.2.3 pycparser-2.17 pycrypto-2.6.1 pyparsing-2.2.0 setuptools-34.4.1 six-1.10.0
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
ubuntu@ubuntu-xenial:~$ ansible all -i 'localhost, ' -c local -m debug -a 'var=ansible_user'
localhost | SUCCESS => {
    "ansible_user": "ubuntu"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects_2.3This issue/PR affects Ansible v2.3bugThis issue/PR relates to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions