Ansible_workstation/tasks/ssh.yml

44 lines
1019 B
YAML
Raw Normal View History

2018-08-24 08:00:59 +00:00
---
# - name: Copy sshd_config
# template:
# src: files/sshd_config
# dest: /etc/ssh/sshd_config
2018-08-24 09:00:52 +00:00
- name: Disable empty password login
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^#?PermitEmptyPasswords"
line: "PermitEmptyPasswords no"
backrefs: yes
2018-08-24 09:00:52 +00:00
- name: Disable remote root login
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^#?PermitRootLogin"
line: "PermitRootLogin no"
backrefs: yes
2018-08-24 09:00:52 +00:00
- name: Add public key for deploy user
authorized_key:
2018-08-24 08:59:13 +00:00
user: "{{ item.username }}"
2018-08-25 12:52:47 +00:00
key: "{{ deploy_public_key }}"
2018-08-24 09:14:48 +00:00
state: present
2018-08-24 08:59:13 +00:00
with_items: "{{ deploy_users }}"
2018-08-24 09:00:52 +00:00
register: add_identity_key
- name: Disable password login
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^#?PasswordAuthentication"
line: "PasswordAuthentication no"
backrefs: yes
2018-08-24 09:14:48 +00:00
when: add_identity_key is success and not add_identity_key is skipped
2018-08-24 08:13:15 +00:00
notify: restart sshd
- name: Enable SSH daemon
service:
name: sshd
state: started
enabled: yes
2018-08-24 08:17:21 +00:00