Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Test with Molecule 3.0 alpha release. #32

Merged
merged 2 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python_version: ["3.6"]
python_version: ['3.6']
steps:
- name: Check out code
uses: actions/checkout@v1
Expand All @@ -36,7 +36,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python_version: ["3.6"]
python_version: ['3.6']
steps:
- name: Check out code
uses: actions/checkout@v1
Expand All @@ -61,7 +61,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python_version: ['3.7']
python_version: ['3.7']
steps:
- name: Check out code
uses: actions/checkout@v1
Expand All @@ -77,7 +77,7 @@ jobs:
python-version: ${{ matrix.python_version }}

- name: Install molecule and openshift dependencies
run: pip install molecule openshift
run: pip install molecule yamllint openshift

- name: Install ansible-base
run: pip install git+https://github.com/ansible-collection-migration/ansible-base.git --disable-pip-version-check
Expand Down
12 changes: 12 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
extends: default

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
line-length: disable
truthy: disable
9 changes: 3 additions & 6 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ driver:
login_cmd_template: 'docker exec -ti {instance} bash'
ansible_connection_options:
ansible_connection: docker
lint:
name: yamllint
options:
config-data:
line-length:
max: 160
lint: |
yamllint .
platforms:
- name: instance-kind
provisioner:
Expand All @@ -27,6 +23,7 @@ provisioner:
scenario:
name: default
test_sequence:
- lint
- syntax
- converge
- verify
1 change: 1 addition & 0 deletions molecule/default/tasks/append_hash.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- block:
- name: Ensure that append_hash namespace exists
k8s:
Expand Down
10 changes: 5 additions & 5 deletions molecule/default/tasks/delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
- not pods_delete.resources

always:
- name: Remove namespace
k8s:
kind: Namespace
name: "{{ delete_namespace }}"
state: absent
- name: Remove namespace
k8s:
kind: Namespace
name: "{{ delete_namespace }}"
state: absent
20 changes: 10 additions & 10 deletions molecule/default/tasks/full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
app: galaxy
service: web
ports:
- protocol: TCP
targetPort: 8000
name: port-8000-tcp
port: 8000
- protocol: TCP
targetPort: 8000
name: port-8000-tcp
port: 8000
register: output

- name: Show output
Expand Down Expand Up @@ -107,7 +107,7 @@
requests:
storage: 5Gi
accessModes:
- ReadWriteOnce
- ReadWriteOnce

- name: Show output
debug:
Expand Down Expand Up @@ -149,14 +149,14 @@
containers:
- name: elastic
volumeMounts:
- mountPath: /usr/share/elasticsearch/data
name: elastic-volume
- mountPath: /usr/share/elasticsearch/data
name: elastic-volume
command: ['elasticsearch']
image: 'ansible/galaxy-elasticsearch:2.4.6'
volumes:
- name: elastic-volume
persistentVolumeClaim:
claimName: elastic-volume
- name: elastic-volume
persistentVolumeClaim:
claimName: elastic-volume
strategy:
type: RollingUpdate
register: output
Expand Down
227 changes: 113 additions & 114 deletions molecule/default/tasks/lists.yml
Original file line number Diff line number Diff line change
@@ -1,140 +1,139 @@
---

- name: Ensure testing1 namespace exists
k8s:
api_version: v1
kind: Namespace
name: testing1

- block:
- name: Create configmaps
k8s:
namespace: testing1
definition:
apiVersion: v1
kind: ConfigMapList
items: '{{ configmaps }}'
- name: Create configmaps
k8s:
namespace: testing1
definition:
apiVersion: v1
kind: ConfigMapList
items: '{{ configmaps }}'

- name: Get ConfigMaps
k8s_info:
api_version: v1
kind: ConfigMap
namespace: testing1
label_selectors:
- app=test
register: cms
- name: Get ConfigMaps
k8s_info:
api_version: v1
kind: ConfigMap
namespace: testing1
label_selectors:
- app=test
register: cms

- name: All three configmaps should exist
assert:
that: item.data.a is defined
with_items: '{{ cms.resources }}'
- name: All three configmaps should exist
assert:
that: item.data.a is defined
with_items: '{{ cms.resources }}'

