launch.yml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ---
  2. - name: Launch instance(s)
  3. hosts: localhost
  4. connection: local
  5. gather_facts: no
  6. vars:
  7. inst_names: "{{ oo_new_inst_names }}"
  8. machine_type: n1-standard-1
  9. image: libra-rhel7
  10. vars_files:
  11. - vars.yml
  12. tasks:
  13. - name: Launch instances
  14. gce:
  15. instance_names: "{{ inst_names }}"
  16. machine_type: "{{ machine_type }}"
  17. image: "{{ image }}"
  18. service_account_email: "{{ gce_service_account_email }}"
  19. pem_file: "{{ gce_pem_file }}"
  20. project_id: "{{ gce_project_id }}"
  21. tags: "{{ oo_new_inst_tags }}"
  22. register: gce
  23. - name: Add new instances public IPs to oo_nodes_to_config
  24. add_host: "hostname={{ item.name }} ansible_ssh_host={{ item.public_ip }} groupname=oo_nodes_to_config"
  25. with_items: gce.instance_data
  26. - name: Wait for ssh
  27. wait_for: "port=22 host={{ item.public_ip }}"
  28. with_items: gce.instance_data
  29. - debug: var=gce
  30. - name: Wait for root user setup
  31. command: "ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null root@{{ item.public_ip }} echo root user is setup"
  32. register: result
  33. until: result.rc == 0
  34. retries: 20
  35. delay: 10
  36. with_items: gce.instance_data
  37. # Apply the configs, separate so that just the configs can be run by themselves
  38. - include: config.yml
  39. # Always bounce service to pick up new credentials
  40. #- name: "Restart instances"
  41. # hosts: oo_nodes_to_config
  42. # connection: ssh
  43. # user: root
  44. # tasks:
  45. # - debug: var=groups.oo_nodes_to_config
  46. # - name: Restart OpenShift
  47. # service: name=openshift-node enabled=yes state=restarted