This commit is contained in:
2026-06-18 23:18:11 +03:00
parent 22f030ff7b
commit 2868f76761
9 changed files with 181 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
[defaults]
#Отключаем проверку fingerprnt при первом подключении к серверу
host_key_checking=false
#Задаём файл с хостами по умолчанию. Больше не нужно писать "ansible -i hosts.txt all -m ping", достаточно "ansible all -m ping"
inventory=/ansible/hosts.txt
interpreter_python=auto_silent
+22
View File
@@ -0,0 +1,22 @@
[ansible_servers]
rdb1 ansible_host=192.168.33.120
rdb2 ansible_host=192.168.33.121
ldcore1 ansible_host=192.168.33.124
ldcore2 ansible_host=192.168.33.125
lcloud1 ansible_host=192.168.33.129
hub ansible_host=192.168.33.220
rdb3 ansible_host=192.168.33.221
#Тут не настроен wg
#icap ansible_host=10.10.10.10
ldext1 ansible_host=82.202.138.229 ansible_port=22233
ldext2 ansible_host=176.108.251.94 ansible_port=22233
app ansible_host=95.174.93.179 ansible_port=22233
[ansible_servers:vars]
ansible_user=zmaster
ansible_ssh_private_key_file=/home/zmaster/.ssh/zmasterKeys
+7
View File
@@ -0,0 +1,7 @@
- name: ping
hosts: all
become: yes
tasks:
- name: Ping
ping:
+47
View File
@@ -0,0 +1,47 @@
- name: Prepeare OS Linux (Rocky + Ubuntu) after install
hosts: all
become: yes
tasks:
- block:
- name: Remove soft
dnf: name="{{ item }}" state=absent autoremove=yes
loop: [qemu*, cockpit*, postfix*, libvirt*, podman*]
- name: Install soft
dnf: name="{{ item }}" state=latest
loop: [unzip, mtr, yum-utils, epel-release, net-tools, wget, tar, lsof, sysstat, smartmontools, which, iperf3, vim, htop, iftop, nethogs, tree]
- name: Remove services from firewall
firewalld: service="{{ item }}" state=disabled permanent=true immediate=true
loop: [cockpit, dhcpv6-client]
- name: Create aliases
lineinfile: path=/etc/bashrc line="{{ item }}"
loop:
- alias lll='ls -alh --color=auto'
- alias sss='ss -tulpn'
- alias df='df -h'
when: ansible_facts['os_family'] == "RedHat"
- block:
- name: Remove soft
apt: name="{{ item }}" state=absent autoremove=yes
loop: [qemu*, cockpit*, postfix*, libvirt*, podman*]
- name: Install soft
apt: name="{{ item }}" state=latest
loop: [unzip, mtr, net-tools, wget, tar, lsof, sysstat, smartmontools, which, iperf3, vim, htop, iftop, nethogs, tree]
- name: Create aliases
lineinfile: path=/etc/bash.bashrc line="{{ item }}"
loop:
- alias lll='ls -alh --color=auto'
- alias sss='ss -tulpn'
- alias df='df -h'
when: ansible_facts['os_family'] == "Debian"
- name: Disable SELinux
selinux: state=disabled
when: ansible_facts['selinux']['status']!="disabled"
- name: Do not prompt for sudo password for zmaster
lineinfile: path="/etc/sudoers" line="{{ item }}"
loop:
- "zmaster ALL=(ALL) NOPASSWD: ALL"
+5
View File
@@ -0,0 +1,5 @@
---
- name: Remove soft
dnf: name="{{ item }}" state=absent autoremove=yes
loop: [qemu*, cockpit*, postfix*, libvirt*, podman*]
+4
View File
@@ -0,0 +1,4 @@
---
- name: Install soft
dnf: name="{{ item }}" state=latest
loop: [unzip, mtr, yum-utils, epel-release, net-tools, wget, tar, lsof, sysstat, smartmontools, which, iperf3, vim, htop, iftop, nethogs, tree]
+7
View File
@@ -0,0 +1,7 @@
---
- name: Install Soft
hosts: all
become: yes
roles:
- delsoft
- inssoft
+20
View File
@@ -0,0 +1,20 @@
- name: Update all system packages
hosts: all
become: yes
tasks:
- name: Update packages to the latest version
dnf: name="*" state=latest
- name: Check if a reboot is required
command:
cmd: needs-restarting -r
register: reboot_check
changed_when: false
failed_when: reboot_check.rc not in [0, 1]
- name: Reboot the server only if needed
reboot:
when: reboot_check.rc == 1
+63
View File
@@ -0,0 +1,63 @@
PLAY [Update all system packages] **********************************************
TASK [Gathering Facts] *********************************************************
ok: [rdb1]
ok: [ldcore1]
ok: [ldcore2]
ok: [lcloud1]
ok: [hub]
ok: [rdb2]
ok: [rdb3]
ok: [ldext1]
ok: [ldext2]
ok: [app]
TASK [Update packages to the latest version] ***********************************
ok: [rdb1]
ok: [ldcore1]
ok: [rdb2]
ok: [ldcore2]
ok: [lcloud1]
ok: [hub]
ok: [rdb3]
ok: [ldext1]
ok: [app]
ok: [ldext2]
TASK [Check if a reboot is required] *******************************************
ok: [ldcore2]
ok: [ldcore1]
ok: [rdb2]
ok: [lcloud1]
ok: [hub]
ok: [rdb3]
ok: [rdb1]
ok: [ldext2]
ok: [ldext1]
ok: [app]
TASK [Reboot the server only if needed] ****************************************
skipping: [rdb1]
skipping: [rdb2]
skipping: [ldcore1]
skipping: [ldcore2]
skipping: [lcloud1]
skipping: [hub]
skipping: [rdb3]
skipping: [ldext1]
skipping: [ldext2]
skipping: [app]
PLAY RECAP *********************************************************************
app : ok=3 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
hub : ok=3 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
lcloud1 : ok=3 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
ldcore1 : ok=3 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
ldcore2 : ok=3 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
ldext1 : ok=3 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
ldext2 : ok=3 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
rdb1 : ok=3 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
rdb2 : ok=3 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
rdb3 : ok=3 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0