sshd
This commit is contained in:
parent
424fe250d8
commit
2c24ade913
1
ansible/group_vars/all.yaml
Normal file
1
ansible/group_vars/all.yaml
Normal file
@ -0,0 +1 @@
|
||||
---
|
6
ansible/host_vars/lab.yaml
Normal file
6
ansible/host_vars/lab.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
|
||||
# sshd
|
||||
|
||||
authorized_keys_file: lab_authorized_keys
|
||||
openssh_configuration_src: sshd_config_arch
|
9
ansible/playbooks/lab.yaml
Normal file
9
ansible/playbooks/lab.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: Configure lab host
|
||||
gather_facts: true
|
||||
hosts: lab
|
||||
become: true
|
||||
|
||||
roles:
|
||||
- sshd
|
||||
- firewall
|
9
ansible/roles/sshd/handlers/main.yml
Normal file
9
ansible/roles/sshd/handlers/main.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
- name: restart openssh
|
||||
ansible.builtin.service:
|
||||
name: "{{ openssh_service }}"
|
||||
state: restarted
|
||||
when:
|
||||
- not ansible_check_mode
|
||||
- not openssh_restart_immediately
|
@ -4,4 +4,35 @@
|
||||
name: "{{ openssh_packages }}"
|
||||
state: latest
|
||||
update_cache: true
|
||||
reason: explicit
|
||||
reason: explicit
|
||||
when:
|
||||
- ansible_os_family == 'Arch'
|
||||
|
||||
- name: add authorized keys
|
||||
ansible.builtin.copy:
|
||||
dest: "/home/{{ ansible_user }}/.ssh/authorized_keys"
|
||||
src: "{{ authorized_keys_file }}"
|
||||
mode: 0600
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "{{ ansible_user }}"
|
||||
|
||||
- name: configure openssh
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ openssh_configuration_file }}"
|
||||
src: "{{ openssh_configuration_src }}"
|
||||
mode: "{{ openssh_configuration_mode }}"
|
||||
owner: root
|
||||
group: root
|
||||
notify:
|
||||
- restart openssh
|
||||
|
||||
- name: start and enable openssh
|
||||
ansible.builtin.service:
|
||||
name: "{{ openssh_service }}"
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
- name: flush handlers
|
||||
ansible.builtin.meta: flush_handlers
|
||||
when:
|
||||
- openssh_restart_immediately
|
Loading…
Reference in New Issue
Block a user