Skip to content

Commit 9fa44a3

Browse files
committed
add playbooks for manager vm and kube vms
1 parent fada01a commit 9fa44a3

File tree

11 files changed

+130
-1841
lines changed

11 files changed

+130
-1841
lines changed

cassandra.yaml

Lines changed: 0 additions & 1818 deletions
This file was deleted.

k8s_cluster/Vagrantfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
nodes = [
2-
{ :hostname => 'node1-master', :ip => '10.245.1.122', :memory => 2048, :cpu => 1, :boxname => 'spox/ubuntu-arm' },
3-
{ :hostname => 'node4-worker', :ip => '10.245.1.125', :memory => 1536, :cpu => 1, :boxname => 'spox/ubuntu-arm' },
4-
{ :hostname => 'node5-worker', :ip => '10.245.1.126', :memory => 1536, :cpu => 1, :boxname => 'spox/ubuntu-arm' },
5-
{ :hostname => 'node2-manager', :ip => '10.245.1.127', :memory => 1024, :cpu => 1, :boxname => 'spox/ubuntu-arm' }
2+
{ :hostname => 'node1-master', :ip => '10.245.1.122', :memory => 2048, :cpu => 1, :boxname => 'spox/ubuntu-arm', :hdd => '30GB' },
3+
{ :hostname => 'node4-worker', :ip => '10.245.1.125', :memory => 1536, :cpu => 1, :boxname => 'spox/ubuntu-arm', :hdd => '30GB' },
4+
{ :hostname => 'node5-worker', :ip => '10.245.1.126', :memory => 1536, :cpu => 1, :boxname => 'spox/ubuntu-arm', :hdd => '30GB' },
5+
{ :hostname => 'node2-manager', :ip => '10.245.1.127', :memory => 1024, :cpu => 1, :boxname => 'spox/ubuntu-arm', :hdd => '10GB' }
66
]
77

88
Vagrant.configure("2") do |config|
99
nodes.each do |node|
1010
config.vm.box_check_update = false
1111
config.vm.define node[:hostname] do |nodeconfig|
12+
config.disksize.size = node[:hdd]
1213
nodeconfig.vm.box = node[:boxname]
1314
nodeconfig.vm.hostname = node[:hostname]
1415
nodeconfig.vm.network :private_network, ip: node[:ip]

k8s_cluster/inventory/inventory_manager.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ all:
66
ansible_ssh_private_key_file: /Users/ilyachaynichkov/devops/k8s_cluster/.vagrant/machines/node2-manager/vmware_desktop/private_key
77
workers:
88
hosts:
9-
192.168.2.180:
9+
192.168.2.171:
1010
ansible_connection: ssh
1111
ansible_user: vagrant
1212
ansible_ssh_private_key_file: /Users/ilyachaynichkov/devops/k8s_cluster/.vagrant/machines/node1-master/vmware_desktop/private_key
13-
192.168.2.178:
13+
192.168.2.190:
1414
ansible_connection: ssh
1515
ansible_user: vagrant
1616
ansible_ssh_private_key_file: /Users/ilyachaynichkov/devops/k8s_cluster/.vagrant/machines/node4-worker/vmware_desktop/private_key
17-
192.168.2.182:
17+
192.168.2.192:
1818
ansible_connection: ssh
1919
ansible_user: vagrant
2020
ansible_ssh_private_key_file: /Users/ilyachaynichkov/devops/k8s_cluster/.vagrant/machines/node5-worker/vmware_desktop/private_key

k8s_cluster/kubeVM/Vagrantfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
nodes = [
2+
{ :hostname => 'node1-master', :ip => '10.245.1.122', :memory => 2048, :cpu => 1, :boxname => 'spox/ubuntu-arm', :hdd => '30GB' },
3+
{ :hostname => 'node2-master', :ip => '10.245.1.123', :memory => 2048, :cpu => 1, :boxname => 'spox/ubuntu-arm', :hdd => '30GB' }
4+
{ :hostname => 'node3-worker', :ip => '10.245.1.125', :memory => 1536, :cpu => 1, :boxname => 'spox/ubuntu-arm', :hdd => '20GB' },
5+
{ :hostname => 'node4-worker', :ip => '10.245.1.126', :memory => 1536, :cpu => 1, :boxname => 'spox/ubuntu-arm', :hdd => '20GB' },
6+
]
7+
8+
Vagrant.configure("2") do |config|
9+
nodes.each do |node|
10+
config.vm.box_check_update = false
11+
config.disksize.size = node[:hdd]
12+
config.vm.define node[:hostname] do |nodeconfig|
13+
nodeconfig.vm.box = node[:boxname]
14+
nodeconfig.vm.hostname = node[:hostname]
15+
nodeconfig.vm.network :private_network, ip: node[:ip]
16+
nodeconfig.vm.provider :vmware_desktop do |vmware|
17+
vmware.gui = true
18+
vmware.cpus = node[:cpu]
19+
vmware.memory = node[:memory]
20+
vmware.vmx["ethernet0.virtualdev"] = "vmxnet3"
21+
vmware.ssh_info_public = true
22+
vmware.linked_clone = false
23+
end
24+
end
25+
end
26+
end
27+

