Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include vars for ansible version >= 2.6 #33

Merged
merged 4 commits into from
May 23, 2018
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to import the 25 variables as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just use them to override 25 variables.

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will these changes work with v1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested using 2.5 and it still worked.

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