-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a409ab
commit 61dac73
Showing
18 changed files
with
564 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
- name: "[MARIADB_APB][TEST] Test MariaDB APB" | ||
hosts: localhost | ||
gather_facts: False | ||
connection: local | ||
roles: | ||
- role: ansible.kubernetes-modules | ||
install_python_requirements: no | ||
- role: ansibleplaybookbundle.asb-modules | ||
|
||
tasks: | ||
- include_tasks: test_tasks.yml | ||
vars: | ||
plan: "{{ outer_item }}" | ||
with_items: | ||
- ha | ||
loop_control: | ||
loop_var: outer_item |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
- name: "Include variables per apb plan" | ||
include_vars: | ||
file: "vars/{{ plan }}.yml" | ||
|
||
- debug: | ||
msg: "{{ hostvars[inventory_hostname] }}" | ||
|
||
- name: "[TEST][{{ _apb_plan_id }}] Create new project" | ||
openshift_v1_project: | ||
name: '{{ namespace }}' | ||
state: 'present' | ||
|
||
- name: "[TEST][{{ _apb_plan_id }}]" | ||
include_role: | ||
name: rhscl-mariadb-apb-openshift | ||
vars: | ||
action: 'provision' | ||
state: 'present' | ||
|
||
- name: "[TEST][{{ _apb_plan_id }}]" | ||
include_role: | ||
name: rhscl-mariadb-apb-openshift | ||
vars: | ||
action: 'test' | ||
|
||
- name: "[TEST][{{ _apb_plan_id }}]" | ||
include_role: | ||
name: rhscl-mariadb-apb-openshift | ||
vars: | ||
action: 'deprovision' | ||
state: 'absent' | ||
|
||
- name: "[TEST][{{ _apb_plan_id }}] Delete test project" | ||
openshift_v1_project: | ||
name: '{{ namespace }}' | ||
state: 'absent' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
_apb_plan_id: "dev" | ||
service_name: "rhscl-mariadb" | ||
namespace: "test-{{ _apb_plan_id }}-{{ service_name }}" | ||
mariadb_database: "userdb" | ||
mariadb_user: "user" | ||
volume_size: "1Gi" | ||
mariadb_version: "10.2" | ||
mariadb_root_password: "password123" | ||
mariadb_password: "password123" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
_apb_plan_id: "ha" | ||
service_name: "rhscl-mariadb" | ||
namespace: "test-{{ _apb_plan_id }}-{{ service_name }}" | ||
mariadb_database: "userdb" | ||
mariadb_user: "user" | ||
volume_size: "1Gi" | ||
mariadb_version: "10.2" | ||
mariadb_root_password: "password123" | ||
mariadb_password: "password123" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
_apb_plan_id: "prod" | ||
service_name: "rhscl-mariadb" | ||
namespace: "test-{{ _apb_plan_id }}-{{ service_name }}" | ||
mariadb_database: "userdb" | ||
mariadb_user: "user" | ||
volume_size: "1Gi" | ||
mariadb_version: "10.2" | ||
mariadb_root_password: "password123" | ||
mariadb_password: "password123" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,35 @@ | ||
--- | ||
|
||
service_name: "{{ lookup('env','SERVICE_NAME') | default('rhscl-mariadb', true) }}" | ||
namespace: "{{ lookup('env','NAMESPACE') | default('rhscl-mariadb-apb', true) }}" | ||
mariadb_database: "{{ lookup('env','MARIADB_DATABASE') | default('', true) }}" | ||
mariadb_user: "{{ lookup('env','MARIADB_USER') | default('admin', true) }}" | ||
volume_size: "{{ lookup('env','VOLUME_SIZE') | default('10Gi', true) }}" | ||
mariadb_version: "{{ lookup('env','MARIADB_VERSION') | default('10.0', true) }}" | ||
image: "registry.access.redhat.com/rhscl/mariadb-{{ mariadb_version | replace('.', '') }}-rhel7" | ||
mariadb_version_nodots: "{{ mariadb_version | replace('.', '') }}" | ||
|
||
|
||
# http://jinja.pocoo.org/docs/2.10/templates/#whitespace-control | ||
# https://stackoverflow.com/a/21699210 | ||
image: >- | ||
{% if _apb_plan_id == "ha" -%} | ||
registry.centos.org/centos/mariadb-{{ mariadb_version_nodots }}-centos7 | ||
{%- else %} | ||
registry.access.redhat.com/rhscl/mariadb-{{ mariadb_version_nodots }}-rhel7 | ||
{%- endif %} | ||
state: present | ||
|
||
# Variables below are for the testing of the mariadb service. | ||
|
||
test_create_table: 'CREATE TABLE IF NOT EXISTS example_timestamp (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,data VARCHAR(100),cur_timestamp TIMESTAMP(6));' | ||
test_insert: 'INSERT INTO example_timestamp (data) VALUES ("The time of creation is:");' | ||
test_select: 'SELECT * FROM example_timestamp;' | ||
test_galera: | ||
- 'SHOW GLOBAL STATUS LIKE "wsrep_local_state_comment";' | ||
- 'SHOW GLOBAL STATUS LIKE "wsrep_connected";' | ||
- 'SHOW GLOBAL STATUS LIKE "wsrep_ready";' | ||
|
||
test_galera_expected_results: | ||
wsrep_connected: "ON" | ||
wsrep_ready: "ON" | ||
wsrep_local_state_comment: "Synced" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
# This module fails if the import ImageStream exists | ||
- name: Image Streams | ||
openshift_v1_image_stream: | ||
name: "{{ item.name }}" | ||
namespace: "{{ namespace }}" | ||
state: "{{ state }}" | ||
spec_tags: "{{ item.tags | default(omit) }}" | ||
ignore_errors: True | ||
with_items: | ||
- name: "{{ service_name }}-{{ mariadb_version_nodots }}-{{ _apb_plan_id }}" | ||
- name: "{{ service_name }}-{{ mariadb_version_nodots }}-galera" | ||
- name: "{{ image.split('/')[-1] }}" | ||
tags: | ||
- from: | ||
kind: DockerImage | ||
name: "{{ image }}" | ||
name: latest | ||
|
||
# This module does not correctly implement `spec_cluster_ip` when setting | ||
# to 'None' still creates a clusterIP. | ||
- name: Template Service | ||
template: | ||
src: service.yaml.j2 | ||
dest: /tmp/service.yaml | ||
register: svc | ||
|
||
- name: Apply Service | ||
command: "oc apply -n {{ namespace }} -f {{ svc.dest | default(svc.path) }}" | ||
|
||
- name: Template BuildConfigs | ||
template: | ||
src: "{{ item }}.j2" | ||
dest: "/tmp/{{ item }}" | ||
register: bc | ||
with_items: | ||
- "bc-ha.yaml" | ||
- "bc-galera.yaml" | ||
|
||
- name: Create BuildConfigs | ||
openshift_v1_build_config: | ||
name: "{{ (lookup('file', item.dest|default(item.path)) | from_yaml).metadata['name'] }}" | ||
namespace: "{{ namespace }}" | ||
state: "{{ state }}" | ||
src: "{{ item.dest | default(item.path) }}" | ||
with_items: "{{ bc.results }}" | ||
|
||
- name: Template StatefulSet | ||
template: | ||
src: statefulset.yaml.j2 | ||
dest: /tmp/statefulset.yaml | ||
register: sfs | ||
|
||
# This module fails if the statefulset exists and state is present | ||
- name: Create StatefulSet | ||
k8s_v1beta1_stateful_set: | ||
name: "{{ service_name }}-{{ mariadb_version_nodots }}-{{ _apb_plan_id }}" | ||
namespace: "{{ namespace }}" | ||
src: "{{ sfs.dest | default(sfs.path) }}" | ||
state: "{{ state }}" | ||
ignore_errors: True | ||
|
||
|
||
- name: Wait for rollout of StatefulSet | ||
k8s_v1beta1_stateful_set: | ||
name: "{{ service_name }}-{{ mariadb_version_nodots }}-{{ _apb_plan_id }}" | ||
namespace: "{{ namespace }}" | ||
register: rollout | ||
until: rollout['stateful_set']['status']['ready_replicas'] == rollout['stateful_set']['status']['replicas'] | ||
delay: 30 | ||
retries: 20 | ||
when: state == 'present' | ||
|
Oops, something went wrong.