summaryrefslogtreecommitdiff
path: root/ansible/roles/k3s-install/tasks/main.yml
blob: b254c8dcf57217ffe7ab93ec20302f41fee0dfcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
- name: "prepare install k3s"
  shell: sed -ie "s/SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config

#- name: "execute k3s install"
#  shell: curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn INSTALL_K3S_SKIP_ENABLE=true  sh -

- name: "get k3s to dest"
  get_url:
    url: https://repo.geedge.net/filerepo/install/release/os-build-files/k3s/v1.29.2/k3s
    dest: /usr/bin/k3s
    url_username: "{{ lookup('env', 'PULP_REPO_USERNAME') }}"
    url_password: "{{ lookup('env', 'PULP_REPO_PASSWORD') }}"
    mode: 0755


- name: "Create /var/lib/rancher/k3s/agent/images directory"
  file:
    path: "/var/lib/rancher/k3s/agent/images"
    state: directory
    mode: '0755'

# - name: "copy k3s-airgap-images-amd64.tar to destination"
#   copy:
#     src: "{{ role_path }}/files/k3s-airgap-images-amd64.tar"
#     dest: /var/lib/rancher/k3s/agent/images/

- name: "get k3s-airgap-images-amd64.tar to dest"
  get_url:
    url: https://repo.geedge.net/filerepo/install/release/os-build-files/k3s/v1.29.2/k3s-airgap-images-amd64.tar
    dest: /var/lib/rancher/k3s/agent/images/k3s-airgap-images-amd64.tar
    url_username: "{{ lookup('env', 'PULP_REPO_USERNAME') }}"
    url_password: "{{ lookup('env', 'PULP_REPO_PASSWORD') }}"

- name: "execute k3s install"
  shell: curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_SKIP_ENABLE=true INSTALL_K3S_BIN_DIR=/usr/bin INSTALL_K3S_SYSTEMD_DIR=/usr/lib/systemd/system sh -s - --flannel-backend=none --node-name=localhost --disable-helm-controller

- name: "enable k3s"
  systemd:
    name: k3s
    enabled: yes

- name: "kubectl bash auto-completion"
  shell: kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null

- name: "copy k3s resouce file to k3s manifests directory"
  copy:
    src: "{{ role_path }}/files/multus-daemonset.yml"
    dest: /var/lib/rancher/k3s/server/manifests/

- name: "copy k3s fish completion file to host"
  copy:
    src: "{{ role_path }}/files/kubectl.fish"
    dest: /usr/share/fish/completions/

- name: "copy k3s.service.env to destination"
  copy:
    src: "{{ role_path }}/files/k3s.service.env"
    dest: /usr/lib/systemd/system/k3s.service.env

- name: "copy multus-cni.tar to destination"
  copy:
    src: "{{ role_path }}/files/multus-cni.tar"
    dest: /var/lib/rancher/k3s/agent/images/

- name: "create cni bin directory"
  file:
    path: "/opt/cni/bin"
    state: directory

- name: "unarchive cni plugin tar package"
  unarchive:
    src: "{{ role_path }}/files/cni-plugins-linux-amd64.tgz"
    dest: /opt/cni/bin/

- name: "copy 10-bridge.conf to destination"
  copy:
    src: "{{ role_path }}/files/10-bridge.conf"
    dest: /etc/cni/net.d/

- name: "copy config.yaml  to dest for resource management"
  copy:
    src: "{{ role_path }}/files/config.yaml"
    dest: /etc/rancher/k3s/

- name: "copy  clean_orphaned_pods_dir to dest"
  copy:
    src: "{{ role_path }}/files/clean_orphaned_pods_dir.sh"
    dest: /opt/tsg/k3s/scripts/
    mode: 0755

- name: "copy override service file to dest"
  copy:
    src: "{{ role_path }}/files/service_set_RuntimeMaxSec.conf"
    dest: /usr/lib/systemd/system/k3s.service.d/

- name: "Create /usr/libexec/k3s directory if it does not exist"
  file:
    path: "{{ item }}"
    state: directory
    mode: '0755'
  with_items:
    - /usr/libexec/k3s


- name: "copy k3s-orphaned-pods-dir-clean.service to destination"
  copy:
    src: "{{ role_path }}/files/k3s-orphaned-pods-dir-clean.service"
    dest: /usr/lib/systemd/system/

- name: "copy k3s-orphaned-pods-dir-clean.timer to destination"
  copy:
    src: "{{ role_path }}/files/k3s-orphaned-pods-dir-clean.timer"
    dest: /usr/lib/systemd/system/

- name: "enable k3s-orphaned-pods-dir-clean.timer"
  systemd:
    name: k3s-orphaned-pods-dir-clean.timer
    enabled: yes

- name: "copy nic-uio-binder file to dest"
  copy:
    src: "{{ role_path }}/files/nic-uio-binder.yaml"
    dest: /var/lib/rancher/k3s/server/manifests/

- name: "copy dynamic-hostport yaml file to k3s manifests directory"
  copy:
    src: "{{ role_path }}/files/dynamic-hostport.yaml"
    dest: /var/lib/rancher/k3s/server/manifests/

- name: "Get dynamic-hostport chart images to dest"
  get_url:
    url: https://repo.geedge.net/filerepo/install/release/tsg-container-images/dynamic-hostport.tar
    dest: /var/lib/rancher/k3s/agent/images/dynamic-hostport.tar
    url_username: "{{ lookup('env', 'PULP_REPO_USERNAME') }}"
    url_password: "{{ lookup('env', 'PULP_REPO_PASSWORD') }}"

- name: "copy coredns-custom yaml file to k3s manifests directory"
  copy:
    src: "{{ role_path }}/files/coredns-custom.yaml"
    dest: /var/lib/rancher/k3s/server/manifests/

- name: "copy k3s-reset.sh to /usr/bin"
  copy:
    src: "{{ role_path }}/files/k3s-reset.sh"
    dest: /usr/bin/
    mode: 0755

- name: "download helm-controller images tar"
  get_url:
    url: https://repo.geedge.net/filerepo/install/release/os-build-files/k3s/v1.29.2/k3s-helm-controller-amd64.tar
    dest: /var/lib/rancher/k3s/agent/images/k3s-helm-controller-amd64.tar
    url_username: "{{ lookup('env', 'PULP_REPO_USERNAME') }}"
    url_password: "{{ lookup('env', 'PULP_REPO_PASSWORD') }}"

- name: "install deploy helm-controller mainfest file to dest"
  copy:
    src: "{{ role_path }}/files/deploy-helm-controller.yaml"
    dest: /var/lib/rancher/k3s/server/manifests/