-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfresh_ubuntu_14.yml
162 lines (138 loc) · 3.52 KB
/
fresh_ubuntu_14.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
---
- hosts: testing
sudo: yes
gather_facts: yes
tasks:
# Update repos and distr
# - name: update distros and upgrade packages for latest versions
# apt:
# update_cache: yes
# upgrade: dist
# Change locale
- name: change locale
lineinfile:
dest: /etc/default/locale
regexp: '^LANG="ru'
line: 'LANG="en_US.UTF-8"'
backrefs: yes
# Install default packages
- name: install default packages
apt: name={{ item }} state=latest update_cache=yes
with_items:
- htop
- iotop
- smartmontools
- nmap
- vim
- sysstat
- dmidecode
# Install iptables and config
- name: install iptables-persistent
apt:
name: iptables-persistent
state: latest
update_cache: yes
- name: copy iptables rules
copy:
src: files/rules.v4.ansible
dest: /etc/iptables/
owner: root
group: root
mode: 0644
- name: create link for iptables
shell: /bin/ln -s /etc/init.d/iptables-persistent /etc/init.d/iptables
# Install etckeeper and config
- name: install etckeeper
apt:
name: etckeeper
state: latest
update_cache: yes
- name: configuring etckeeper.conf
lineinfile:
dest: /etc/etckeeper/etckeeper.conf
regexp: '^VCS="bzr"'
line: 'VCS="git"'
- command: etckeeper init
args:
chdir: /etc/
# Install ssmtp and config
- name: install ssmtp, bsd-mailx
apt: pkg={{ item }} state=latest update_cache=yes
with_items:
- ssmtp
- bsd-mailx
- name: configuring ssmtp
template:
src: templates/ssmtp.j2
dest: /etc/ssmtp/ssmtp.conf
owner: root
group: root
mode: 0644
- name: set ssmtp aliases
template:
src: templates/mail.rc
dest: /etc/mail.rc
owner: root
group: root
mode: 0644
# Install zabbix-agent and config
- name: install zabbix-agent
apt:
name: zabbix-agent
state: latest
update_cache: yes
- name: configuring zabbix-agent
template:
src: templates/zabbix-agent2.4.j2
dest: /etc/zabbix/zabbix_agentd.conf
owner: root
group: root
mode: 0644
- name: restart zabbix-agent
service:
name: zabbix-agent
state: restarted
enabled: yes
# Install fail2ban and config
- name: installing fail2ban
apt:
name: fail2ban
state: latest
update_cache: yes
- name: copy jail.conf
template:
src: templates/jail.conf.j2
dest: /etc/fail2ban/jail.conf
owner: root
group: root
mode: 0644
# Install logwatch and config
- name: installing logwatch
apt:
name: logwatch
state: latest
update_cache: yes
- name: mdkir /var/cache/logwatch
file:
path: /var/cache/logwatch
state: directory
mode: 0744
- name: copy logwatch.conf
template:
src: templates/logwatch.conf.j2
dest: /etc/logwatch/conf/logwatch.conf
owner: root
group: root
mode: 0644
- name: run logwatch
shell: /usr/sbin/logwatch --output mail
# Install ntpdate and config
- name: install ntpdate
apt:
name: ntpdate
state: latest
update_cache: yes
- name: set NTP-server
# lineinfile: dest=/etc/crontab line="0 * * * * root ntpdate ntp4.stratum2.ru >/dev/null"
lineinfile:
dest: /etc/crontab line="0 * * * * root ntpdate 10.59.3.38 >/dev/null"