From 118789c602638446e43987c28afb2749b4987896 Mon Sep 17 00:00:00 2001 From: David Zager Date: Tue, 22 May 2018 15:30:55 -0400 Subject: [PATCH 1/4] Include vars for ansible version >= 2.6 --- tasks/main.yml | 4 ++++ templates/deployment.yaml | 3 ++- templates/pvc.yaml | 2 +- templates/route.yaml | 2 +- templates/service.yaml | 2 +- vars/ansible_26.yml | 7 +++++++ vars/main.yml | 7 +++++++ 7 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 vars/ansible_26.yml diff --git a/tasks/main.yml b/tasks/main.yml index 3eae831..0781554 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 | version_compare('2.6', '>=') + - name: Validate Admin User and Password fail: msg: "Mediawiki Admin User and Password cannot be the same value!" diff --git a/templates/deployment.yaml b/templates/deployment.yaml index a2f2f59..8e14eaa 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -1,9 +1,10 @@ --- -apiVersion: v1 {% if cluster == 'kubernetes' %} +apiVersion: {{ deployment_api_version }} kind: Deployment {% else %} +apiVersion: {{ deploymentconfig_api_version }} kind: DeploymentConfig {% endif %} metadata: diff --git a/templates/pvc.yaml b/templates/pvc.yaml index 43834ea..4933695 100644 --- a/templates/pvc.yaml +++ b/templates/pvc.yaml @@ -1,6 +1,6 @@ --- -apiVersion: v1 +apiVersion: {{ pvc_api_version }} kind: PersistentVolumeClaim metadata: name: {{ app_name }} diff --git a/templates/route.yaml b/templates/route.yaml index b09a4db..7d5b6ad 100644 --- a/templates/route.yaml +++ b/templates/route.yaml @@ -1,6 +1,6 @@ --- -apiVersion: v1 +apiVersion: {{ route_api_version }} kind: Route metadata: name: {{ app_name }} diff --git a/templates/service.yaml b/templates/service.yaml index 3ccf9a8..87d12c5 100644 --- a/templates/service.yaml +++ b/templates/service.yaml @@ -1,6 +1,6 @@ --- -apiVersion: v1 +apiVersion: {{ service_api_version }} kind: Service metadata: name: {{ app_name }} diff --git a/vars/ansible_26.yml b/vars/ansible_26.yml new file mode 100644 index 0000000..bb57793 --- /dev/null +++ b/vars/ansible_26.yml @@ -0,0 +1,7 @@ +--- + +deployment_api_version: apps/v1 +deploymentconfig_api_version: apps.openshift.io/v1 +pvc_api_version: v1 +route_api_version: route.openshift.io/v1 +service_api_version: v1 diff --git a/vars/main.yml b/vars/main.yml index 158c3a5..e19bfe2 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -10,3 +10,10 @@ 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 +pvc_api_version: v1 +route_api_version: v1 +service_api_version: v1 From 88bd892aaa7cb6686198b5447a88fa834b7926b4 Mon Sep 17 00:00:00 2001 From: David Zager Date: Tue, 22 May 2018 15:53:19 -0400 Subject: [PATCH 2/4] Improve version test, fix templates --- tasks/main.yml | 2 +- templates/deployment.yaml | 6 +++--- templates/service.yaml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 0781554..846d109 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,7 +16,7 @@ - name: 'Include variables based on ansible version' include_vars: ansible_26.yml - when: ansible_version.full | version_compare('2.6', '>=') + when: ansible_version.full is version('2.6', '>=') - name: Validate Admin User and Password fail: diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 8e14eaa..ab09326 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -52,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 }} diff --git a/templates/service.yaml b/templates/service.yaml index 87d12c5..89cbe2d 100644 --- a/templates/service.yaml +++ b/templates/service.yaml @@ -12,7 +12,7 @@ spec: ports: - name: web port: 8080 - target_port: 8080 + targetPort: 8080 selector: app: {{ app_name }} service: {{ app_name }} From 774e5da915715682421d3d9982c1fc171ea04574 Mon Sep 17 00:00:00 2001 From: David Zager Date: Tue, 22 May 2018 15:56:49 -0400 Subject: [PATCH 3/4] Remove latest origin/k8s tests --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1acdafa..ec1430b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: From e23a92f0b72f43aab5b4cdb21b41d643d9bc8267 Mon Sep 17 00:00:00 2001 From: David Zager Date: Wed, 23 May 2018 08:42:49 -0400 Subject: [PATCH 4/4] Remove apiVersions that don't change --- templates/pvc.yaml | 2 +- templates/service.yaml | 2 +- vars/ansible_26.yml | 2 -- vars/main.yml | 2 -- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/templates/pvc.yaml b/templates/pvc.yaml index 4933695..43834ea 100644 --- a/templates/pvc.yaml +++ b/templates/pvc.yaml @@ -1,6 +1,6 @@ --- -apiVersion: {{ pvc_api_version }} +apiVersion: v1 kind: PersistentVolumeClaim metadata: name: {{ app_name }} diff --git a/templates/service.yaml b/templates/service.yaml index 89cbe2d..1286f7d 100644 --- a/templates/service.yaml +++ b/templates/service.yaml @@ -1,6 +1,6 @@ --- -apiVersion: {{ service_api_version }} +apiVersion: v1 kind: Service metadata: name: {{ app_name }} diff --git a/vars/ansible_26.yml b/vars/ansible_26.yml index bb57793..4662515 100644 --- a/vars/ansible_26.yml +++ b/vars/ansible_26.yml @@ -2,6 +2,4 @@ deployment_api_version: apps/v1 deploymentconfig_api_version: apps.openshift.io/v1 -pvc_api_version: v1 route_api_version: route.openshift.io/v1 -service_api_version: v1 diff --git a/vars/main.yml b/vars/main.yml index e19bfe2..aa9567b 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -14,6 +14,4 @@ in_cluster: "{{ True if (pod_name and pod_namespace) else False }}" # Ansible 2.5 api versions deployment_api_version: v1 deploymentconfig_api_version: v1 -pvc_api_version: v1 route_api_version: v1 -service_api_version: v1