summaryrefslogtreecommitdiffstats
path: root/roles/openshift_projects
diff options
context:
space:
mode:
authorAndrew Butcher <abutcher@redhat.com>2016-06-30 13:20:10 -0400
committerAndrew Butcher <abutcher@redhat.com>2016-07-07 13:31:12 -0400
commit57dfae185d3d0e02ebe515263c54867bee37b45e (patch)
treefce310bd381bb38145aed3dc10424484feaf96c6 /roles/openshift_projects
parent1a2c22a060b8b6f0e64d452fdfc13012d3c067ed (diff)
downloadopenshift-57dfae185d3d0e02ebe515263c54867bee37b45e.tar.gz
openshift-57dfae185d3d0e02ebe515263c54867bee37b45e.tar.bz2
openshift-57dfae185d3d0e02ebe515263c54867bee37b45e.tar.xz
openshift-57dfae185d3d0e02ebe515263c54867bee37b45e.zip
Various hosted component improvements
* [openshift_projects] Add openshift_projects role * [openshift_hosted] hosted deployments use openshift_hosted_infra_selector if openshift_hosted_<component>_selector is not defined * [openshift_hosted] move openshift_projects, openshift_serviceaccounts and openshift_metrics to dependencies of openshift_hosted * [router] improve router deployment - add router option to force subdomain - add CA to router certificate options * [registry] move registry config into openshift_hosted role - additional registry fixes/tweaks - add s3 storage support for registry * [serviceaccount] fix up serviceaccount creation
Diffstat (limited to 'roles/openshift_projects')
-rw-r--r--roles/openshift_projects/meta/main.yml15
-rw-r--r--roles/openshift_projects/tasks/main.yml47
-rw-r--r--roles/openshift_projects/vars/main.yml2
3 files changed, 64 insertions, 0 deletions
diff --git a/roles/openshift_projects/meta/main.yml b/roles/openshift_projects/meta/main.yml
new file mode 100644
index 000000000..107a70b83
--- /dev/null
+++ b/roles/openshift_projects/meta/main.yml
@@ -0,0 +1,15 @@
+---
+galaxy_info:
+ author: Jason DeTiberus
+ description: OpenShift Projects
+ company: Red Hat, Inc.
+ license: Apache License, Version 2.0
+ min_ansible_version: 1.9
+ platforms:
+ - name: EL
+ versions:
+ - 7
+ categories:
+ - cloud
+dependencies:
+- { role: openshift_facts }
diff --git a/roles/openshift_projects/tasks/main.yml b/roles/openshift_projects/tasks/main.yml
new file mode 100644
index 000000000..62a357cf7
--- /dev/null
+++ b/roles/openshift_projects/tasks/main.yml
@@ -0,0 +1,47 @@
+---
+- name: Create temp directory for kubeconfig
+ command: mktemp -d /tmp/openshift-ansible-XXXXXX
+ register: mktemp
+ changed_when: False
+
+- name: Copy the admin client config(s)
+ command: >
+ cp {{ openshift_master_config_dir }}/admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig
+ changed_when: False
+
+- name: Determine if projects exist
+ command: >
+ {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig
+ get projects {{ item.key }} -o json
+ with_dict: "{{ openshift_projects }}"
+ failed_when: false
+ changed_when: false
+ register: project_test
+
+- name: Create projects
+ command: >
+ {{ openshift.common.admin_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig
+ new-project {{ item.item.key }}
+ {% if item.item.value.default_node_selector | default(none) != none %}
+ {{ '--node-selector=' ~ item.item.value.default_node_selector }}
+ {% endif %}
+ when: item.rc == 1
+ with_items:
+ - "{{ project_test.results }}"
+
+- name: Update project default node selector if necessary
+ command: >
+ {{ openshift.common.client_binary }}
+ --config={{ mktemp.stdout }}/admin.kubeconfig patch namespace {{ item.item.key }}
+ -p '{"metadata": {"annotations": {"openshift.io/node-selector": "{{ item.item.value.default_node_selector }}"}}}'
+ when: "{{ item.rc == 0 and item.item.value.default_node_selector | default(none) != none
+ and item.item.value.default_node_selector | default(none) != (item.stdout | from_json).metadata.annotations['openshift.io/node-selector'] | default(none) }}"
+ with_items:
+ - "{{ project_test.results }}"
+ register: annotate_project
+
+- name: Delete temp directory
+ file:
+ name: "{{ mktemp.stdout }}"
+ state: absent
+ changed_when: False
diff --git a/roles/openshift_projects/vars/main.yml b/roles/openshift_projects/vars/main.yml
new file mode 100644
index 000000000..9967e26f4
--- /dev/null
+++ b/roles/openshift_projects/vars/main.yml
@@ -0,0 +1,2 @@
+---
+openshift_master_config_dir: "{{ openshift.common.config_base }}/master"