--- - name: replace line become: true lineinfile: path: /etc/ssh/sshd_config regexp: '^(.*)#PasswordAuthentication yes(.*)$' line: 'PasswordAuthentication no' backrefs: yes - name: Start and enable sshd become: true ansible.builtin.service: name: sshd state: started enabled: true when: host != 'ntb'