-
Notifications
You must be signed in to change notification settings - Fork 2
/
normalize.yml
38 lines (31 loc) · 942 Bytes
/
normalize.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
- hosts: '*'
connection: local
become: True
vars:
my_hostname: ansible-control-node
tasks:
- name: Ensure root password is Vagrant
user:
name: root
password: '{{ "vagrant" | password_hash("sha512", "salt123") }}'
- name: Ensure ssh auth by password is on
lineinfile:
path: /etc/ssh/sshd_config
regexp: '.*PasswordAuthentication .*'
line: 'PasswordAuthentication yes'
register: ensure_ssh_root_auth
- name: Ensure root ssh access is on
lineinfile:
path: /etc/ssh/sshd_config
regexp: '.*PermitRootLogin .*'
line: 'PermitRootLogin yes'
register: ensure_ssh_password_auth
- name: restart SSH service
when: ensure_ssh_root_auth.changed or ensure_ssh_password_auth.changed
service:
name: ssh
state: restarted
- name: Change hostname
hostname:
name: '{{ my_hostname }}'