refactor: restructure repository into layered IaC architecture (ansible, terraform, kubernetes)
This commit is contained in:
1 parent
d5dfc02889
commit
3c300c0cde
29 files changed
+227
-1
No files matched your search
@@ -0,0 +1,87 @@
|
||||
---
|
||||
- name: Подготовить Python для Ansible
|
||||
ansible.builtin.raw: DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-apt
|
||||
changed_when: false
|
||||
|
||||
- name: Собрать факты
|
||||
ansible.builtin.setup:
|
||||
|
||||
- name: Создать каталог .ssh
|
||||
ansible.builtin.file:
|
||||
path: /root/.ssh
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0700"
|
||||
|
||||
- name: Добавить авторизованные SSH-ключи
|
||||
ansible.posix.authorized_key:
|
||||
user: root
|
||||
key: "{{ item }}"
|
||||
state: present
|
||||
loop: "{{ host_authorized_keys }}"
|
||||
|
||||
- name: Удалить cloud-init настройки пароля SSH
|
||||
ansible.builtin.file:
|
||||
path: /etc/ssh/sshd_config.d/50-cloud-init.conf
|
||||
state: absent
|
||||
notify: Перезапустить SSH
|
||||
|
||||
- name: Отключить вход по паролю в drop-in sshd_config.d
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/ssh/sshd_config.d/00-disable-passwords.conf
|
||||
content: |
|
||||
PasswordAuthentication no
|
||||
KbdInteractiveAuthentication no
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: Перезапустить SSH
|
||||
|
||||
- name: Удалить устаревший drop-in sshd_config.d
|
||||
ansible.builtin.file:
|
||||
path: /etc/ssh/sshd_config.d/99-disable-passwords.conf
|
||||
state: absent
|
||||
notify: Перезапустить SSH
|
||||
|
||||
- name: Запретить PasswordAuthentication в основном sshd_config
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
regexp: '^(#\s*)?PasswordAuthentication\s+.*'
|
||||
line: 'PasswordAuthentication no'
|
||||
notify: Перезапустить SSH
|
||||
|
||||
- name: Применить настройки SSH
|
||||
ansible.builtin.meta: flush_handlers
|
||||
|
||||
- name: Поставить Docker
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- docker.io
|
||||
- docker-compose-v2
|
||||
- ufw
|
||||
- ca-certificates
|
||||
- curl
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Включить Docker
|
||||
ansible.builtin.systemd:
|
||||
name: docker
|
||||
enabled: true
|
||||
state: started
|
||||
|
||||
- name: Разрешить SSH
|
||||
ansible.builtin.command: ufw allow OpenSSH
|
||||
register: ufw_ssh
|
||||
changed_when: "'added' in (ufw_ssh.stdout | lower)"
|
||||
|
||||
- name: Проверить состояние firewall
|
||||
ansible.builtin.command: ufw status
|
||||
register: ufw_status
|
||||
changed_when: false
|
||||
|
||||
- name: Включить firewall
|
||||
ansible.builtin.command: ufw --force enable
|
||||
when: "'Status: active' not in ufw_status.stdout"
|
||||
changed_when: true
|
||||
Reference in new issue
Block a user