summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--roles/openshift_management/README.md28
-rw-r--r--roles/openshift_management/filter_plugins/oo_management_filters.py27
-rw-r--r--roles/openshift_management/tasks/add_many_container_providers.yml26
-rw-r--r--roles/openshift_management/tasks/main.yml4
-rw-r--r--roles/openshift_management/tasks/storage/nfs.yml31
-rw-r--r--roles/openshift_management/tasks/storage/nfs_server.yml31
6 files changed, 94 insertions, 53 deletions
diff --git a/roles/openshift_management/README.md b/roles/openshift_management/README.md
index fb961e38e..817ad4daa 100644
--- a/roles/openshift_management/README.md
+++ b/roles/openshift_management/README.md
@@ -482,16 +482,14 @@ preview** script which allows you to add multiple container platforms
as container providers in any arbitrary MIQ/CFME server.
Using the multiple-provider script requires manual configuration and
-the setting of an additional inventory parameter.
+setting an `EXTRA_VARS` parameter on the command-line.
1. Copy the
[container_providers.yml](files/examples/container_providers.yml)
- example somewhere
-1. Add the `openshift_management_many_container_providers_config`
- parameter to your inventory and set the value to the full path of
- the file you copied in `Step 1`
-1. Update the `hostname`, `user`, and `password` parameters in the
+ example somewhere, such as `/tmp/cp.yml`
+1. If you changed your CFME/MIQ name or password, update the
+ `hostname`, `user`, and `password` parameters in the
`management_server` key in the `container_providers.yml` file copy
1. Fill in an entry under the `container_providers` key for *each* OCP
or Origin cluster you want to add as container providers
@@ -511,6 +509,7 @@ the setting of an additional inventory parameter.
* `port` - Update this key if your OCP/Origin cluster runs the API on a port other than `8443`
* `endpoint` - You may enable SSL verification (`verify_ssl`) or change the validation setting to `ssl-with-validation`. Support for custom trusted CA certificates is not available at this time.
+
Let's see an example describing the following scenario:
* You copied `files/examples/container_providers.yml` to `/tmp/cp.yml`
@@ -542,18 +541,15 @@ management_server:
password: b3tt3r_p4SSw0rd
```
-Then you would add to your inventory file:
-
-```ini
-[OSEv3:vars]
-# ...
-openshift_management_many_container_providers_config=/tmp/cp.yml
-```
-
-Finally, run the many-container-providers integration script:
+Then you will run the many-container-providers integration script. You
+**must** provide the path to the container providers configuration
+file as an `EXTRA_VARS` parameter to `ansible-playbook`. Use the `-e`
+(or `--extra-vars`) parameter to set `container_providers_config` to
+the config file path.
```
-$ ansible-playbook -v -i <YOUR_INVENTORY> roles/openshift_management/tasks/add_many_container_providers.yml
+$ ansible-playbook -v -e container_providers_config=/tmp/cp.yml \
+ roles/openshift_management/tasks/add_many_container_providers.yml
```
Afterwards you will find two new container providers in your
diff --git a/roles/openshift_management/filter_plugins/oo_management_filters.py b/roles/openshift_management/filter_plugins/oo_management_filters.py
new file mode 100644
index 000000000..06bc0796d
--- /dev/null
+++ b/roles/openshift_management/filter_plugins/oo_management_filters.py
@@ -0,0 +1,27 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+def oo_filter_container_providers(results):
+ """results - the result from posting the API calls for adding new
+providers"""
+ all_results = []
+ for result in results:
+ if 'results' in result['json']:
+ # We got an OK response
+ r = result['json']['results'][0]
+ all_results.append("Provider '{}' - Added successfully".format(r['name']))
+ elif 'error' in result['json']:
+ # This was a problem
+ all_results.append("Provider '{}' - Failed to add. Message: {}".format(
+ result['item']['name'], result['json']['error']['message']))
+ return all_results
+
+class FilterModule(object):
+ """ Custom ansible filter mapping """
+
+ # pylint: disable=no-self-use, too-few-public-methods
+ def filters(self):
+ """ returns a mapping of filters to methods """
+ return {
+ "oo_filter_container_providers": oo_filter_container_providers,
+ }
diff --git a/roles/openshift_management/tasks/add_many_container_providers.yml b/roles/openshift_management/tasks/add_many_container_providers.yml
index f92c81277..10a1f4c83 100644
--- a/roles/openshift_management/tasks/add_many_container_providers.yml
+++ b/roles/openshift_management/tasks/add_many_container_providers.yml
@@ -1,9 +1,15 @@
---
-- hosts: "{{ groups['masters'][0] }}"
+- hosts: localhost
tasks:
+ - name: Ensure the container provider configuration is defined
+ assert:
+ that: container_providers_config is defined
+ msg: |
+ Error: Must provide providers config path. Fix: Add '-e container_providers_config=/path/to/your/config' to the ansible-playbook command
+
- name: Include providers/management configuration
include_vars:
- file: "{{ openshift_management_many_container_providers_config }}"
+ file: "{{ container_providers_config }}"
- name: Ensure this cluster is a container provider
uri:
@@ -20,8 +26,16 @@
with_items: "{{ container_providers }}"
register: results
- - name: Ensure failed additions are reported for each container provider
+ # TODO: Make this prettier and easier to read
+ - name: Save results
+ copy:
+ dest: /tmp/results.json
+ content: "{{ results.results | to_nice_json }}"
+ # state: present
+ # debug:
+ # var: item.item
+ # with_items: "{{ results.results }}"
+
+ - name: print each result
debug:
- msg: |
- FLOOP {{ item.item.hostname }}
- with_items: "{{ results.results }}"
+ msg: "{{ results.results | oo_filter_container_providers }}"
diff --git a/roles/openshift_management/tasks/main.yml b/roles/openshift_management/tasks/main.yml
index 88290c44d..9be923a57 100644
--- a/roles/openshift_management/tasks/main.yml
+++ b/roles/openshift_management/tasks/main.yml
@@ -22,6 +22,10 @@
######################################################################
# STORAGE - Initialize basic storage class
+- name: Determine the correct NFS host if required
+ include: storage/nfs_server.yml
+ when: openshift_management_storage_class in ['nfs', 'nfs_external']
+
#---------------------------------------------------------------------
# * nfs - set up NFS shares on the first master for a proof of concept
- name: Create required NFS exports for Management app storage
diff --git a/roles/openshift_management/tasks/storage/nfs.yml b/roles/openshift_management/tasks/storage/nfs.yml
index 696808328..94e11137c 100644
--- a/roles/openshift_management/tasks/storage/nfs.yml
+++ b/roles/openshift_management/tasks/storage/nfs.yml
@@ -2,37 +2,6 @@
# Tasks to statically provision NFS volumes
# Include if not using dynamic volume provisioning
-- name: Ensure we save the local NFS server if one is provided
- set_fact:
- openshift_management_nfs_server: "{{ openshift_management_storage_nfs_local_hostname }}"
- when:
- - openshift_management_storage_nfs_local_hostname is defined
- - openshift_management_storage_nfs_local_hostname != False
- - openshift_management_storage_class == "nfs"
-
-- name: Ensure we save the local NFS server
- set_fact:
- openshift_management_nfs_server: "{{ groups['oo_nfs_to_config'].0 }}"
- when:
- - openshift_management_nfs_server is not defined
- - openshift_management_storage_class == "nfs"
-
-- name: Ensure we save the external NFS server
- set_fact:
- openshift_management_nfs_server: "{{ openshift_management_storage_nfs_external_hostname }}"
- when:
- - openshift_management_storage_class == "nfs_external"
-
-- name: Failed NFS server detection
- assert:
- that:
- - openshift_management_nfs_server is defined
- msg: |
- "Unable to detect an NFS server. The 'nfs_external'
- openshift_management_storage_class option requires that you set
- openshift_management_storage_nfs_external_hostname. NFS hosts detected
- for local nfs services: {{ groups['oo_nfs_to_config'] | join(', ') }}"
-
- name: Setting up NFS storage
block:
- name: Include the NFS Setup role tasks
diff --git a/roles/openshift_management/tasks/storage/nfs_server.yml b/roles/openshift_management/tasks/storage/nfs_server.yml
new file mode 100644
index 000000000..96a742c83
--- /dev/null
+++ b/roles/openshift_management/tasks/storage/nfs_server.yml
@@ -0,0 +1,31 @@
+---
+- name: Ensure we save the local NFS server if one is provided
+ set_fact:
+ openshift_management_nfs_server: "{{ openshift_management_storage_nfs_local_hostname }}"
+ when:
+ - openshift_management_storage_nfs_local_hostname is defined
+ - openshift_management_storage_nfs_local_hostname != False
+ - openshift_management_storage_class == "nfs"
+
+- name: Ensure we save the local NFS server
+ set_fact:
+ openshift_management_nfs_server: "{{ groups['oo_nfs_to_config'].0 }}"
+ when:
+ - openshift_management_nfs_server is not defined
+ - openshift_management_storage_class == "nfs"
+
+- name: Ensure we save the external NFS server
+ set_fact:
+ openshift_management_nfs_server: "{{ openshift_management_storage_nfs_external_hostname }}"
+ when:
+ - openshift_management_storage_class == "nfs_external"
+
+- name: Failed NFS server detection
+ assert:
+ that:
+ - openshift_management_nfs_server is defined
+ msg: |
+ "Unable to detect an NFS server. The 'nfs_external'
+ openshift_management_storage_class option requires that you set
+ openshift_management_storage_nfs_external_hostname. NFS hosts detected
+ for local nfs services: {{ groups['oo_nfs_to_config'] | join(', ') }}"