provision_instance.yml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ---
  2. - name: create resource group
  3. azure_rm_resourcegroup:
  4. name: "{{ openshift_azure_resource_group_name }}"
  5. location: "{{ openshift_azure_resource_location }}"
  6. tags:
  7. now: "{{ lookup('pipe', 'date +%s') }}"
  8. - name: create vnet
  9. azure_rm_virtualnetwork:
  10. name: vnet
  11. resource_group: "{{ openshift_azure_resource_group_name }}"
  12. address_prefixes:
  13. - 192.168.0.0/16
  14. - name: create subnet
  15. azure_rm_subnet:
  16. name: subnet
  17. resource_group: "{{ openshift_azure_resource_group_name }}"
  18. virtual_network: vnet
  19. address_prefix: 192.168.0.0/24
  20. - name: calculate input image
  21. command: az image list -g "{{ image_resource_group }}" --query "[?starts_with(name, '{{ image_prefix }}-') && tags.valid=='true'] | sort_by(@, &name) | [-1]"
  22. register: input_image
  23. - name: create vm
  24. command: >
  25. az vm create
  26. -n vm
  27. -g "{{ openshift_azure_resource_group_name }}"
  28. --size Standard_D4s_v3
  29. --image "{{ (input_image.stdout | from_json).id }}"
  30. --storage-sku Standard_LRS
  31. --admin-username cloud-user
  32. --ssh-dest-key-path /home/cloud-user/.ssh/authorized_keys
  33. --ssh-key-value "{{ openshift_azure_vm_ssh_public_key }}"
  34. {% if create_args is defined %}{{ create_args }}{% endif %}
  35. register: vm
  36. - name: add vm to inventory
  37. add_host:
  38. groups: nodes
  39. name: "{{ (vm.stdout | from_json).publicIpAddress }}"
  40. ansible_ssh_user: cloud-user
  41. ansible_become: True