46 lines
1.1 KiB
YAML
46 lines
1.1 KiB
YAML
---
|
|
# Tasks to install and configure OpenSSH
|
|
|
|
- name: Make sure the SSH server and client packages are installed
|
|
apt:
|
|
pkg:
|
|
- openssh-client
|
|
- openssh-server
|
|
state: present
|
|
tags: ssh
|
|
|
|
- name: Configure the SSH Client
|
|
template:
|
|
src: etc_ssh_ssh_config.j2
|
|
dest: /etc/ssh/ssh_config
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
tags: ssh
|
|
|
|
- name: Configure the SSH Server
|
|
template:
|
|
src: etc_ssh_sshd_config.j2
|
|
dest: /etc/ssh/sshd_config
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
notify: Restart SSH
|
|
tags: ssh
|
|
|
|
#- name: Update ssh_known_hosts
|
|
# lineinfile:
|
|
# dest: /etc/ssh/ssh_known_hosts
|
|
# regexp: "^{{ hostvars[item].ansible_hostname }},"
|
|
# line: >
|
|
# {{ hostvars[item].ansible_hostname }},{{ hostvars[item].ansible_fqdn }},{{ hostvars[item].ansible_default_ipv4.address }}
|
|
# ssh-rsa {{ hostvars[item].ansible_ssh_host_key_rsa_public }}
|
|
# state: present
|
|
# create: yes
|
|
# owner: root
|
|
# group: root
|
|
# mode: 0644
|
|
# with_items: "{{ groups.all|sort }}"
|
|
# when: item in hostvars
|
|
# tags: ssh
|