diff options
author | Andrew Butcher <abutcher@afrolegs.com> | 2016-07-08 10:11:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-08 10:11:04 -0400 |
commit | 69b47af2aa3986ac18d5fdddf5dc6ed478fe08c4 (patch) | |
tree | 0419cfc12d414a95c987f7667f6618fba923c522 /roles/openshift_projects/tasks | |
parent | 8a0c9b6b6a9820b38694cb23979ffc7a8c358588 (diff) | |
parent | 57dfae185d3d0e02ebe515263c54867bee37b45e (diff) | |
download | openshift-69b47af2aa3986ac18d5fdddf5dc6ed478fe08c4.tar.gz openshift-69b47af2aa3986ac18d5fdddf5dc6ed478fe08c4.tar.bz2 openshift-69b47af2aa3986ac18d5fdddf5dc6ed478fe08c4.tar.xz openshift-69b47af2aa3986ac18d5fdddf5dc6ed478fe08c4.zip |
Merge pull request #2023 from abutcher/openshift-hosted
Various hosted component improvements
Diffstat (limited to 'roles/openshift_projects/tasks')
-rw-r--r-- | roles/openshift_projects/tasks/main.yml | 47 |
1 files changed, 47 insertions, 0 deletions
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 |