josh
josh

Reputation: 45

Ansible loop not execute if same value

can i know in an Ansible loop is there a way not to execute repeated statement . Below is my code

vars.yml

type_of_fruit:
  - "lemon"
  - "orange"
  - "orange"
  - "pineapple"

main.yml

- name: Type of frutis
  debug:
    msg: "{{ item }}"
  loop: "{{ type_of_fruit }}"

Expected

"lemon"
"orange"
"pineapple"

Upvotes: 1

Views: 55

Answers (1)

Vladimir Botka
Vladimir Botka

Reputation: 68004

Filter the items, e.q.

    loop: "{{ type_of_fruit|unique }}"

Upvotes: 0

Related Questions