create-project.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. #
  48. # NOTE: Other options that should be specified via vars files:
  49. #
  50. #egress_ip: an available egress IP to allocate to the project
  51. #quota: compute resourcequotas
  52. # requests: compute reservation
  53. # cpu: max cpu reserved (1500m, 1.5 CPU)
  54. # memory: max memory reserved (2048Mi, 2Gi)
  55. # limits: compute limits
  56. # cpu: max cpu consumed (4000m, 4 CPUs)
  57. # memory: max memory consumed (4096Mi, 4Gi)
  58. # lrange: compute limitranges, for both container and pod
  59. # default: default limits and requests
  60. # limit:
  61. # cpu: role.lrange.min.cpu * role.lrange.ratio.cpu
  62. # memory: role.lrange.min.memory * role.lrange.ratio.memory
  63. # request:
  64. # cpu: defaults to whatever role.lrange.min.cpu is
  65. # memory: defaults to whatever role.lrange.min.memory is
  66. # max: maximum limits
  67. # cpu: maximum cpu limit (4000m, 4 cpus)
  68. # memory: maximum memory limit (4096Mi, 4Gi)
  69. # min: minimum requests
  70. # cpu: minimum requested cpu (50m, 5%)
  71. # memory: minimum requested memory (64Mi)
  72. # ratio: max limit-to-request ratio (x-to-1)
  73. # cpu: cpu lrr (4)
  74. # memory: memory lrr (4)
  75. ...