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