Debian Codegraph @

ansible_collections/community/okd/molecule/default/verify.yml

raw
1 ---
2 - name: Create inventory of pods
3 # We need to manually create the inventory of pods now that the inventory plugin has been removed
4 gather_facts: false
5 hosts: localhost
6 connection: local
7 tasks:
8 - name: Get pods
9 kubernetes.core.k8s_info:
10 kind: Pod
11 namespace: testing
12 register: pods
13
14 - name: Add pods to inventory
15 ansible.builtin.add_host:
16 name: "{{ item.metadata.name }}"
17 groups:
18 - namespace_testing_pods
19 ansible_oc_pod: "{{ item.metadata.name }}"
20 ansible_oc_namespace: "{{ item.metadata.namespace }}"
21 pod_phase: "{{ item.status.phase }}"
22 ansible_remote_tmp: /tmp/.ansible
23 loop: "{{ pods.resources }}"
24
25 - name: Verify connection plugin
26 hosts: namespace_testing_pods
27 gather_facts: no
28 connection: community.okd.oc
29 vars:
30 file_content: |
31 Hello world
32 tasks:
33 - name: End play if host not running (TODO should we not add these to the inventory?)
34 meta: end_host
35 when: pod_phase != "Running"
36
37 - setup:
38
39 - debug: var=ansible_facts
40
41 - name: Assert the TEST environment variable was retrieved
42 assert:
43 that: ansible_facts.env.TEST == 'test'
44
45 - name: Copy a file into the host
46 copy:
47 content: '{{ file_content }}'
48 dest: /tmp/test_file
49
50 - name: Retrieve the file from the host
51 slurp:
52 src: /tmp/test_file
53 register: slurped_file
54
55 - name: Assert the file content matches expectations
56 assert:
57 that: (slurped_file.content|b64decode) == file_content
58
59
60 - name: Verify
61 hosts: localhost
62 connection: local
63 gather_facts: no
64 vars:
65 ansible_python_interpreter: '{{ virtualenv_interpreter }}'
66
67 tasks:
68 - pip:
69 name: kubernetes-validate==1.12.0
70 virtualenv: "{{ virtualenv }}"
71 virtualenv_command: "{{ virtualenv_command }}"
72 virtualenv_site_packages: no
73
74 - import_tasks: tasks/validate_installed.yml
75
76 - pip:
77 name: kubernetes-validate
78 state: absent
79 virtualenv: "{{ virtualenv }}"
80 virtualenv_command: "{{ virtualenv_command }}"
81 virtualenv_site_packages: no
82
83 - import_tasks: tasks/validate_not_installed.yml
84
85 - import_tasks: tasks/openshift_auth.yml
86 - import_tasks: tasks/openshift_adm_prune_auth_clusterroles.yml
87 - import_tasks: tasks/openshift_adm_prune_auth_roles.yml
88 - import_tasks: tasks/openshift_adm_prune_deployments.yml
89 - import_tasks: tasks/openshift_builds.yml
90 - import_tasks: tasks/openshift_route.yml
91 - import_tasks: tasks/openshift_import_images.yml
92 - import_tasks: tasks/openshift_prune_images.yml
93 - block:
94 - name: Create namespace
95 community.okd.k8s:
96 api_version: v1
97 kind: Namespace
98 name: process-test
99 - import_tasks: tasks/openshift_process.yml
100 vars:
101 files_dir: '{{ playbook_dir }}/files'
102 nginx_version: 1.22-ubi8
103 always:
104 - name: Delete namespace
105 community.okd.k8s:
106 api_version: v1
107 kind: Namespace
108 name: process-test
109 state: absent
110
111 roles:
112 - role: openshift_adm_groups