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

lookup password module with path '/dev/null' returns empty string #22359

Closed
yabhinav opened this Issue Mar 7, 2017 · 2 comments

Comments

Projects
None yet
5 participants
@yabhinav

yabhinav commented Mar 7, 2017

ISSUE TYPE
  • Bug Report
COMPONENT NAME

lookup

ANSIBLE VERSION
[user@server ]$ ansible --version
ansible 2.2.1.0
  config file = /home/ansible.cfg
  configured module search path = ['./library']
CONFIGURATION
# some basic default values...
[defaults]
inventory       = ./inventory/hosts
ansible.verbose = "v"
library         = ./library
remote_tmp      = /tmp/$USER/.ansible
local_tmp       = /tmp/$USER/.ansible
pattern         = *
forks           = 5
poll_interval   = 15
transport       = smart
remote_port     = 22
module_lang     = C
scp_if_ssh      = True
gathering = implicit
roles_path    = ./roles
host_key_checking = False
sudo_user       = root
ask_sudo_pass   = False
ask_pass        = False
sudo_exe = sudo
timeout = 10
remote_user = root
log_path = ./ansible.log
module_name = shell
executable = /bin/bash

# set plugin path directories here, separate with colons
action_plugins     = ~/.ansible/plugins/action_plugins/:/usr/share/ansible_plugins/action_plugins:./action_plugins/
callback_plugins   = ~/.ansible/plugins/callback_plugins/:/usr/share/ansible_plugins/callback_plugins:./callback_plugins/
connection_plugins = ~/.ansible/plugins/connection_plugins/:/usr/share/ansible_plugins/connection_plugins:./connection_plugins/
lookup_plugins     = ~/.ansible/plugins/lookup_plugins/:/usr/share/ansible_plugins/lookup_plugins:./lookup_plugins/
vars_plugins       = ~/.ansible/plugins/vars_plugins/:/usr/share/ansible_plugins/vars_plugins:./vars_plugins/
filter_plugins     = ~/.ansible/plugins/filter_plugins/:/usr/share/ansible_plugins/filter_plugins:./filter_plugins/
nocows = 0
ANSIBLE_COW_SELECTION=random
http_user_agent = ansible-agent
fact_caching = memory

retry_files_save_path = ~/.ansible-retry

[privilege_escalation]
#become=True
become_method='dzdo'
#become_user='root'
#become_ask_pass=False
[ssh_connection]
control_path = ~/.ssh/ansible-%%r@%%h:%%p
[accelerate]
accelerate_port = 5099
accelerate_timeout = 30
accelerate_connect_timeout = 5.0
OS / ENVIRONMENT

Redhat Linux 6.5

SUMMARY

When using lookup-password module to generate a random password, as mentioned by documentation here using /dev/null should generate the password string , also verified in the module code that same thing is happening, but when running the same in a task an empty string is generated probably because the module is looking for /dev/null file and it is empty.

STEPS TO REPRODUCE
- debug: 
    msg: "{{ lookup('password', '/dev/null chars=ascii_letters length=15') }}"

- debug: 
    msg: "{{ lookup('password', '/dev/null') }}"
EXPECTED RESULTS
ok: [testlab] => {
    "msg": "trtretreteytreert2324sf"
}
ACTUAL RESULTS
ok: [testlab] => {
    "msg": ""
}

This issue might be due to the failure of the checks and the module is looking for password in /dev/null

if content is None or b_path == to_bytes('/dev/null'):

if changed and b_path != to_bytes('/dev/null'):
@Lujeni

This comment has been minimized.

Show comment
Hide comment
@Lujeni

Lujeni Mar 17, 2017

Contributor

Hello,

This bug seems fixed in the devel branch (6fae1d2).

Contributor

Lujeni commented Mar 17, 2017

Hello,

This bug seems fixed in the devel branch (6fae1d2).

@bcoca

This comment has been minimized.

Show comment
Hide comment
@bcoca

bcoca Mar 17, 2017

Member

closing as per above

Member

bcoca commented Mar 17, 2017

closing as per above

@bcoca bcoca closed this Mar 17, 2017

@ansibot ansibot added bug and removed bug_report labels Mar 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment