Adding multiples ansible roles, playbooks and inventory
This commit is contained in:
29
roles/deploy_ssh_key/tasks/main.yml
Normal file
29
roles/deploy_ssh_key/tasks/main.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
- name: S'assurer que le répertoire .ssh existe
|
||||
file:
|
||||
path: "~/.ssh"
|
||||
state: directory
|
||||
mode: '0700'
|
||||
|
||||
- name: Ajouter la clé publique au fichier authorized_keys
|
||||
ansible.posix.authorized_key:
|
||||
user: root
|
||||
state: present
|
||||
key: "{{ lookup('file', '/home/riesjack/.ssh/ansible.pub') }}"
|
||||
|
||||
- name: Ajouter la clé publique au fichier authorized_keys
|
||||
ansible.posix.authorized_key:
|
||||
user: root
|
||||
state: present
|
||||
key: "{{ lookup('file', '/home/riesjack/.ssh/riesjack.pub') }}"
|
||||
|
||||
- name: Inject ssh config to remove open ssh root
|
||||
copy:
|
||||
src: ../files/sshd_config
|
||||
dest: /etc/ssh/sshd_config
|
||||
|
||||
- name: Restart SSH service
|
||||
ansible.builtin.systemd:
|
||||
name: ssh
|
||||
state: restarted
|
||||
enabled: yes
|
||||
Reference in New Issue
Block a user