From ccf9acd9dad5c9dc2e1640f417a9109c9042a689 Mon Sep 17 00:00:00 2001
From: Thomas Wiest <twiest@redhat.com>
Date: Mon, 12 Oct 2015 15:29:35 -0400
Subject: Fixed GCE playbooks so that they're more like the AWS playbooks.

Namely the GCE playbooks now:
- Create infra nodes
- Correctly label nodes in OpenShift
- Setup masters as nodes as well (needed for sdn)
- Removed set_infra_launch_facts_tasks.yml as it's not used anymore.
---
 .../openshift-cluster/tasks/launch_instances.yml    | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

(limited to 'playbooks/gce/openshift-cluster/tasks')

diff --git a/playbooks/gce/openshift-cluster/tasks/launch_instances.yml b/playbooks/gce/openshift-cluster/tasks/launch_instances.yml
index e300b5b5a..c428cb465 100644
--- a/playbooks/gce/openshift-cluster/tasks/launch_instances.yml
+++ b/playbooks/gce/openshift-cluster/tasks/launch_instances.yml
@@ -20,22 +20,37 @@
       - host-type-{{ type }}
       - sub-host-type-{{ g_sub_host_type }}
       - env-host-type-{{ cluster }}-openshift-{{ type }}
-  when: instances |length > 0 
+  when: instances |length > 0
   register: gce
 
+- set_fact:
+    node_label:
+      # There doesn't seem to be a way to get the region directly, so parse it out of the zone.
+      region: "{{ gce.zone | regex_replace('^(.*)-.*$', '\\\\1') }}"
+      type: "{{ g_sub_host_type }}"
+  when: instances |length > 0 and type == "node"
+
+- set_fact:
+    node_label:
+      # There doesn't seem to be a way to get the region directly, so parse it out of the zone.
+      region: "{{ gce.zone | regex_replace('^(.*)-.*$', '\\\\1') }}"
+      type: "{{ type }}"
+  when: instances |length > 0 and type != "node"
+
 - name: Add new instances to groups and set variables needed
   add_host:
     hostname: "{{ item.name }}"
-    ansible_ssh_host: "{{ item.name }}"
+    ansible_ssh_host: "{{ item.public_ip }}"
     ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user | default(ansible_ssh_user, true) }}"
     ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
     groups: "{{ item.tags | oo_prepend_strings_in_list('tag_') | join(',') }}"
     gce_public_ip: "{{ item.public_ip }}"
     gce_private_ip: "{{ item.private_ip }}"
+    openshift_node_labels: "{{ node_label }}"
   with_items: gce.instance_data | default([], true)
 
 - name: Wait for ssh
-  wait_for: port=22 host={{ item.name }}
+  wait_for: port=22 host={{ item.public_ip }}
   with_items: gce.instance_data | default([], true)
 
 - name: Wait for user setup
-- 
cgit v1.2.3