create-project.yml 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ---
  2. # Creates an ICHP-like project in the cluster.
  3. #
  4. # Pass variables to this playbook on the command line (-e):
  5. #
  6. # user: the user requesting the project (role.requester)
  7. # project: the name of the project (role.name)
  8. # rbac: last token of "ichp-project-${foo}"
  9. # (admin, editor, viewer, debugger)
  10. # (becomes role.rbac_level, defaults to "editor")
  11. #
  12. # For anything more complex, create a vars file and load it (-e @file.yml).
  13. # See the structure of the vars below. Generally do not set egress_ip.
  14. #
  15. # TODO: establish egress IP? (openshift.egress_range)
  16. # TODO: remove egress IPs without their corresponding projects
  17. #
  18. - name: Create an ICHP-lookalike project.
  19. hosts: workstation.lab.example.com
  20. gather_subset: min
  21. become: no
  22. tasks:
  23. - name: Ensure that the parameters are specified.
  24. ansible.builtin.assert:
  25. that:
  26. - project is defined
  27. - user is defined
  28. success_msg: "OK, got all parameters, continuing."
  29. fail_msg: "FATAL: You must specify the \"user\" and \"project\" variables at minimum."
  30. - name: Check that rbac parameter is an acceptable value.
  31. ansible.builtin.assert:
  32. that:
  33. - (rbac | default('editor')) in ['admin', 'editor', 'viewer']
  34. success_msg: "OK, rbac role is fine."
  35. fail_msg: "FATAL: \"rbac\" role can only be one of ['admin', 'editor', 'viewer']."
  36. # Get auth info, and test comms.
  37. - include_role:
  38. name: check-env
  39. - include_role:
  40. name: create-ichp-project
  41. vars:
  42. role:
  43. requester: "{{ user }}"
  44. name: "{{ project }}"
  45. displayname: "{{ displayname | default(project) }}"
  46. rbac_level: "ichp-project-{{ rbac | default('editor') }}"
  47. egress_ip: "192.168.50.38"
  48. #egress_ip: an available egress IP to allocate to the project
  49. #quota: compute resourcequotas
  50. # requests: compute reservation
  51. # cpu: max cpu reserved (1500m, 1.5 CPU)
  52. # memory: max memory reserved (2048Mi, 2Gi)
  53. # limits: compute limits
  54. # cpu: max cpu consumed (4000m, 4 CPUs)
  55. # memory: max memory consumed (4096Mi, 4Gi)
  56. #lrange: compute limitranges, for both container and pod
  57. # default: default limits and requests (no defaults)
  58. # limit:
  59. # cpu:
  60. # memory:
  61. # request:
  62. # cpu:
  63. # memory:
  64. # max: maximum limits
  65. # cpu: maximum cpu limit (4000m, 4 cpus)
  66. # memory: maximum memory limit (4096Mi, 4Gi)
  67. # min: minimum requests
  68. # cpu: minimum requested cpu (50m, 5%)
  69. # memory: minimum requested memory (64Mi)
  70. # ratio: max limit-to-request ratio (x-to-1)
  71. # cpu: cpu lrr (4)
  72. # memory: memory lrr (4)
  73. ...