---
# Main Ansible Playbook for Undateable.me
# Usage: ansible-playbook -i inventory.yml site.yml

- name: Configure AMD EPYC Compute Instance
  hosts: amd_compute
  become: yes

  vars_prompt:
    - name: postgres_password
      prompt: "Enter PostgreSQL password"
      private: yes

    - name: redis_password
      prompt: "Enter Redis password (or press enter for no auth)"
      private: yes
      default: ""

  roles:
    - common
    - docker
    - database
    - redis

  post_tasks:
    - name: Display connection information
      debug:
        msg: |
          ============================================
          AMD EPYC Instance Configuration Complete!
          ============================================

          PostgreSQL:
            Host: {{ ansible_host }}
            Port: 5432
            Database: {{ postgres_db }}
            User: {{ postgres_user }}

          Redis:
            Host: {{ ansible_host }}
            Port: {{ redis_port }}

          To connect from Kubernetes, update your secrets:
            kubectl create secret generic db-credentials \
              --namespace=undateable \
              --from-literal=DB_HOST={{ ansible_host }} \
              --from-literal=DB_NAME={{ postgres_db }} \
              --from-literal=DB_USER={{ postgres_user }} \
              --from-literal=DB_PASS={{ postgres_password }} \
              --dry-run=client -o yaml | kubectl apply -f -
