Skip to content

Commit

Permalink
Check for capabilities instead of openshift
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontleon committed Aug 24, 2018
1 parent 32b1b92 commit 60d0664
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion playbooks/deprovision.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- connection: local
gather_facts: false
hosts: localhost
name: "Deprovision mediawiki-apb from {{ cluster }}"
name: "Deprovision mediawiki-apb"
roles:
- ansibleplaybookbundle.asb-modules
- mediawiki-apb
Expand Down
6 changes: 1 addition & 5 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
description: "0%: Starting"
when: in_cluster

- name: 'Set facts'
set_fact:
cluster: '{{ "openshift" if "openshift" in lookup("k8s", cluster_info="version") else "kubernetes" }}'

- name: Validate Admin User and Password
fail:
msg: "Mediawiki Admin User and Password cannot be the same value!"
Expand All @@ -25,7 +21,7 @@
- name: service.yaml.j2
- name: pvc.yaml.j2
- name: route.yaml.j2
apply: "{{ True if cluster == 'openshift' else False }}"
apply: "{{ True if 'route.openshift.io' in lookup('k8s', cluster_info='api_groups') else False }}"
- name: deployment.yaml.j2

- name: "Update last operation"
Expand Down
30 changes: 15 additions & 15 deletions templates/deployment.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---

{% if cluster == 'kubernetes' %}
apiVersion: apps/v1
kind: Deployment
{% else %}
{% if 'apps.openshift.io' in lookup('k8s', cluster_info='api_groups') %}
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
{% else %}
apiVersion: apps/v1
kind: Deployment
{% endif %}
metadata:
name: {{ app_name }}
Expand All @@ -15,15 +15,15 @@ metadata:
service: {{ app_name }}
spec:
replicas: 1
{% if cluster == 'kubernetes' %}
{% if 'apps.openshift.io' in lookup('k8s', cluster_info='api_groups') %}
selector:
app: {{ app_name }}
service: {{ app_name }}
{% else %}
selector:
matchLabels:
app: {{ app_name }}
service: {{ app_name }}
{% else %}
selector:
app: {{ app_name }}
service: {{ app_name }}
{% endif %}
strategy:
type: Recreate
Expand All @@ -47,12 +47,7 @@ spec:
value: {{ mediawiki_admin_user }}
- name: MEDIAWIKI_ADMIN_PASS
value: {{ mediawiki_admin_pass }}
{% if cluster == 'kubernetes' %}
- name: MEDIAWIKI_SITE_SERVER
valueFrom:
fieldRef:
fieldPath: status.podIP
{% else %}
{% if 'apps.openshift.io' in lookup('k8s', cluster_info='api_groups') %}
- name: MEDIAWIKI_SITE_SERVER
value: {{
lookup(
Expand All @@ -63,6 +58,11 @@ spec:
resource_name=app_name
) | json_query("spec.host")
}}
{% else %}
- name: MEDIAWIKI_SITE_SERVER
valueFrom:
fieldRef:
fieldPath: status.podIP
{% endif %}
ports:
- containerPort: 8080
Expand Down

0 comments on commit 60d0664

Please sign in to comment.