- name: Delete configmaps
k8s:
state: absent
namespace: testing1
definition:
apiVersion: v1
kind: ConfigMapList
items: '{{ configmaps }}'
- name: Delete configmaps
k8s:
state: absent
namespace: testing1
definition:
apiVersion: v1
kind: ConfigMapList
items: '{{ configmaps }}'

- name: Get ConfigMaps
k8s_info:
api_version: v1
kind: ConfigMap
namespace: testing1
label_selectors:
- app=test
register: cms
- name: Get ConfigMaps
k8s_info:
api_version: v1
kind: ConfigMap
namespace: testing1
label_selectors:
- app=test
register: cms

- name: All three configmaps should not exist
assert:
that: not cms.resources
- name: All three configmaps should not exist
assert:
that: not cms.resources
vars:
configmaps:
- metadata:
name: list-example-1
labels:
app: test
data:
a: first
- metadata:
name: list-example-2
labels:
app: test
data:
a: second
- metadata:
name: list-example-3
labels:
app: test
data:
a: third
- metadata:
name: list-example-1
labels:
app: test
data:
a: first
- metadata:
name: list-example-2
labels:
app: test
data:
a: second
- metadata:
name: list-example-3
labels:
app: test
data:
a: third

- block:
- name: Create list of arbitrary resources
k8s:
namespace: testing1
definition:
apiVersion: v1
kind: List
- name: Create list of arbitrary resources
k8s:
namespace: testing1
items: '{{ resources }}'
definition:
apiVersion: v1
kind: List
namespace: testing1
items: '{{ resources }}'

- name: Get the created resources
k8s_info:
api_version: '{{ item.apiVersion }}'
kind: '{{ item.kind }}'
namespace: testing1
name: '{{ item.metadata.name }}'
register: list_resources
with_items: '{{ resources }}'
- name: Get the created resources
k8s_info:
api_version: '{{ item.apiVersion }}'
kind: '{{ item.kind }}'
namespace: testing1
name: '{{ item.metadata.name }}'
register: list_resources
with_items: '{{ resources }}'

- name: All resources should exist
assert:
that: ((list_resources.results | sum(attribute="resources", start=[])) | length) == (resources | length)
- name: All resources should exist
assert:
that: ((list_resources.results | sum(attribute="resources", start=[])) | length) == (resources | length)

- name: Delete list of arbitrary resources
k8s:
state: absent
namespace: testing1
definition:
apiVersion: v1
kind: List
- name: Delete list of arbitrary resources
k8s:
state: absent
namespace: testing1
items: '{{ resources }}'
definition:
apiVersion: v1
kind: List
namespace: testing1
items: '{{ resources }}'

- name: Get the resources
k8s_info:
api_version: '{{ item.apiVersion }}'
kind: '{{ item.kind }}'
namespace: testing1
name: '{{ item.metadata.name }}'
register: list_resources
with_items: '{{ resources }}'
- name: Get the resources
k8s_info:
api_version: '{{ item.apiVersion }}'
kind: '{{ item.kind }}'
namespace: testing1
name: '{{ item.metadata.name }}'
register: list_resources
with_items: '{{ resources }}'

- name: The resources should not exist
assert:
that: not ((list_resources.results | sum(attribute="resources", start=[])) | length)
- name: The resources should not exist
assert:
that: not ((list_resources.results | sum(attribute="resources", start=[])) | length)
vars:
resources:
- apiVersion: v1
kind: ConfigMap
metadata:
name: list-example-4
data:
key: value
- apiVersion: v1
kind: Service
metadata:
name: list-example-svc
labels:
app: test
spec:
selector:
app: test
ports:
- protocol: TCP
targetPort: 8000
name: port-8000-tcp
port: 8000
- apiVersion: v1
kind: ConfigMap
metadata:
name: list-example-4
data:
key: value
- apiVersion: v1
kind: Service
metadata:
name: list-example-svc
labels:
app: test
spec:
selector:
app: test
ports:
- protocol: TCP
targetPort: 8000
name: port-8000-tcp
port: 8000
Loading