From 55cca7bba344b4a96f5bed45b5079f37ef9eb37b Mon Sep 17 00:00:00 2001 From: Julien DOCHE Date: Tue, 12 May 2020 17:47:20 +0200 Subject: [PATCH] contrib/ansible: Remove duplication and redirect to new repository Signed-off-by: Julien DOCHE --- contrib/ansible/README.md | 53 +------------ contrib/ansible/ansible.cfg | 11 --- contrib/ansible/inventory/group_vars/all.yml | 5 -- contrib/ansible/inventory/hosts.ini | 12 --- contrib/ansible/reset.yml | 7 -- contrib/ansible/roles/download/tasks/main.yml | 38 ---------- .../ansible/roles/k3s/master/tasks/main.yml | 75 ------------------- .../roles/k3s/master/templates/k3s.service.j2 | 24 ------ contrib/ansible/roles/k3s/node/tasks/main.yml | 16 ---- .../roles/k3s/node/templates/k3s.service.j2 | 24 ------ contrib/ansible/roles/prereq/tasks/main.yml | 35 --------- contrib/ansible/roles/raspbian/tasks/main.yml | 24 ------ contrib/ansible/roles/reset/tasks/main.yml | 25 ------- contrib/ansible/site.yml | 22 ------ 14 files changed, 1 insertion(+), 370 deletions(-) delete mode 100644 contrib/ansible/ansible.cfg delete mode 100644 contrib/ansible/inventory/group_vars/all.yml delete mode 100644 contrib/ansible/inventory/hosts.ini delete mode 100644 contrib/ansible/reset.yml delete mode 100644 contrib/ansible/roles/download/tasks/main.yml delete mode 100644 contrib/ansible/roles/k3s/master/tasks/main.yml delete mode 100644 contrib/ansible/roles/k3s/master/templates/k3s.service.j2 delete mode 100644 contrib/ansible/roles/k3s/node/tasks/main.yml delete mode 100644 contrib/ansible/roles/k3s/node/templates/k3s.service.j2 delete mode 100644 contrib/ansible/roles/prereq/tasks/main.yml delete mode 100644 contrib/ansible/roles/raspbian/tasks/main.yml delete mode 100644 contrib/ansible/roles/reset/tasks/main.yml delete mode 100644 contrib/ansible/site.yml diff --git a/contrib/ansible/README.md b/contrib/ansible/README.md index 2183dfaf9b..4d6329e321 100644 --- a/contrib/ansible/README.md +++ b/contrib/ansible/README.md @@ -1,54 +1,3 @@ # Build a Kubernetes cluster using k3s via Ansible -Author: - -## K3s Ansible Playbook - -Build a Kubernetes cluster using Ansible with k3s. The goal is easily install a Kubernetes cluster on machines running: - -- [X] Debian -- [ ] Ubuntu -- [X] CentOS - -on processor architecture: - -- [X] x64 -- [X] arm64 -- [X] armhf - -## System requirements - -Deployment environment must have Ansible 2.4.0+ -Master and nodes must have passwordless SSH access - -## Usage - -Add the system information gathered above into a file called hosts.ini. For example: - -```bash -[master] -192.16.35.12 - -[node] -192.16.35.[10:11] - -[k3s-cluster:children] -master -node - -``` - -Start provisioning of the cluster using the following command: - -```bash -ansible-playbook site.yml -i inventory/hosts.ini -``` - -## Kubeconfig - -To get access to your **Kubernetes** cluster just - -```bash -scp debian@master_pi:~/.kube/config ~/.kube/config -``` - +The ansible playbook was moved to https://github.com/rancher/k3s-ansible diff --git a/contrib/ansible/ansible.cfg b/contrib/ansible/ansible.cfg deleted file mode 100644 index 747586b07d..0000000000 --- a/contrib/ansible/ansible.cfg +++ /dev/null @@ -1,11 +0,0 @@ -[defaults] -roles_path = ./roles -inventory = ./hosts.ini - -remote_tmp = $HOME/.ansible/tmp -local_tmp = $HOME/.ansible/tmp -pipelining = True -become = True -host_key_checking = False -deprecation_warnings = False -callback_whitelist = profile_tasks diff --git a/contrib/ansible/inventory/group_vars/all.yml b/contrib/ansible/inventory/group_vars/all.yml deleted file mode 100644 index d80065e7ea..0000000000 --- a/contrib/ansible/inventory/group_vars/all.yml +++ /dev/null @@ -1,5 +0,0 @@ -k3s_version: v0.8.1 -ansible_user: debian -systemd_dir: /etc/systemd/system -master_ip: "{{ hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0]) }}" -extra_server_args: "" diff --git a/contrib/ansible/inventory/hosts.ini b/contrib/ansible/inventory/hosts.ini deleted file mode 100644 index e45c65c779..0000000000 --- a/contrib/ansible/inventory/hosts.ini +++ /dev/null @@ -1,12 +0,0 @@ -[master] -192.168.1.26 - -[node] -192.168.1.34 -192.168.1.39 -192.168.1.16 -192.168.1.32 - -[k3s-cluster:children] -master -node diff --git a/contrib/ansible/reset.yml b/contrib/ansible/reset.yml deleted file mode 100644 index 4dd5794272..0000000000 --- a/contrib/ansible/reset.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -- hosts: k3s-cluster - gather_facts: yes - become: yes - roles: - - { role: reset } diff --git a/contrib/ansible/roles/download/tasks/main.yml b/contrib/ansible/roles/download/tasks/main.yml deleted file mode 100644 index bdcb2ba6eb..0000000000 --- a/contrib/ansible/roles/download/tasks/main.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- - -- name: Delete k3s if already present - file: - path: /usr/local/bin/k3s - state: absent - -- name: Download k3s binary x64 - get_url: - url: https://github.com/rancher/k3s/releases/download/{{ k3s_version }}/k3s - dest: /usr/local/bin/k3s - owner: root - group: root - mode: 755 -# when: ( ansible_facts.userspace_architecture == "x86_64" ) - when: ( ansible_facts.architecture == "x86_64" ) - -- name: Download k3s binary arm64 - get_url: - url: https://github.com/rancher/k3s/releases/download/{{ k3s_version }}/k3s-arm64 - dest: /usr/local/bin/k3s - owner: root - group: root - mode: 755 - when: ( ansible_facts.architecture is search("arm") ) - and - ( ansible_facts.userspace_bits == "64" ) - -- name: Download k3s binary armhf - get_url: - url: https://github.com/rancher/k3s/releases/download/{{ k3s_version }}/k3s-armhf - dest: /usr/local/bin/k3s - owner: root - group: root - mode: 755 - when: ( ansible_facts.architecture is search("arm") ) - and - ( ansible_facts.userspace_bits == "32" ) diff --git a/contrib/ansible/roles/k3s/master/tasks/main.yml b/contrib/ansible/roles/k3s/master/tasks/main.yml deleted file mode 100644 index f2e05c1207..0000000000 --- a/contrib/ansible/roles/k3s/master/tasks/main.yml +++ /dev/null @@ -1,75 +0,0 @@ ---- - -- name: Copy K3s service file - register: k3s_service - template: - src: "k3s.service.j2" - dest: "{{ systemd_dir }}/k3s.service" - owner: root - group: root - mode: 0755 - -- name: Enable and check K3s service - systemd: - name: k3s - daemon_reload: yes - state: restarted - enabled: yes - -- name: Wait for node-token - wait_for: - path: /var/lib/rancher/k3s/server/node-token - -- name: Register node-token file access mode - stat: - path: /var/lib/rancher/k3s/server - register: p - -- name: Change file access node-token - file: - path: /var/lib/rancher/k3s/server - mode: "g+rx,o+rx" - -- name: Read node-token from master - slurp: - src: /var/lib/rancher/k3s/server/node-token - register: node_token - -- name: Store Master node-token - set_fact: - token: "{{ node_token.content | b64decode | regex_replace('\n', '') }}" - -- name: Restore node-token file access - file: - path: /var/lib/rancher/k3s/server - mode: "{{ p.stat.mode }}" - -- name: Create directory .kube - file: - path: ~{{ ansible_user }}/.kube - state: directory - owner: "{{ ansible_user }}" - -- name: Copy config file to user home directory - copy: - src: /etc/rancher/k3s/k3s.yaml - dest: ~{{ ansible_user }}/.kube/config - remote_src: yes - owner: "{{ ansible_user }}" - -- name: Replace https://localhost:6443 by https://master-pi:6443 - command: k3s kubectl config set-cluster default - --server=https://{{ master_ip }}:6443 - --kubeconfig ~{{ ansible_user }}/.kube/config - -- name: Create kubectl symlink - file: - src: /usr/local/bin/k3s - dest: /usr/local/bin/kubectl - state: link - -- name: Create crictl symlink - file: - src: /usr/local/bin/k3s - dest: /usr/local/bin/crictl - state: link diff --git a/contrib/ansible/roles/k3s/master/templates/k3s.service.j2 b/contrib/ansible/roles/k3s/master/templates/k3s.service.j2 deleted file mode 100644 index d0f7dcc0fd..0000000000 --- a/contrib/ansible/roles/k3s/master/templates/k3s.service.j2 +++ /dev/null @@ -1,24 +0,0 @@ -[Unit] -Description=Lightweight Kubernetes -Documentation=https://k3s.io -After=network-online.target - -[Service] -Type=notify -ExecStartPre=-/sbin/modprobe br_netfilter -ExecStartPre=-/sbin/modprobe overlay -ExecStart=/usr/local/bin/k3s server {{ extra_server_args | default("") }} -KillMode=process -Delegate=yes -# Having non-zero Limit*s causes performance problems due to accounting overhead -# in the kernel. We recommend using cgroups to do container-local accounting. -LimitNOFILE=1048576 -LimitNPROC=infinity -LimitCORE=infinity -TasksMax=infinity -TimeoutStartSec=infinity -Restart=always -RestartSec=5s - -[Install] -WantedBy=multi-user.target diff --git a/contrib/ansible/roles/k3s/node/tasks/main.yml b/contrib/ansible/roles/k3s/node/tasks/main.yml deleted file mode 100644 index 0ce8e08d0f..0000000000 --- a/contrib/ansible/roles/k3s/node/tasks/main.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- - -- name: Copy K3s service file - template: - src: "k3s.service.j2" - dest: "{{ systemd_dir }}/k3s-node.service" - owner: root - group: root - mode: 0755 - -- name: Enable and check K3s service - systemd: - name: k3s-node - daemon_reload: yes - state: restarted - enabled: yes diff --git a/contrib/ansible/roles/k3s/node/templates/k3s.service.j2 b/contrib/ansible/roles/k3s/node/templates/k3s.service.j2 deleted file mode 100644 index cf491213d9..0000000000 --- a/contrib/ansible/roles/k3s/node/templates/k3s.service.j2 +++ /dev/null @@ -1,24 +0,0 @@ -[Unit] -Description=Lightweight Kubernetes -Documentation=https://k3s.io -After=network-online.target - -[Service] -Type=notify -ExecStartPre=-/sbin/modprobe br_netfilter -ExecStartPre=-/sbin/modprobe overlay -ExecStart=/usr/local/bin/k3s agent --server https://{{ master_ip }}:6443 --token {{ hostvars[groups['master'][0]]['token'] }} -KillMode=process -Delegate=yes -# Having non-zero Limit*s causes performance problems due to accounting overhead -# in the kernel. We recommend using cgroups to do container-local accounting. -LimitNOFILE=1048576 -LimitNPROC=infinity -LimitCORE=infinity -TasksMax=infinity -TimeoutStartSec=infinity -Restart=always -RestartSec=5s - -[Install] -WantedBy=multi-user.target diff --git a/contrib/ansible/roles/prereq/tasks/main.yml b/contrib/ansible/roles/prereq/tasks/main.yml deleted file mode 100644 index 7036c1afcd..0000000000 --- a/contrib/ansible/roles/prereq/tasks/main.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -- name: Set SELinux to disabled state - selinux: - state: disabled - when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' - -- name: Enable IPv4 forwarding - sysctl: - name: net.ipv4.ip_forward - value: "1" - state: present - reload: yes - -- name: Enable IPv6 forwarding - sysctl: - name: net.ipv6.conf.all.forwarding - value: "1" - state: present - reload: yes - -- name: Set bridge-nf-call-iptables (just to be sure) - sysctl: - name: net.bridge.bridge-nf-call-iptables - value: "1" - state: present - reload: yes - when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' - -- name: Set bridge-nf-call-ip6tables (just to be sure) - sysctl: - name: net.bridge.bridge-nf-call-iptables - value: "1" - state: present - reload: yes - when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' diff --git a/contrib/ansible/roles/raspbian/tasks/main.yml b/contrib/ansible/roles/raspbian/tasks/main.yml deleted file mode 100644 index 1bc085fbcc..0000000000 --- a/contrib/ansible/roles/raspbian/tasks/main.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- - -- name: Test for Raspbian - stat: - path: /boot/cmdline.txt - register: cmdline - -- name: Activating cgroup on Raspbian - lineinfile: - path: /boot/cmdline.txt - regexp: '^(.*rootwait)$' - line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' - backrefs: true - when: ( cmdline.stat.path is defined ) - and - ( ansible_facts.architecture is search("arm") ) - register: boot_cmdline - -- name: Rebooting on Raspbian - shell: reboot now - ignore_errors: true - when: ( boot_cmdline is changed ) - and - ( ansible_facts.architecture is search("arm") ) diff --git a/contrib/ansible/roles/reset/tasks/main.yml b/contrib/ansible/roles/reset/tasks/main.yml deleted file mode 100644 index 8bf8d08b00..0000000000 --- a/contrib/ansible/roles/reset/tasks/main.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -- name: Disable services - systemd: - name: "{{ item }}" - state: stopped - enabled: no - with_items: - - k3s - - k3s-node - -- name: Remove service files, binaries and data - file: - name: "{{ item }}" - state: absent - with_items: - - "{{ systemd_dir }}/k3s.service" - - "{{ systemd_dir }}/k3s-node.service" - - /etc/rancher/k3s - - /var/lib/rancher/k3s - - /var/lib/kubelet - - /usr/local/bin/k3s - -- name: daemon_reload - systemd: - daemon_reload: yes diff --git a/contrib/ansible/site.yml b/contrib/ansible/site.yml deleted file mode 100644 index 70c3b758ba..0000000000 --- a/contrib/ansible/site.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- - -- hosts: k3s-cluster - gather_facts: yes - become: yes - roles: - - { role: prereq } - - { role: download } - - { role: raspbian } - - -- hosts: master -# gather_facts: yes - become: yes - roles: - - { role: k3s/master } - -- hosts: node -# gather_facts: yes - become: yes - roles: - - { role: k3s/node }