Skip to content

two random password lookups in same task return same value #34144

Closed
@richlv

Description

@richlv
ISSUE TYPE
  • Bug Report
COMPONENT NAME

lookups

ANSIBLE VERSION
2.3.0.0, 2.4.1.0
CONFIGURATION

no custom config

OS / ENVIRONMENT

Linux

SUMMARY

two consecutive facts from password lookup with same length get identical values.
separate tasks or different length result in different values, as expected.

STEPS TO REPRODUCE
- name: Set random passwords for clusters
  set_fact:
    password1: "{{ lookup('password', '/dev/null length=20') }}"
    password2: "{{ lookup('password', '/dev/null length=20') }}"
  delegate_to: localhost
  delegate_facts: True
- debug:
    msg: "{{hostvars['localhost'].password1}} {{hostvars['localhost'].password2}}"
EXPECTED RESULTS

two different values

ACTUAL RESULTS

two identical values

changing length for one of these, or using separate tasks, gives different values.

http://docs.ansible.com/ansible/latest/playbooks_lookups.html#the-password-lookup says "A special case is using /dev/null as a path. The password lookup will generate a new random password each time", thus the current behaviour is at least confusing and unexpected.

from irc :

<larsks> Richlv: Whatever is happening seems to be happening at a higher level than the password lookup plugin: as far as I can tell, it's only ever getting called once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects_2.3This issue/PR affects Ansible v2.3bugThis issue/PR relates to a bug.has_prThis issue has an associated PR.support:coreThis issue/PR relates to code supported by the Ansible Engineering Team.testThis PR relates to tests.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions