ssh_bastion.yml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ---
  2. - name: Create ssh bastion project
  3. oc_project:
  4. name: openshift-ssh-bastion
  5. description: openshift-ssh-bastion
  6. node_selector: ""
  7. kubeconfig: "{{ kubeconfig_path }}"
  8. - name: Create ssh keys secret
  9. oc_secret:
  10. state: present
  11. namespace: openshift-ssh-bastion
  12. name: ssh-host-keys
  13. kubeconfig: "{{ kubeconfig_path }}"
  14. files:
  15. - name: ssh_host_rsa_key
  16. path: ../../inventory/dynamic/injected/ssh-privatekey
  17. - name: sshd_config
  18. path: files/sshd_config
  19. no_log: true
  20. - name: Create ssh bastion
  21. command: "oc --kubeconfig={{ kubeconfig_path }} apply -f files/"
  22. - name: Wait for deployment to rollout
  23. command: "oc --kubeconfig={{ kubeconfig_path }} -n openshift-ssh-bastion rollout status deployment ssh-bastion -w"
  24. - name: Get ssh bastion address
  25. oc_obj:
  26. name: ssh-bastion
  27. kind: service
  28. namespace: openshift-ssh-bastion
  29. kubeconfig: "{{ kubeconfig_path }}"
  30. state: present
  31. register: svc
  32. until:
  33. - svc.results is defined
  34. - svc.results.returncode is defined
  35. - svc.results.returncode == 0
  36. - svc.results.results is defined
  37. - svc.results.results | length > 0
  38. - svc.results.results[0].status is defined
  39. - svc.results.results[0].status.loadBalancer is defined
  40. - svc.results.results[0].status.loadBalancer.ingress | length > 0
  41. - svc.results.results[0].status.loadBalancer.ingress[0].hostname is defined
  42. retries: 36
  43. delay: 5
  44. - set_fact:
  45. ssh_bastion: "{{ svc.results.results[0].status.loadBalancer.ingress[0].hostname }}"