feat(ansible): Add common role tasks

This commit is contained in:
Claude AI
2026-01-06 14:43:12 +00:00
parent 99e2a2daf0
commit d40aaaa145

View File

@@ -0,0 +1,47 @@
---
# Common role - Base system configuration
- name: Update apt cache
apt:
update_cache: true
cache_valid_time: 3600
when: ansible_os_family == "Debian"
tags: ['packages']
- name: Install common packages
apt:
name: "{{ common_packages }}"
state: present
tags: ['packages']
- name: Set timezone
timezone:
name: "{{ timezone }}"
tags: ['system']
- name: Create admin users
user:
name: "{{ item.name }}"
groups: "{{ item.groups }}"
shell: "{{ item.shell }}"
create_home: true
state: present
loop: "{{ admin_users }}"
tags: ['users']
- name: Configure SSH
lineinfile:
path: /etc/ssh/sshd_config
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
state: present
loop:
- { regexp: '^#?PasswordAuthentication', line: 'PasswordAuthentication no' }
- { regexp: '^#?PermitRootLogin', line: 'PermitRootLogin no' }
- { regexp: '^#?Port', line: 'Port {{ ssh_port }}' }
notify: restart sshd
tags: ['ssh', 'security']
- name: Display completion
debug:
msg: "✅ Common configuration completed"