create-project.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. - name: Create an ICHP-lookalike project.
  16. hosts: workstation.lab.example.com
  17. gather_subset: min
  18. become: no
  19. tasks:
  20. - name: Ensure that the parameters are specified.
  21. ansible.builtin.assert:
  22. that:
  23. - project is defined
  24. - user is defined
  25. success_msg: "OK, got all parameters, continuing."
  26. fail_msg: "FATAL: You must specify the \"user\" and \"project\" variables at minimum."
  27. - name: Check that rbac parameter is an acceptable value.
  28. ansible.builtin.assert:
  29. that:
  30. - (rbac | default('editor')) in ['admin', 'editor', 'viewer']
  31. success_msg: "OK, rbac role is fine."
  32. fail_msg: "FATAL: \"rbac\" role can only be one of ['admin', 'editor', 'viewer']."
  33. # Get auth info, and test comms.
  34. - include_role:
  35. name: check-env
  36. - include_role:
  37. name: create-ichp-project
  38. vars:
  39. role:
  40. requester: "{{ user }}"
  41. name: "{{ project }}"
  42. displayname: "{{ displayname | default(project) }}"
  43. rbac_level: "ichp-project-{{ rbac | default('editor') }}"
  44. #
  45. # NOTE: Other options that should be specified via vars files:
  46. #
  47. #egress_ip: an available egress IP to allocate to the project
  48. #quota: compute resourcequotas
  49. # requests: compute reservation
  50. # cpu: max cpu reserved (1500m, 1.5 CPU)
  51. # memory: max memory reserved (2048Mi, 2Gi)
  52. # limits: compute limits
  53. # cpu: max cpu consumed (4000m, 4 CPUs)
  54. # memory: max memory consumed (4096Mi, 4Gi)
  55. # lrange: compute limitranges, for both container and pod
  56. # default: default limits and requests
  57. # limit:
  58. # cpu: role.lrange.min.cpu * role.lrange.ratio.cpu
  59. # memory: role.lrange.min.memory * role.lrange.ratio.memory
  60. # request:
  61. # cpu: defaults to whatever role.lrange.min.cpu is
  62. # memory: defaults to whatever role.lrange.min.memory is
  63. # max: maximum limits
  64. # cpu: maximum cpu limit (4000m, 4 cpus)
  65. # memory: maximum memory limit (4096Mi, 4Gi)
  66. # min: minimum requests
  67. # cpu: minimum requested cpu (50m, 5%)
  68. # memory: minimum requested memory (64Mi)
  69. # ratio: max limit-to-request ratio (x-to-1)
  70. # cpu: cpu lrr (4)
  71. # memory: memory lrr (4)
  72. ...