Update Ansible configuration and enhance playbook
- Add UFW configuration to secure server ports - Install additional packages including vim, zsh, and monitoring tools - Change default shell for 'deploy' user to zsh - Update .gitignore to include Ansible inventory files
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
[new_server]
|
||||
#your-new-server-ip ansible_user=deploy
|
||||
127.0.0.1 ansible_user=deploy
|
||||
|
||||
[all:vars]
|
||||
ansible_python_interpreter=/usr/bin/python3
|
||||
@@ -31,6 +31,13 @@
|
||||
- curl
|
||||
- sshpass
|
||||
- rsync
|
||||
- vim
|
||||
- zsh
|
||||
- ufw
|
||||
- htop
|
||||
- iotop
|
||||
- traceroute
|
||||
- ncdu
|
||||
state: present
|
||||
|
||||
- name: Включить и запустить Docker
|
||||
@@ -39,6 +46,28 @@
|
||||
enabled: yes
|
||||
state: started
|
||||
|
||||
- name: Настроить UFW (файрвол)
|
||||
ufw:
|
||||
state: enabled
|
||||
policy: deny
|
||||
direction: incoming
|
||||
rule: allow
|
||||
port: "22"
|
||||
proto: tcp
|
||||
notify: restart ufw
|
||||
|
||||
- name: Открыть порты для сервисов
|
||||
ufw:
|
||||
rule: allow
|
||||
port: "{{ item }}"
|
||||
proto: tcp
|
||||
loop:
|
||||
- "8080" # Telegram Bot
|
||||
- "8081" # AnonBot
|
||||
- "9090" # Prometheus
|
||||
- "3000" # Grafana
|
||||
notify: restart ufw
|
||||
|
||||
- name: Проверить существование пользователя deploy
|
||||
getent:
|
||||
database: passwd
|
||||
@@ -57,13 +86,19 @@
|
||||
name: "{{ deploy_user }}"
|
||||
uid: "{{ uid }}"
|
||||
group: "{{ gid }}"
|
||||
shell: /bin/bash
|
||||
shell: /bin/zsh
|
||||
create_home: yes
|
||||
system: no
|
||||
groups: docker
|
||||
append: yes
|
||||
when: not user_exists.exists
|
||||
|
||||
- name: Установить zsh как оболочку по умолчанию для существующего пользователя deploy
|
||||
user:
|
||||
name: "{{ deploy_user }}"
|
||||
shell: /bin/zsh
|
||||
when: user_exists.exists
|
||||
|
||||
- name: Настроить безопасный SSH
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
@@ -239,9 +274,13 @@
|
||||
debug:
|
||||
msg: "Все сервисы запущены и слушают нужные порты."
|
||||
|
||||
# handler для перезагрузки SSH
|
||||
# handlers для перезагрузки сервисов
|
||||
handlers:
|
||||
- name: reload ssh
|
||||
systemd:
|
||||
name: ssh
|
||||
state: reloaded
|
||||
|
||||
- name: restart ufw
|
||||
ufw:
|
||||
state: reloaded
|
||||
Reference in New Issue
Block a user