Files
configs/playbooks/roles/server_ssh/tasks/main.yml
Morten Olsen dce2196c32 update
2024-12-05 23:29:30 +01:00

61 lines
1.3 KiB
YAML

---
- name: Copy config
tags:
- config
ansible.builtin.file:
mode: "{{ item.mode }}"
path: "{{ home }}/{{ item.path }}"
state: directory
owner: "{{ username }}"
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'directory'
- name: "Copy templates"
tags:
- config
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ home }}/{{ item.path | regex_replace('\\.j2$', '') }}"
mode: "{{ item.mode }}"
owner: "{{ username }}"
with_community.general.filetree:
- ../templates
loop_control:
label: "{{ item.path }}"
when: item.state == 'file'
- name: Copy config
tags:
- config
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ home }}/{{ item.path }}"
mode: "{{ item.mode }}"
owner: "{{ username }}"
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'file'
- name: Install ssh server
when: not mac_os
tags:
- install
ansible.builtin.package:
name:
- openssh-server
- name: Disable password authentication for root
tags:
- config
when: not mac_os
lineinfile:
path: /etc/ssh/sshd_config
state: present
regexp: "^#?PermitRootLogin"
line: "PermitRootLogin prohibit-password"