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

Update APB for ansible 26 #38

Merged
merged 1 commit into from
Jul 17, 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
38 changes: 11 additions & 27 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,9 @@
description: "0%: Starting"
when: in_cluster

- name: 'Determine cluster type'
command: oc version
register: oc_version
ignore_errors: yes

- name: 'Set facts'
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', '>=')
cluster: '{{ "openshift" if "openshift" in lookup("k8s", cluster_info="version") else "kubernetes" }}'

- name: Validate Admin User and Password
fail:
Expand All @@ -26,23 +17,16 @@
- apb_action == "provision"

- name: "Set mediawiki objects state={{ state }}"
k8s_raw:
state: '{{ state }}'
definition: "{{ lookup('template', item) | from_yaml }}"
with_items:
- service.yaml
- pvc.yaml

- name: "Set mediawiki route state={{ state }}"
openshift_raw:
state: '{{ state }}'
definition: "{{ lookup('template', 'route.yaml') | from_yaml }}"
when: cluster == 'openshift'

- name: "Set mediawiki deployment state={{ state }}"
openshift_raw:
state: '{{ state }}'
definition: "{{ lookup('template', 'deployment.yaml') | from_yaml }}"
k8s:
state: "{{ state }}"
definition: "{{ lookup('template', item.name) | from_yaml }}"
when: item.apply | default(True)
loop:
- name: service.yaml.j2
- name: pvc.yaml.j2
- name: route.yaml.j2
apply: "{{ True if cluster == 'openshift' else False }}"
- name: deployment.yaml.j2

- name: "Update last operation"
asb_last_operation:
Expand Down
6 changes: 3 additions & 3 deletions templates/deployment.yaml → templates/deployment.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---

{% if cluster == 'kubernetes' %}
apiVersion: {{ deployment_api_version }}
apiVersion: apps/v1
kind: Deployment
{% else %}
apiVersion: {{ deploymentconfig_api_version }}
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
{% endif %}
metadata:
Expand Down Expand Up @@ -57,7 +57,7 @@ spec:
value: {{
lookup(
'openshift',
api_version=route_api_version,
api_version='route.openshift.io/v1',
kind='Route',
namespace=namespace,
resource_name=app_name
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion templates/route.yaml → templates/route.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---

apiVersion: {{ route_api_version }}
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: {{ app_name }}
Expand Down
File renamed without changes.
5 changes: 0 additions & 5 deletions vars/ansible_26.yml

This file was deleted.

5 changes: 0 additions & 5 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ 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