ansible/roles/ubuntu_base/tasks/ssh-port.yml

19 lines
450 B
YAML
Raw Normal View History

---
- name: Change SSH port on host
2022-11-26 08:52:41 +00:00
ansible.builtin.lineinfile:
dest: /etc/ssh/sshd_config
regexp: '^#?Port '
line: Port 19022
register: ssh_changed
- name: Restart sshd
2022-11-26 08:52:41 +00:00
ansible.builtin.service:
name: sshd
state: restarted
2022-11-26 08:52:41 +00:00
when: ssh_changed is defined and ssh_changed.changed
- name: Change Ansible port to 19022
2022-11-26 08:52:41 +00:00
ansible.builtin.set_fact:
ansible_port: 19022
2022-11-26 08:52:41 +00:00
when: ssh_changed is defined and ssh_changed.changed