-
Notifications
You must be signed in to change notification settings - Fork 0
/
first-time.yml
106 lines (89 loc) · 2.26 KB
/
first-time.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
- hosts: first_timers
become: '{{ become }}'
environment:
DEBIAN_FRONTEND: noninteractive
roles:
- postfix
- login-notify
tasks:
- name: Set hostname
hostname:
name: '{{ host_name }}'
use: '{{ host_name_strategy }}'
- name: Setup locale ru_RU.UTF-8
locale_gen:
name: ru_RU.UTF-8
state: present
- name: Setup timezone
timezone:
name: UTC
- name: Apt update
apt:
update_cache: true
cache_valid_time: 300
- name: Apt upgrade
apt:
upgrade: dist
- name: Apt cleanup
apt:
clean: true
autoclean: true
autoremove: true
- name: Install basic software
apt:
name:
- zsh
- curl
- tmux
- htop
- python3
- ca-certificates
state: latest
install_recommends: false
- name: Create remote user
user:
name: '{{ remote_user }}'
password: '!'
password_lock: true
shell: /bin/zsh
state: present
- name: SSH copy ID
authorized_key:
key: '{{ default_public_key }}'
user: '{{ remote_user }}'
state: present
exclusive: true
- name: Allow remote user to have passwordless sudo
lineinfile:
dest: /etc/sudoers
state: present
line: '%{{ remote_user }} ALL=(ALL) NOPASSWD: ALL'
- name: Disallow login as root, step 1
lineinfile:
dest: /etc/ssh/sshd_config
line: 'PermitRootLogin yes'
state: absent
- name: Disallow login as root, step 2
lineinfile:
dest: /etc/ssh/sshd_config
line: 'PermitRootLogin no'
state: present
- name: Disallow login with password, step 1
lineinfile:
dest: /etc/ssh/sshd_config
line: 'PasswordAuthentication yes'
state: absent
- name: Disallow login with password, step 2
lineinfile:
dest: /etc/ssh/sshd_config
line: 'PasswordAuthentication no'
state: present
- name: Add .zshrc
copy:
content: ''
dest: '/home/{{ remote_user }}/.zshrc'
owner: '{{ remote_user }}'
- name: Reload SSH
service:
name: ssh
state: reloaded