main.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ---
  2. - name: create the cluster-autoscaler serviceaccount
  3. oc_serviceaccount:
  4. name: "{{ openshift_cluster_autoscaler_serviceaccount }}"
  5. namespace: "{{ openshift_cluster_autoscaler_namespace }}"
  6. state: "{{ openshift_cluster_autoscaler_state }}"
  7. - name: copy the cluster-autoscaler files
  8. copy:
  9. src: "{{ item }}"
  10. dest: "{{ openshift_cluster_autoscaler_template_location }}/{{ item }}"
  11. with_items:
  12. - clusterrole.yml
  13. - role.yml
  14. when: openshift_cluster_autoscaler_state == 'present'
  15. - name: "Ensure the cluster-autoscaler roles are {{ openshift_cluster_autoscaler_state }}"
  16. oc_obj:
  17. namespace: "{{ openshift_cluster_autoscaler_namespace }}"
  18. state: "{{ openshift_cluster_autoscaler_state }}"
  19. kind: "{{ item.type }}"
  20. name: "{{ item.name }}"
  21. delete_after: "{{ openshift_cluster_autoscaler_delete_config }}"
  22. files:
  23. - "{{ openshift_cluster_autoscaler_template_location }}/{{ item.fname }}"
  24. with_items:
  25. - fname: clusterrole.yml
  26. type: clusterrole
  27. name: "system:{{ openshift_cluster_autoscaler_name }}"
  28. - fname: role.yml
  29. type: role
  30. name: "{{ openshift_cluster_autoscaler_name }}"
  31. - include_tasks: aws.yml
  32. when: openshift_cluster_autoscaler_cloud_provider == 'aws'
  33. - name: create the policies
  34. oc_adm_policy_user:
  35. state: "{{ openshift_cluster_autoscaler_state }}"
  36. user: "system:serviceaccount:openshift-infra:{{ openshift_cluster_autoscaler_serviceaccount }}"
  37. namespace: "{{ openshift_cluster_autoscaler_namespace }}"
  38. resource_kind: "{{ item.name }}"
  39. resource_name: cluster-autoscaler
  40. role_namespace: "{{ item.role_namespace | default(omit) }}"
  41. with_items:
  42. - name: cluster-role
  43. - name: role
  44. role_namespace: "{{ openshift_cluster_autoscaler_namespace }}"
  45. - name: "grant cluster-reader to {{ openshift_cluster_autoscaler_serviceaccount }}"
  46. oc_adm_policy_user:
  47. state: "{{ openshift_cluster_autoscaler_state }}"
  48. user: "system:serviceaccount:{{ openshift_cluster_autoscaler_namespace }}:{{ openshift_cluster_autoscaler_serviceaccount }}"
  49. namespace: "{{ openshift_cluster_autoscaler_namespace }}"
  50. resource_name: cluster-reader
  51. resource_kind: cluster-role
  52. - name: laydown the deployment file for cluster-autoscaler
  53. template:
  54. src: cluster-autoscaler.j2
  55. dest: "{{ openshift_cluster_autoscaler_template_location }}/{{ openshift_cluster_autoscaler_template_name }}"
  56. when: openshift_cluster_autoscaler_state == 'present'
  57. - name: "Ensure the cluster-autoscaler is {{ openshift_cluster_autoscaler_state }}"
  58. oc_obj:
  59. namespace: "{{ openshift_cluster_autoscaler_namespace }}"
  60. state: "{{ openshift_cluster_autoscaler_state }}"
  61. kind: deployment
  62. name: "{{ openshift_cluster_autoscaler_name }}"
  63. delete_after: "{{ openshift_cluster_autoscaler_delete_config }}"
  64. files:
  65. - "{{ openshift_cluster_autoscaler_template_location }}/{{ openshift_cluster_autoscaler_template_name }}"