main.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Update sysctl to handle incorrectly routed traffic when iptables is bypassed
  16. copy:
  17. src: k8s.conf
  18. dest: "{{ k8s_conf_dest }}"
  19. owner: root
  20. group: root
  21. mode: "{{ k8s_conf_file_mode }}"
  22. tags: install
  23. - name: Update sysctl
  24. command: /sbin/sysctl --system
  25. changed_when: true
  26. tags: install
  27. - block:
  28. - name: Add kubernetes repo
  29. yum_repository:
  30. name: kubernetes
  31. description: kubernetes
  32. baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
  33. enabled: yes
  34. gpgcheck: no
  35. repo_gpgcheck: no
  36. gpgkey:
  37. - https://packages.cloud.google.com/yum/doc/yum-key.gpg
  38. - https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
  39. tags: install
  40. - name: Install k8s packages
  41. package:
  42. name: "{{ k8s_packages }}"
  43. state: present
  44. tags: install
  45. - name: Versionlock kubernetes
  46. command: "yum versionlock '{{ item }}'"
  47. args:
  48. warn: false
  49. with_items:
  50. - "{{ k8s_packages }}"
  51. changed_when: true
  52. tags: install
  53. when: os_supported_leap not in compute_os
  54. - block:
  55. - name: Add kubernetes repo
  56. zypper_repository:
  57. name: google-k8s
  58. repo: "{{ k8s_repo_leap }}"
  59. state: present
  60. autorefresh: yes
  61. disable_gpg_check: yes
  62. tags: install
  63. - name: Import rpm-package key for installing kubernetes
  64. rpm_key:
  65. key: "{{ rpm_pkg_leap }}"
  66. state: present
  67. tags: install
  68. - name: Import yum key for installing kubernetes
  69. rpm_key:
  70. key: "{{ yum_key_leap }}"
  71. state: present
  72. tags: install
  73. - name: Import gpg-pubkey key for installing kubernetes
  74. command: "{{ gpg_pubkey_leap }}"
  75. args:
  76. warn: false
  77. changed_when: false
  78. tags: install
  79. - name: Refresh repositories and installing conntrack-tools
  80. package:
  81. name: conntrack-tools
  82. state: present
  83. tags: install
  84. - name: Install Kubeadm
  85. ansible.builtin.expect:
  86. command: zypper install --oldpackage "{{ kubeadm_version }}"
  87. responses:
  88. (.*) [1/2/c/d/?](.): '2'
  89. (.*)(y): 'y'
  90. register: kubeadm_status
  91. until: kubeadm_status is not failed
  92. retries: "{{ max_retries }}"
  93. tags: install
  94. - name: Install Kubelet
  95. ansible.builtin.expect:
  96. command: zypper install --oldpackage "{{ kubelet_version }}"
  97. responses:
  98. (.*) [1/2/c/d/?](.): '2'
  99. (.*)(y): 'y'
  100. register: kubelet_status
  101. until: kubelet_status is not failed
  102. retries: "{{ max_retries }}"
  103. tags: install
  104. - name: Install Kubectl
  105. zypper:
  106. name: "{{ kubectl_version }}"
  107. state: present
  108. oldpackage: yes
  109. force: yes
  110. register: kubectl_status
  111. until: kubectl_status is not failed
  112. retries: "{{ max_retries }}"
  113. tags: install
  114. - name: Versionlocking kubeadm
  115. command: zypper addlock "{{ kubeadm_version }}"
  116. args:
  117. warn: false
  118. changed_when: false
  119. tags: install
  120. - name: Versionlocking kubectl
  121. command: zypper addlock "{{ kubelet_version }}"
  122. args:
  123. warn: false
  124. changed_when: false
  125. tags: install
  126. - name: Versionlocking kubelet
  127. command: zypper addlock "{{ kubectl_version }}"
  128. args:
  129. warn: false
  130. changed_when: false
  131. tags: install
  132. when: ( os_supported_leap in compute_os ) and ( ansible_distribution_version >= os_supported_leap_version )
  133. - name: Start and enable docker service
  134. service:
  135. name: docker
  136. state: restarted
  137. enabled: yes
  138. tags: install
  139. - name: Start and enable kubernetes - kubelet
  140. service:
  141. name: kubelet
  142. state: restarted
  143. enabled: yes