vn-ansible/linux/base-config-debian/roles/config-root-user/tasks/main.yaml

41 lines
1.3 KiB
YAML
Raw Normal View History

2023-10-13 07:08:54 +00:00
---
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-13 07:08:54 +00:00
# delete default user , only on VM
- name: delete default user , only on VM
user:
name: "{{ name_user }}"
state: absent
remove: yes
tags:
- delete-user
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-13 07:08:54 +00:00
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-13 07:08:54 +00:00
# change root password
- name: change root password
user:
name: root
password: "{{ ssh_password | password_hash('sha512') }}"
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-13 07:08:54 +00:00
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-13 07:08:54 +00:00
# config sshd_config file , no root password
- name: change sshd_config to no root password
copy:
src: /etc/ssh/sshd_config.orig
dest: /etc/ssh/sshd_config
2023-10-13 08:05:38 +00:00
remote_src: yes
2023-10-13 07:08:54 +00:00
owner: root
group: root
mode: '0644'
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-13 07:08:54 +00:00
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-13 07:08:54 +00:00
# delete file sshd_config.orig
- name: delete /etc/ssh/sshd_config.orig file
file:
path: /etc/ssh/sshd_config.orig
state: absent
2023-10-18 07:09:20 +00:00
notify: Restart ssh service
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++