I'm trying to generate random numbers in ansible while the generated number, exists in a list of numbers.
Let's suppose that my list have this values.
list = [1, 3, 5, 8, 9, 10]
I'm using the module set_fact
like this.
- set_fact:
value: ""
until: value not in list
The value generated using the random rule always generate the number 1
or 10
, I've used the module debug
like the code below and it always generate different numbers.
- debug:
msg: ""
My problem here is, how can I generate random number in a certain interval, like the one above (1,10) and how can I keep generating random numbers while the generated number exists in the list, when the generated number isn't in the list, i want to stop the loop and use this number for something.
Aucun commentaire:
Enregistrer un commentaire