# Buggy code
def do_var_prompt(
    cls,
    varname,
    private=True,
    prompt=None,
    encrypt=None,
    confirm=False,
    salt_size=None,
    salt=None,
    default=None,
):
    result = None
    if sys.__stdin__.isatty():
        do_prompt = cls.prompt

        if prompt and default is not None:
            msg = "%s [%s]: " % (prompt, default)
        elif prompt:
            msg = "%s: " % prompt
        else:
            msg = "input for %s: " % varname

        if confirm:
            while True:
                result = do_prompt(msg, private)
                second = do_prompt("confirm " + msg, private)
                if result == second:
                    break
                display.display("***** VALUES ENTERED DO NOT MATCH ****")
        else:
            result = do_prompt(msg, private)
    else:
        result = None
        display.warning("Not prompting as we are not in interactive mode")

    # if result is false and default is not None
    if not result and default is not None:
        result = default

    if encrypt:
        # Circular import because encrypt needs a display class
        from ansible.utils.encrypt import do_encrypt

        result = do_encrypt(result, encrypt, salt_size, salt)

    # handle utf-8 chars
    result = to_unicode(result, errors="strict")
    return result


# Traceback (NameError)
Unexpected Exception: global name 'display' is not defined
the full traceback was:

Traceback (most recent call last):
File "/usr/bin/ansible-playbook", line 85, in <module>
sys.exit(cli.run())
File "/usr/lib/pymodules/python2.7/ansible/cli/playbook.py", line 150, in run
results = pbex.run()
File "/usr/lib/pymodules/python2.7/ansible/executor/playbook_executor.py", line 117, in run
play.vars[vname] = display.do_var_prompt(vname, private, prompt, encrypt, confirm, salt_size, salt, default)
File "/usr/lib/pymodules/python2.7/ansible/utils/display.py", line 303, in do_var_prompt
display.warning("Not prompting as we are not in interactive mode")
NameError: global name 'display' is not defined

# Fixed code
def do_var_prompt(
    self,
    varname,
    private=True,
    prompt=None,
    encrypt=None,
    confirm=False,
    salt_size=None,
    salt=None,
    default=None,
):
    result = None
    if sys.__stdin__.isatty():
        do_prompt = self.prompt

        if prompt and default is not None:
            msg = "%s [%s]: " % (prompt, default)
        elif prompt:
            msg = "%s: " % prompt
        else:
            msg = "input for %s: " % varname

        if confirm:
            while True:
                result = do_prompt(msg, private)
                second = do_prompt("confirm " + msg, private)
                if result == second:
                    break
                self.display("***** VALUES ENTERED DO NOT MATCH ****")
        else:
            result = do_prompt(msg, private)
    else:
        result = None
        self.warning("Not prompting as we are not in interactive mode")

    # if result is false and default is not None
    if not result and default is not None:
        result = default

    if encrypt:
        # Circular import because encrypt needs a display class
        from ansible.utils.encrypt import do_encrypt

        result = do_encrypt(result, encrypt, salt_size, salt)

    # handle utf-8 chars
    result = to_unicode(result, errors="strict")
    return result