etcd.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. ---
  2. # To run contiv-etcd in a container as non-root, we need to match the uid/gid
  3. # with the filesystem permissions on the host.
  4. - name: Contiv etcd | Create local unix group
  5. group:
  6. name: "{{ contiv_etcd_system_group }}"
  7. gid: "{{ contiv_etcd_system_gid }}"
  8. system: yes
  9. - name: Contiv etcd | Create local unix user
  10. user:
  11. name: "{{ contiv_etcd_system_user }}"
  12. createhome: no
  13. uid: "{{ contiv_etcd_system_uid }}"
  14. group: "{{ contiv_etcd_system_group }}"
  15. home: "{{ contiv_etcd_data_dir }}"
  16. shell: /bin/false
  17. system: yes
  18. - name: Contiv etcd | Create directories
  19. file:
  20. path: "{{ item }}"
  21. state: directory
  22. mode: g-rwx,o-rwx
  23. owner: "{{ contiv_etcd_system_user }}"
  24. group: "{{ contiv_etcd_system_group }}"
  25. setype: svirt_sandbox_file_t
  26. seuser: system_u
  27. serole: object_r
  28. selevel: s0
  29. recurse: yes
  30. with_items:
  31. - "{{ contiv_etcd_data_dir }}"
  32. - "{{ contiv_etcd_conf_dir }}"
  33. - name: Contiv etcd | Create contiv-etcd openshift user
  34. oc_serviceaccount:
  35. state: present
  36. name: contiv-etcd
  37. namespace: kube-system
  38. run_once: true
  39. - name: Contiv etcd | Create temp directory for doing work
  40. command: mktemp -d /tmp/openshift-contiv-XXXXXX
  41. register: mktemp
  42. changed_when: False
  43. # For things that pass temp files between steps, we want to make sure they
  44. # run on the same node.
  45. delegate_to: "{{ groups.oo_masters_to_config.0 }}"
  46. run_once: true
  47. - name: Contiv etcd | Create etcd-scc.yml from template
  48. template:
  49. src: etcd-scc.yml.j2
  50. dest: "{{ mktemp.stdout }}/etcd-scc.yml"
  51. delegate_to: "{{ groups.oo_masters_to_config.0 }}"
  52. run_once: true
  53. - name: Contiv etcd | Create etcd.yml from template
  54. template:
  55. src: etcd-daemonset.yml.j2
  56. dest: "{{ mktemp.stdout }}/etcd-daemonset.yml"
  57. delegate_to: "{{ groups.oo_masters_to_config.0 }}"
  58. run_once: true
  59. - name: Contiv etcd | Create etcd-proxy.yml from template
  60. template:
  61. src: etcd-proxy-daemonset.yml.j2
  62. dest: "{{ mktemp.stdout }}/etcd-proxy-daemonset.yml"
  63. delegate_to: "{{ groups.oo_masters_to_config.0 }}"
  64. run_once: true
  65. - name: Contiv etcd | Add etcd scc
  66. oc_obj:
  67. state: present
  68. namespace: "kube-system"
  69. kind: SecurityContextConstraints
  70. name: contiv-etcd
  71. files:
  72. - "{{ mktemp.stdout }}/etcd-scc.yml"
  73. delegate_to: "{{ groups.oo_masters_to_config.0 }}"
  74. run_once: true
  75. # Always "import" this file, k8s won't do anything if it matches exactly what
  76. # is already in the cluster.
  77. - name: Contiv etcd | Add etcd daemonset
  78. oc_obj:
  79. state: present
  80. namespace: "kube-system"
  81. kind: daemonset
  82. name: contiv-etcd
  83. files:
  84. - "{{ mktemp.stdout }}/etcd-daemonset.yml"
  85. delegate_to: "{{ groups.oo_masters_to_config.0 }}"
  86. run_once: true
  87. - name: Contiv etcd | Add etcd-proxy daemonset
  88. oc_obj:
  89. state: present
  90. namespace: "kube-system"
  91. kind: daemonset
  92. name: contiv-etcd-proxy
  93. files:
  94. - "{{ mktemp.stdout }}/etcd-proxy-daemonset.yml"
  95. delegate_to: "{{ groups.oo_masters_to_config.0 }}"
  96. run_once: true
  97. - name: Contiv etcd | Delete temp directory
  98. file:
  99. name: "{{ mktemp.stdout }}"
  100. state: absent
  101. changed_when: False
  102. delegate_to: "{{ groups.oo_masters_to_config.0 }}"
  103. run_once: true