---
- name: Verify
  hosts: k8s
  gather_facts: false

  vars:
    ansible_python_interpreter: '{{ ansible_playbook_python }}'
    deploy_dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/deploy"
    custom_resource: "{{ lookup('file', '/'.join([deploy_dir, 'crds/drupal_v1alpha1_drupal_cr.yaml'])) | from_yaml }}"

  tasks:
    - name: Get all StorageClass objects.
      k8s_info:
        api_version: v1
        kind: StorageClass
        namespace: '{{ default_namespace }}'
      register: storageclass
      delegate_to: localhost

    - name: Verify the custom EBS StorageClass is present.
      assert:
        that: "{{ 'kubernetes.io/aws-ebs' in storageclass | to_nice_json }}"

    - name: Get all namespaces.
      k8s_info:
        api_version: v1
        kind: Namespace
      register: all_namespaces
      delegate_to: localhost
