1
0
Fork 0

Initial base playbooks

Signed-off-by: Nis Wechselberg <enbewe@enbewe.de>
This commit is contained in:
Nis Wechselberg 2024-06-17 16:45:02 +02:00
parent 9c51597396
commit dd603044fc
Signed by: enbewe
GPG key ID: 7B25171F921B9E57
11 changed files with 305 additions and 0 deletions

36
playbooks/access.yml Normal file
View file

@ -0,0 +1,36 @@
---
- name: 'Configure access permissions'
hosts: 'all'
vars:
ssh_public_keys_exclusive: true
tasks:
- name: 'Install ssh keys in target system'
ansible.posix.authorized_key:
user: '{{ ansible_user }}'
key: '{{ ssh_public_keys }}'
exclusive: '{{ ssh_public_keys_exclusive }}'
- name: 'Allow ansible user to use sudo'
become: true
ansible.builtin.template:
src: 'sudoers.d/ansible.j2'
dest: '/etc/sudoers.d/ansible'
owner: 'root'
group: 'root'
mode: 'u=rw,g=r,o='
- name: 'Disallow ssh password login'
become: true
ansible.builtin.lineinfile:
path: '/etc/ssh/sshd_config'
regexp: '^#?PasswordAuthentication '
line: 'PasswordAuthentication no'
- name: 'Disallow ssh root login without key'
become: true
ansible.builtin.lineinfile:
path: '/etc/ssh/sshd_config'
regexp: '^#?PermitRootLogin '
line: 'PermitRootLogin prohibit-password'