mirror of
https://gitlab.sectorq.eu/jaydee/ansible.git
synced 2026-03-12 21:32:48 +01:00
build
This commit is contained in:
@@ -110,7 +110,7 @@
|
||||
apt:
|
||||
name: ufw
|
||||
state: present
|
||||
when: inventory_hostname == 'ubuntu-vm01.home.lan'
|
||||
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
|
||||
|
||||
- name: Allow Kubernetes ports
|
||||
ufw:
|
||||
@@ -120,13 +120,13 @@
|
||||
- 6443
|
||||
- 2379:2380
|
||||
- 10250
|
||||
when: inventory_hostname == 'ubuntu-vm01.home.lan'
|
||||
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
|
||||
|
||||
- name: Initialize Kubernetes
|
||||
command: kubeadm init --pod-network-cidr=10.244.0.0/16
|
||||
args:
|
||||
creates: /etc/kubernetes/admin.conf
|
||||
when: inventory_hostname == 'ubuntu-vm01.home.lan'
|
||||
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
|
||||
|
||||
- name: Create .kube directory
|
||||
file:
|
||||
@@ -135,7 +135,7 @@
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "{{ ansible_user }}"
|
||||
mode: '0755'
|
||||
when: inventory_hostname == 'ubuntu-vm01.home.lan'
|
||||
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
|
||||
|
||||
- name: Copy kubeconfig to user
|
||||
copy:
|
||||
@@ -145,25 +145,25 @@
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "{{ ansible_user }}"
|
||||
mode: '0644'
|
||||
when: inventory_hostname == 'ubuntu-vm01.home.lan'
|
||||
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
|
||||
|
||||
- name: Install Flannel CNI
|
||||
become_user: "{{ ansible_user }}"
|
||||
command: kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
|
||||
when: inventory_hostname == 'ubuntu-vm01.home.lan'
|
||||
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
|
||||
|
||||
- name: Get join command
|
||||
command: kubeadm token create --print-join-command
|
||||
register: join_command
|
||||
when: inventory_hostname == 'ubuntu-vm01.home.lan'
|
||||
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
|
||||
|
||||
- name: Save join command
|
||||
set_fact:
|
||||
worker_join_cmd: "{{ join_command.stdout }}"
|
||||
when: inventory_hostname == 'ubuntu-vm01.home.lan'
|
||||
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
|
||||
|
||||
- name: Join cluster
|
||||
command: "{{ hostvars['ubuntu-vm01.home.lan'].worker_join_cmd }}"
|
||||
command: "{{ hostvars['ubuntu24-vm01.home.lan'].worker_join_cmd }}"
|
||||
args:
|
||||
creates: /etc/kubernetes/kubelet.conf
|
||||
when: inventory_hostname != 'ubuntu-vm01.home.lan'
|
||||
when: inventory_hostname != 'ubuntu24-vm01.home.lan'
|
||||
Reference in New Issue
Block a user