# =================================================================================================== # ? ABOUT # @author : Noah Knegt # @email : personal@noahknegt.com # @repo : https://git.noahknegt.com/noah.knegt/ansible-automations # @createdOn : 27-02-2023 # @description : This will setup the ssh server on the machine. # =================================================================================================== --- - name: Install or update openssh ansible.builtin.package: name: "{{ setup_openssh_package }}" state: present notify: - restart_sshd - name: Enable ssh daemon when: inventory_hostname in groups['datacenter'] ansible.builtin.service: name: "{{ openssh_service }}" state: started enabled: true - name: Configure sshd when: inventory_hostname in groups['datacenter'] ansible.builtin.template: src: sshd_config.j2 dest: /etc/ssh/sshd_config owner: root group: root mode: 0644 notify: - restart_sshd - name: Copy sshd banner ansible.builtin.copy: src: ssh_banner.net dest: /etc/issue.net owner: root group: root mode: 0644 - name: Copy ssh public key ansible.builtin.authorized_key: user: ansible key: "{{ item }}" with_file: - ansible/ansible.pub - name: Copy ssh public key ansible.builtin.authorized_key: user: noahk key: "{{ item }}" with_file: - noahk/noahk.pub