---
- hosts: localhost
  gather_facts: no
  vars_files:
    - "{{demo}}/setup.yml"

  vars:
    controller_validate_certs: false
    default_components:
      - controller_notifications
    controller_notifications:
      - name: Telemetry
        organization: Default
        notification_type: webhook
        notification_configuration:
          url: https://script.google.com/macros/s/AKfycbxSjCQ36cMWfWxG0dAjkL-gz-heiBcfLXFOOd0FV34JKXnagsCoAbOIa3q3Yr0YG91mHQ/exec
          http_method: POST

  tasks:
    - name: Setup Components
      include_role:
        name: "redhat_cop.controller_configuration.{{ item }}"
      loop: "{{ controller_components }}"
      when:
        - default_components + configuration_components | d("") | length > 0

    - name: Log Demo
      ansible.builtin.uri:
        url: https://docs.google.com/forms/d/e/1FAIpQLSdIZ77YpETjEfGOoYlXtMnQiU-6M7QFlb2hJA4ujo25QYb2jw/formResponse
        method: POST
        body: "ifq&entry.1569353616={{ demo }} &entry.498055740={{ lookup('ansible.builtin.env', 'AWX_HOST') }}&sumbit=Submit"
      ignore_errors: true

    - name: Print Message
      debug:
        msg: "{{ user_message }}"
      when: user_message is defined
