Hi I have a usecase where i have a string “dumb”. During the execution of play i create a new string by using a random filter and this string should be any of [‘duma’,‘dumc’,‘dumd’] but not “dumb”. So i tried to use do until loop as follows:
- hosts: local
connection: local
gather_facts: false
vars:
old_string: ‘dumb’
tasks:
-
name: Generate random number
set_fact: “new_string=dum{{ [‘a’,‘b’,‘c’,‘d’] |random }}”
register: e
until: e != old_string -
name: Fail if old number and new number are same
action: fail
when: new_string == old_string
So as far as i am concerned the check at the until step should avoid allowing the new_string to be “dumb”, but its not doing as expected. Any suggestions ?