This is an old revision of the document!
Replace inplace sshd_config param (at same position)
Ex:
#Port 22 by Port 2222 or Port 2233
---
- hosts: webservers
tasks:
- name: Update SSH configuration to be more secure.
lineinfile:
dest: /ansible/sshd_config
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
state: present
with_items:
- regexp: '^(.*)PasswordAuthentication (.*)$'
line: "PasswordAuthentication no"
- regexp: '^(.*)PermitRootLogin (.*)$'
line: "PermitRootLogin no"
- regexp: '^(.*)Port (.*)$'
line: "Port 2849"