Ansible: appending to a list conditionally

    - set_fact:
        items_list: "{{ items_list | default(['item1']) + [item] }}"
      loop:
        - "{{ (True and True) | ternary('item2', None) }}"
        - "{{ (True) | ternary('item3', None) }}"
      when: item
    - debug: var=items_list

or

     - set_fact:
         items_list: "{{ items_list | default(['item1']) + [item] }}"
       loop:
         - "item2"
         - "item3"
       when: >-
         (item == "item2" and True and True) or
         (item == "item3" and True)
     - debug: var=items_list