---
- name: "Initialze VARs"
  set_fact:
    tok_obj: {}
  tags:
    - harbor-configure-robots

- name: "DEBUG"
  debug:
    msg: "DEBUGGING - robot_token: {{ robot_token }}"
  when:
    - debug
    - harbor-configure-robots

- name: "Drop token_state from dict to avoid rejecting object by harbor API due to unknown field"
  set_fact:
    tok_obj: "{{ tok_obj | combine( { item.key: item.value } ) }}"
  when: item.key not in ['token_state']
  with_dict: "{{ robot_token }}"
  tags:
    - harbor-configure-robots

- name:
  include_tasks: configure_robot_tokens_crud.yml
  vars:
    token_state: "{{ robot_token.token_state | default('present') }}"
    token_object: "{{ tok_obj }}"
  tags:
    - harbor-configure-robots
