mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-03-26 21:33:02 +00:00
* Add support for configuring garbage collection This surfaces deleteOptions functionality in a top-level delete_options parameter. * Add changelog fragment * Remove kind and apiVersion from delete_options * Add release version to docs
121 lines
2.7 KiB
YAML
121 lines
2.7 KiB
YAML
---
|
|
- name: Converge
|
|
hosts: localhost
|
|
connection: local
|
|
|
|
collections:
|
|
- community.kubernetes
|
|
|
|
vars_files:
|
|
- vars/main.yml
|
|
|
|
tasks:
|
|
- name: Verify cluster is working.
|
|
k8s_info:
|
|
namespace: kube-system
|
|
kind: Pod
|
|
register: pod_list
|
|
|
|
- name: Verify cluster has more than 5 pods running.
|
|
assert:
|
|
that: (pod_list.resources | count) > 5
|
|
|
|
- include_tasks: tasks/delete.yml
|
|
- include_tasks: tasks/scale.yml
|
|
- include_tasks: tasks/apply.yml
|
|
- include_tasks: tasks/waiter.yml
|
|
- include_tasks: tasks/full.yml
|
|
- include_tasks: tasks/exec.yml
|
|
- include_tasks: tasks/log.yml
|
|
- include_tasks: tasks/cluster_info.yml
|
|
- include_tasks: tasks/access_review.yml
|
|
- include_tasks: tasks/rollback.yml
|
|
- include_tasks: tasks/gc.yml
|
|
|
|
roles:
|
|
- helm
|
|
|
|
post_tasks:
|
|
- name: Ensure namespace exists
|
|
k8s:
|
|
api_version: v1
|
|
kind: Namespace
|
|
name: inventory
|
|
|
|
- name: Add a deployment
|
|
k8s:
|
|
definition:
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: inventory
|
|
namespace: inventory
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: "{{ k8s_pod_name }}"
|
|
template: "{{ k8s_pod_template }}"
|
|
wait: yes
|
|
wait_timeout: 120
|
|
vars:
|
|
k8s_pod_name: inventory
|
|
k8s_pod_image: python
|
|
k8s_pod_command:
|
|
- python
|
|
- '-m'
|
|
- http.server
|
|
k8s_pod_env:
|
|
- name: TEST
|
|
value: test
|
|
|
|
- meta: refresh_inventory
|
|
|
|
- name: Verify inventory and connection plugins
|
|
hosts: namespace_inventory_pods
|
|
gather_facts: no
|
|
|
|
vars:
|
|
file_content: |
|
|
Hello world
|
|
|
|
tasks:
|
|
- name: End play if host not running (TODO should we not add these to the inventory?)
|
|
meta: end_host
|
|
when: pod_phase != "Running"
|
|
|
|
- debug: var=hostvars
|
|
- setup:
|
|
|
|
- debug: var=ansible_facts
|
|
|
|
- name: Assert the TEST environment variable was retrieved
|
|
assert:
|
|
that: ansible_facts.env.TEST == 'test'
|
|
|
|
- name: Copy a file into the host
|
|
copy:
|
|
content: '{{ file_content }}'
|
|
dest: /tmp/test_file
|
|
|
|
- name: Retrieve the file from the host
|
|
slurp:
|
|
src: /tmp/test_file
|
|
register: slurped_file
|
|
|
|
- name: Assert the file content matches expectations
|
|
assert:
|
|
that: (slurped_file.content|b64decode) == file_content
|
|
|
|
- name: Delete inventory namespace
|
|
hosts: localhost
|
|
connection: local
|
|
gather_facts: no
|
|
tasks:
|
|
- name: Remove inventory namespace
|
|
k8s:
|
|
api_version: v1
|
|
kind: Namespace
|
|
name: inventory
|
|
state: absent
|