refactor(roles/common): naming and formatting improvements

This commit is contained in:
ITQ
2026-03-19 14:44:09 +03:00
parent 22a56aca43
commit a54b4272ce
4 changed files with 29 additions and 17 deletions
+16 -8
View File
@@ -1,9 +1,10 @@
---
- name: Include optimization tasks
include_tasks: optimization.yaml
ansible.builtin.include_tasks: optimization.yaml
tags: optimization
- name: Install essential packages
become: true
ansible.builtin.apt:
name: "{{ system_packages.essential }}"
state: present
@@ -12,48 +13,54 @@
tags: packages
- name: Set hostname and FQDN
tags: system
block:
- name: Set hostname
become: true
ansible.builtin.hostname:
name: "{{ hostname | default(inventory_hostname) }}"
- name: Configure FQDN in hosts file
become: true
ansible.builtin.lineinfile:
path: /etc/hosts
regexp: '^127\.0\.1\.1.*'
line: "127.0.1.1 {{ fqdn | default(hostname) }} {{ hostname | default(inventory_hostname) }}"
state: present
tags: system
- name: Deploy MOTD template
template:
become: true
ansible.builtin.template:
src: motd.j2
dest: /etc/motd
mode: '0644'
mode: "0644"
- name: Configure timezone
become: true
community.general.timezone:
name: "{{ timezone }}"
tags: system, ntp
- name: Install and configure NTP
include_role:
ansible.builtin.include_role:
name: geerlingguy.ntp
tags: system, ntp
- name: Deploy SSH configuration
become: true
ansible.builtin.template:
src: sshd_config.j2
dest: /etc/ssh/sshd_config
owner: root
group: root
mode: '0600'
validate: '/usr/sbin/sshd -t -f %s'
mode: "0600"
validate: "/usr/sbin/sshd -t -f %s"
notify: Restart ssh
- name: Create admin users with proper SSH keys
block:
- name: Ensure user exists
become: true
ansible.builtin.user:
name: "{{ item.name }}"
shell: "{{ item.shell | default('/bin/bash') }}"
@@ -66,6 +73,7 @@
tags: users
- name: Deploy SSH authorized keys
become: true
ansible.posix.authorized_key:
user: "{{ item.0.name }}"
state: present
@@ -77,5 +85,5 @@
tags: users, ssh
- name: Include cron tasks
include_tasks: cron.yaml
ansible.builtin.include_tasks: cron.yaml
tags: cron