diff options
author | Russell Teague <rteague@redhat.com> | 2017-03-14 15:55:03 -0400 |
---|---|---|
committer | Russell Teague <rteague@redhat.com> | 2017-03-17 14:09:50 -0400 |
commit | d86b2700328761c30d4525941804425164126a9d (patch) | |
tree | 5a9fa1a06d3a49adf53e383f19398952ed18674b /roles/openshift_projects | |
parent | b6b20207a510bd959b586bbeec9c19a7013a79cf (diff) | |
download | openshift-d86b2700328761c30d4525941804425164126a9d.tar.gz openshift-d86b2700328761c30d4525941804425164126a9d.tar.bz2 openshift-d86b2700328761c30d4525941804425164126a9d.tar.xz openshift-d86b2700328761c30d4525941804425164126a9d.zip |
Refactor openshift_projects role
Diffstat (limited to 'roles/openshift_projects')
-rw-r--r-- | roles/openshift_projects/meta/main.yml | 15 | ||||
-rw-r--r-- | roles/openshift_projects/tasks/main.yml | 50 | ||||
-rw-r--r-- | roles/openshift_projects/vars/main.yml | 2 |
3 files changed, 5 insertions, 62 deletions
diff --git a/roles/openshift_projects/meta/main.yml b/roles/openshift_projects/meta/main.yml deleted file mode 100644 index 107a70b83..000000000 --- a/roles/openshift_projects/meta/main.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -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 index 30d58afd3..e7252ee99 100644 --- a/roles/openshift_projects/tasks/main.yml +++ b/roles/openshift_projects/tasks/main.yml @@ -1,47 +1,7 @@ --- -- 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.client_binary }} adm --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 + oc_project: + name: "{{ item.key }}" + node_selector: + - "{{ item.value.default_node_selector }}" + with_dict: "{{ openshift_projects }}" diff --git a/roles/openshift_projects/vars/main.yml b/roles/openshift_projects/vars/main.yml deleted file mode 100644 index 9967e26f4..000000000 --- a/roles/openshift_projects/vars/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -openshift_master_config_dir: "{{ openshift.common.config_base }}/master" |