Skip to content

Commit

Permalink
Include vars for ansible version >= 2.6 (#33)
Browse files Browse the repository at this point in the history
* Include vars for ansible version >= 2.6

* Improve version test, fix templates

* Remove latest origin/k8s tests

* Remove apiVersions that don't change
  • Loading branch information
djzager authored May 23, 2018
1 parent 1f72cb8 commit 4738c47
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ python:

env:
- OPENSHIFT_VERSION=v3.9
- OPENSHIFT_VERSION=v3.10
#- OPENSHIFT_VERSION=v3.10
- KUBERNETES_VERSION=v1.9.0
- KUBERNETES_VERSION=v1.10.0
#- KUBERNETES_VERSION=v1.10.0
# Allow failures on oc latest
# TODO: re-enable latest when it isn't busted
matrix:
Expand Down
4 changes: 4 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
set_fact:
cluster: "{{ 'openshift' if 'openshift' in oc_version.stdout else 'kubernetes' }}"

- name: 'Include variables based on ansible version'
include_vars: ansible_26.yml
when: ansible_version.full is version('2.6', '>=')

- name: Validate Admin User and Password
fail:
msg: "Mediawiki Admin User and Password cannot be the same value!"
Expand Down
9 changes: 5 additions & 4 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---

apiVersion: v1
{% if cluster == 'kubernetes' %}
apiVersion: {{ deployment_api_version }}
kind: Deployment
{% else %}
apiVersion: {{ deploymentconfig_api_version }}
kind: DeploymentConfig
{% endif %}
metadata:
Expand Down Expand Up @@ -51,12 +52,12 @@ spec:
fieldRef:
fieldPath: status.podIP
ports:
- container_port: 8080
- containerPort: 8080
protocol: TCP
volumeMounts:
- name: mediawiki
mountPath: /persistent
volumes:
- name: mediawiki
persistent_volume_claim:
claim_name: {{ app_name }}
persistentVolumeClaim:
claimName: {{ app_name }}
2 changes: 1 addition & 1 deletion templates/route.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---

apiVersion: v1
apiVersion: {{ route_api_version }}
kind: Route
metadata:
name: {{ app_name }}
Expand Down
2 changes: 1 addition & 1 deletion templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
ports:
- name: web
port: 8080
target_port: 8080
targetPort: 8080
selector:
app: {{ app_name }}
service: {{ app_name }}
5 changes: 5 additions & 0 deletions vars/ansible_26.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

deployment_api_version: apps/v1
deploymentconfig_api_version: apps.openshift.io/v1
route_api_version: route.openshift.io/v1
5 changes: 5 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ state: "{{ state_map[apb_action] }}"
pod_name: "{{ lookup('env', 'POD_NAME') }}"
pod_namespace: "{{ lookup('env', 'POD_NAMESPACE') }}"
in_cluster: "{{ True if (pod_name and pod_namespace) else False }}"

# Ansible 2.5 api versions
deployment_api_version: v1
deploymentconfig_api_version: v1
route_api_version: v1

0 comments on commit 4738c47

Please sign in to comment.