1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/sshd/tasks/main.yml

62 lines
1.4 KiB
YAML
Raw Normal View History

2019-02-03 00:33:49 +00:00
- name: "Install ssh daemon using package: {{ sshd_package }}"
2019-01-02 02:44:19 +00:00
package:
name: "{{ sshd_package }}"
state: present
2020-01-30 09:00:00 +00:00
- name: Disable password-based logins to root
2018-09-20 00:44:42 +00:00
lineinfile:
dest: /etc/ssh/sshd_config
regexp: '^PermitRootLogin'
line: 'PermitRootLogin without-password'
state: present
2020-01-30 09:00:00 +00:00
#when: sshd_enabled | bool
2017-05-27 18:09:50 +00:00
#TODO: use handler to reload ssh
2020-01-30 09:00:00 +00:00
- name: mkdir /root/.ssh
2018-09-20 00:55:28 +00:00
file:
2020-01-30 09:00:00 +00:00
state: directory
2018-09-20 00:55:28 +00:00
path: /root/.ssh
owner: root
group: root
2020-01-30 09:00:00 +00:00
mode: '0700'
#when: sshd_enabled | bool
2018-09-20 00:55:28 +00:00
- name: Install dummy root keys as placeholder
copy:
src: dummy_authorized_keys
dest: /root/.ssh/authorized_keys
owner: root
group: root
2020-01-30 09:00:00 +00:00
mode: '0600'
2018-09-20 00:55:28 +00:00
force: no
2020-01-30 09:00:00 +00:00
#when: sshd_enabled | bool
# RECORD sshd AS INSTALLED
- name: "Set 'sshd_installed: True'"
set_fact:
sshd_installed: True
- name: "Add 'sshd_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
2020-01-30 09:00:00 +00:00
regexp: '^sshd_installed'
line: 'sshd_installed: True'
2018-09-20 00:55:28 +00:00
2020-01-30 09:00:00 +00:00
- name: Enable & Start ssh daemon ({{ sshd_service }}) if sshd_enabled
systemd:
2018-09-20 00:44:42 +00:00
name: "{{ sshd_service }}"
2020-01-30 09:00:00 +00:00
daemon_reload: yes
2018-09-20 00:44:42 +00:00
enabled: yes
state: started
when: sshd_enabled | bool
2017-05-27 18:09:50 +00:00
2020-01-30 09:00:00 +00:00
- name: Disable & Stop ssh daemon ({{ sshd_service }}) if not sshd_enabled
systemd:
2018-09-20 00:44:42 +00:00
name: "{{ sshd_service }}"
enabled: no
state: stopped
2017-05-27 18:09:50 +00:00
when: not sshd_enabled