github.com/yashbhutwala/operator-sdk@v0.8.1/test/ansible-inventory/molecule/test-local/prepare.yml (about)

     1  ---
     2  - name: Prepare
     3    hosts: k8s
     4    gather_facts: no
     5    vars:
     6      kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}"
     7    tasks:
     8      - name: delete the kubeconfig if present
     9        file:
    10          path: '{{ kubeconfig }}'
    11          state: absent
    12        delegate_to: localhost
    13  
    14      - name: Fetch the kubeconfig
    15        fetch:
    16          dest: '{{ kubeconfig }}'
    17          flat: yes
    18          src: /root/.kube/config
    19  
    20      - name: Change the kubeconfig port to the proper value
    21        replace:
    22          regexp: 8443
    23          replace: "{{ lookup('env', 'KIND_PORT') }}"
    24          path: '{{ kubeconfig }}'
    25        delegate_to: localhost
    26  
    27      - name: Wait for the Kubernetes API to become available (this could take a minute)
    28        uri:
    29          url: "https://localhost:8443/apis"
    30          status_code: 200
    31          validate_certs: no
    32        register: result
    33        until: (result.status|default(-1)) == 200
    34        retries: 60
    35        delay: 5
    36  
    37  - name: Prepare operator resources
    38    hosts: localhost
    39    connection: local
    40    vars:
    41      ansible_python_interpreter: '{{ ansible_playbook_python }}'
    42      deploy_dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/deploy"
    43    tasks:
    44    - name: Create Custom Resource Definition
    45      k8s:
    46        definition: "{{ lookup('file', '/'.join([deploy_dir, 'crds/inventory_v1alpha1_inventory_crd.yaml'])) }}"
    47  
    48    - name: Ensure specified namespace is present
    49      k8s:
    50        api_version: v1
    51        kind: Namespace
    52        name: '{{ namespace }}'
    53  
    54    - name: Create RBAC resources
    55      k8s:
    56        definition: "{{ lookup('template', '/'.join([deploy_dir, item])) }}"
    57        namespace: '{{ namespace }}'
    58      with_items:
    59        - role.yaml
    60        - role_binding.yaml
    61        - service_account.yaml
    62  
    63    - name: Dump the dev image
    64      command: docker save -o /tmp/dev-operator.tar quay.io/operator-framework/ansible-operator:dev
    65  
    66    - name: Copy the image to the kind container
    67      command: docker cp /tmp/dev-operator.tar kind-test-local:/dev-operator.tar
    68  
    69  - name: Make dev operator image available
    70    hosts: k8s
    71    gather_facts: no
    72    tasks:
    73    - name: Make dev operator available
    74      command: docker load -i /dev-operator.tar
    75  
    76  - name: Clean up
    77    hosts: localhost
    78    connection: local
    79    gather_facts: no
    80    tasks:
    81    - name: remove dev-operator.tar
    82      file:
    83        path: /tmp/dev-operator.tar
    84        state: absent