k8s_cluster/managerVM/Vagrantfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
nodes = [
2+
{ :hostname => 'node-manager', :ip => '10.245.1.127', :memory => 1024, :cpu => 1, :boxname => 'spox/ubuntu-arm', :hdd => '10GB' }
3+
]
4+
5+
Vagrant.configure("2") do |config|
6+
nodes.each do |node|
7+
config.vm.box_check_update = false
8+
config.vm.define node[:hostname] do |nodeconfig|
9+
nodeconfig.vm.box = node[:boxname]
10+
nodeconfig.vm.hostname = node[:hostname]
11+
nodeconfig.vm.network :private_network, ip: node[:ip]
12+
nodeconfig.vm.provider :vmware_desktop do |vmware|
13+
vmware.gui = true
14+
vmware.cpus = node[:cpu]
15+
vmware.memory = node[:memory]
16+
vmware.vmx["ethernet0.virtualdev"] = "vmxnet3"
17+
vmware.ssh_info_public = true
18+
vmware.linked_clone = false
19+
end
20+
end
21+
config.vm.provision "ansible" do |ansible|
22+
ansible.playbook = "playbook.yml"
23+
end
24+
end
25+
end
26+

k8s_cluster/managerVM/playbook.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
- hosts: all
3+
become: true
4+
tasks:
5+
- name: Update all packages in Ubuntu
6+
become: true
7+
apt:
8+
update_cache: yes
9+
cache_valid_time: 86400
10+
11+
- name: Установка pip для Python 3.8
12+
apt:
13+
name: python3-pip
14+
state: present
15+
16+
- name: Установка venv для Python 3.8
17+
apt:
18+
name: python3.8-venv
19+
state: present
20+
21+
- name: Добавление параметра net.ipv4.ip_forward в /etc/sysctl.conf
22+
lineinfile:
23+
path: /etc/sysctl.conf
24+
line: "net.ipv4.ip_forward=1"
25+
state: present
26+
notify: Apply sysctl changes
27+
28+
- name: Отключение swap
29+
command: swapoff -a
30+
ignore_errors: true
31+
32+
- name: Копирование репозитория kubespray
33+
shell: |
34+
cd /home/vagrant
35+
git clone https://github.com/kubernetes-sigs/kubespray
36+
37+
- name: Установка необходимых библиотек для запуска и создание виртуального окружения
38+
shell: |
39+
cd kubespray
40+
git checkout release-2.20
41+
pip install -r requirements.txt
42+
handlers:
43+
- name: Apply sysctl changes
44+
command: sysctl --system

k8s_cluster/startup_playbook.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
- hosts: workers
33
become: true
44
tasks:
5-
- name: Update all packages in Ubuntu
6-
become: true
7-
apt:
8-
# upgrade: yes
9-
update_cache: yes
10-
cache_valid_time: 86400
11-
- name: Установка Python 3.11
12-
shell: |
13-
sudo add-apt-repository ppa:deadsnakes/ppa -y
14-
sudo apt update
15-
sudo apt install python3.11 -y
16-
sudo apt install python3.11-venv -y
5+
# - name: Update all packages in Ubuntu
6+
# become: true
7+
# apt:
8+
# # upgrade: yes
9+
# update_cache: yes
10+
# cache_valid_time: 86400
11+
# - name: Установка Python 3.11
12+
# shell: |
13+
# sudo add-apt-repository ppa:deadsnakes/ppa -y
14+
# sudo apt update
15+
# sudo apt install python3.11 -y
16+
# sudo apt install python3.11-venv -y
1717
- name: Добавление параметра net.ipv4.ip_forward в /etc/sysctl.conf
1818
lineinfile:
1919
path: /etc/sysctl.conf

linuxADM/Vagrantfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,8 @@ Vagrant.configure("2") do |config|
2020
vmware.linked_clone = false
2121
end
2222
end
23+
config.vm.provision "ansible" do |ansible|
24+
ansible.playbook = "lab4/taskPlaybook.yml"
25+
end
2326
end
2427
end

linuxADM/lab4/cleanupPlaybook.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- name: clean dirs
55
shell: |
66
rm -r /home/vagrant/shared
7+
# todo сделать проверку через баш, что есть такие директории stage
78
rm -r /home/vagrant/stage*
89
- name: Удалить пользователя developer
910
user:

linuxADM/lab4/inventory.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
vm1:
22
hosts:
3-
192.168.2.190:
3+
192.168.2.171:
44
ansible_connection: ssh
55
ansible_user: vagrant
6-
ansible_ssh_private_key_file: /Users/ilyachaynichkov/devops/linuxADM/.vagrant/machines/ubuntu1-master/vmware_desktop/private_key
6+
ansible_ssh_private_key_file: /Users/ilyachaynichkov/devops/linuxADM/.vagrant/machines/ubuntu1-master/vmware_desktop/private_key
7+
8+

0 commit comments

Comments
 (0)