---
- name: 0. Check Kubernetes Pods (ALL)
  command: "{{ role_path }}/files/k8s_status {{ cmoa_namespace }}"

- name: 1. IP Setting reset
  command: "{{ role_path }}/files/ip_change {{ansible_default_ipv4.address}} {{before_ip}} {{ role_path }}/files"

- name: 2. CloudMOA Version reset
  command: "{{ role_path }}/files/rel_change {{ cmoa_version }} {{ before_version }} {{ role_path }}/files"

- debug:
    msg: 
      - =======================================================================================
      - "## Keycloak WEB"
      - keycloak URL = http://{{ ansible_default_ipv4.address }}:31082
      - ---------------------------------------------------------------------------------------
      - "## Keycloak Login Theme Setting"
      - "## WEB > Realm Settings > Themes > Login Theme"
      - "  > CloudMOA_V2"
      - ---------------------------------------------------------------------------------------
      - "## CloudMOA WEB "
      - CloudMOA Jaeger = http://{{ ansible_default_ipv4.address }}:31080
      - CloudMOA JSPD   = http://{{ ansible_default_ipv4.address }}:31084
      - =======================================================================================

#- name: Node add Label (worker1)
#  shell: kubectl get node "{{ item }}" --show-labels
#  register: worker1
#  with_items: 
#  - "{{ ansible_hostname }}"
#  #when: ansible_hostname in groups.worker1
#
#- name: Node add Label (worker2)
#  shell: kubectl get node "{{ item }}" --show-labels
#  register: worker2
#  with_items: 
#  - "{{ ansible_hostname }}"
#  #when: ansible_hostname in groups.worker2
#
#
#- name: debug
#  debug:
#    msg: "{{item}}"
#  with_items:
#  - "{{ worker1.stdout }}"
#  - "{{ worker2.stdout }}"

#- name: Iterate over pod names and delete the filtered ones
#  #debug:
#  #  msg: "{{ item }}" 
#  kubernetes.core.k8s_cp:
#    namespace: imxc
#    pod: "{{ item }}"
#    remote_path: /tmp/postgres_insert_ddl.psql
#    local_path: "{{ role_path }}/files/03-ddl-dml/postgres/postgres_insert_ddl.psql"
#  with_items: "{{ pod_list.stdout_lines }}"
#  when: item is match('postgres')

#- name: Execute a command
#  kubernetes.core.k8s_exec:
#    namespace: imxc
#    pod: "{{ item }}"
#    command: bash -c "PGPASSWORD='eorbahrhkswp' && /usr/bin/psql -h 'localhost' -U 'admin' -d 'postgresdb' -f /tmp/postgres_insert_ddl.psql"
#  with_items: "{{ pod_list.stdout_lines }}"
#  when: item is match('postgres')
#
#- name: Iterate over pod names and delete the filtered ones
#  #debug:
#  #  msg: "{{ item }}" 
#  kubernetes.core.k8s_cp:
#    namespace: imxc
#    pod: "{{ item }}"
#    remote_path: /tmp/postgres_insert_dml.psql
#    local_path: "{{ role_path }}/files/03-ddl-dml/postgres/postgres_insert_dml.psql"
#  with_items: "{{ pod_list.stdout_lines }}"
#  when: item is match('postgres')
#
#- name: Execute a command
#  kubernetes.core.k8s_exec:
#    namespace: imxc
#    pod: "{{ item }}"
#    command: bash -c "PGPASSWORD='eorbahrhkswp' && /usr/bin/psql -h 'localhost' -U 'admin' -d 'postgresdb' -f /tmp/postgres_insert_dml.psql"
#  with_items: "{{ pod_list.stdout_lines }}"
#  when: item is match('postgres')
#  register: test
#
#- name: test
#  debug:
#    msg: "{{ test.stdout }}"
##- set_fact:
##    postgres_pod: "{{ postgres_pod2.stdout_lines is match('postgres') | default(postgres_pod2) }}"
#