bootstrap_changes.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. ---
  2. - name: Check for existing node-config.yaml
  3. stat:
  4. path: "{{ openshift.common.config_base }}/node/node-config.yaml"
  5. register: existing_node_config
  6. - name: Copy existing configuration to bootstrap configuration
  7. copy:
  8. remote_src: true
  9. src: "{{ openshift.common.config_base }}/node/node-config.yaml"
  10. dest: "{{ openshift.common.config_base }}/node/bootstrap-node-config.yaml"
  11. force: no
  12. owner: root
  13. group: root
  14. mode: 0600
  15. when: existing_node_config.stat.exists
  16. - name: Find existing credentials
  17. find:
  18. paths:
  19. - "{{ openshift.common.config_base }}/node"
  20. patterns:
  21. - system*.kubeconfig
  22. - node.kubeconfig
  23. register: system_kubeconfigs
  24. - name: Copy existing credentials to bootstrap credentials
  25. copy:
  26. remote_src: true
  27. src: "{{ item }}"
  28. dest: "{{ openshift.common.config_base }}/node/bootstrap.kubeconfig"
  29. force: no
  30. owner: root
  31. group: root
  32. mode: 0600
  33. with_items: "{{ system_kubeconfigs.files | default([]) | map(attribute='path') | list }}"
  34. - name: Remove non-bootstrap configuration
  35. file:
  36. path: "{{ item }}"
  37. state: absent
  38. with_items:
  39. - "{{ openshift.common.config_base }}/node/node.kubeconfig"
  40. - "{{ openshift.common.config_base }}/node/node-config.yaml"
  41. - name: Update node-config to prepare for bootstrapping
  42. yedit:
  43. src: "{{ openshift.common.config_base }}/node/bootstrap-node-config.yaml"
  44. edits:
  45. - key: servingInfo.certFile
  46. value: ""
  47. - key: servingInfo.clientCA
  48. value: client-ca.crt
  49. - key: servingInfo.keyFile
  50. value: ""
  51. - key: kubeletArguments.bootstrap-kubeconfig
  52. value:
  53. - "{{ openshift.common.config_base }}/node/bootstrap.kubeconfig"
  54. - key: kubeletArguments.rotate-certificates
  55. value:
  56. - "true"
  57. - key: kubeletArguments.cert-dir
  58. value:
  59. - "{{ openshift.common.config_base }}/node/certificates"
  60. - key: kubeletArguments.feature-gates
  61. value:
  62. - RotateKubeletClientCertificate=true,RotateKubeletServerCertificate=true
  63. - key: masterKubeConfig
  64. value: node.kubeconfig
  65. - name: Use the admin.kubeconfig for the kubelet bootstrap identity
  66. copy:
  67. remote_src: true
  68. src: "{{ openshift.common.config_base }}/master/admin.kubeconfig"
  69. dest: "{{ openshift.common.config_base }}/node/bootstrap.kubeconfig"
  70. force: yes
  71. owner: root
  72. group: root
  73. mode: 0600
  74. when: inventory_hostname in groups.oo_masters_to_config
  75. - name: Update symlink master CA for docker-registry (name changed)
  76. file:
  77. src: "{{ item }}"
  78. dest: "/etc/docker/certs.d/docker-registry.default.svc:5000/{{ item | basename }}"
  79. state: link
  80. force: yes
  81. with_items:
  82. - "{{ openshift.common.config_base }}/node/client-ca.crt"
  83. - name: Remove previous bootstrap certificates
  84. file:
  85. path: "{{ openshift.common.config_base }}/node/certificates"
  86. state: absent
  87. - name: Determine if node already has a dynamic config group
  88. command: grep -E '^BOOTSTRAP_CONFIG_NAME=.+' "/etc/sysconfig/{{ openshift_service_type }}-node"
  89. ignore_errors: true
  90. register: existing
  91. - name: Update the sysconfig to group "{{ r_node_dynamic_config_name }}"
  92. lineinfile:
  93. dest: "/etc/sysconfig/{{ openshift_service_type }}-node"
  94. line: "BOOTSTRAP_CONFIG_NAME={{ r_node_dynamic_config_name }}"
  95. regexp: "^BOOTSTRAP_CONFIG_NAME=.*"
  96. when: r_node_dynamic_config_force|default(False) or existing is failed
  97. - name: Set up node-config.yml if dynamic configuration is off
  98. copy:
  99. remote_src: true
  100. src: "{{ openshift.common.config_base }}/node/bootstrap-node-config.yaml"
  101. dest: "{{ openshift.common.config_base }}/node/node-config.yaml"
  102. force: no
  103. owner: root
  104. group: root
  105. mode: 0600
  106. when: r_node_dynamic_config_name|length == 0