Add tests for inventory plugin (#16)

This commit is contained in:
Fabian von Feilitzsch
2020-08-26 15:01:10 -04:00
committed by GitHub
parent 9a4af00302
commit 1b08450b19
3 changed files with 58 additions and 14 deletions

View File

@@ -26,32 +26,35 @@
apiVersion: v1 apiVersion: v1
kind: DeploymentConfig kind: DeploymentConfig
metadata: metadata:
name: elastic name: hello-world
labels: labels:
app: galaxy app: galaxy
service: elastic service: hello-world
namespace: testing namespace: testing
spec: spec:
template: template:
metadata: metadata:
labels: labels:
app: galaxy app: galaxy
service: elastic service: hello-world
spec: spec:
containers: containers:
- name: elastic - name: hello-world
volumeMounts: image: python
- mountPath: /usr/share/elasticsearch/data command:
name: elastic-volume - python
command: ['elasticsearch'] - '-m'
image: 'ansible/galaxy-elasticsearch:2.4.6' - http.server
volumes: env:
- name: elastic-volume - name: TEST
persistentVolumeClaim: value: test
claimName: elastic-volume
replicas: 1 replicas: 1
strategy: strategy:
type: Rolling type: Recreate
wait: yes
wait_condition:
type: Available
status: True
register: output register: output
- name: Show output - name: Show output

View File

@@ -9,10 +9,15 @@ platforms:
- k8s - k8s
provisioner: provisioner:
name: ansible name: ansible
config_options:
inventory:
enable_plugins: community.okd.openshift
lint: | lint: |
set -e set -e
ansible-lint ansible-lint
inventory: inventory:
hosts:
plugin: community.okd.openshift
host_vars: host_vars:
localhost: localhost:
virtualenv: ${MOLECULE_EPHEMERAL_DIRECTORY}/virtualenv virtualenv: ${MOLECULE_EPHEMERAL_DIRECTORY}/virtualenv

View File

@@ -1,4 +1,40 @@
--- ---
- name: Verify inventory and connection plugins
# This group is created by the openshift_inventory plugin
# It is automatically configured to use the `oc` connection plugin
hosts: namespace_testing_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"
- 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: Verify - name: Verify
hosts: localhost hosts: localhost
connection: local connection: local