-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfresh_install_ubuntu_1404.yml
165 lines (140 loc) · 3.71 KB
/
fresh_install_ubuntu_1404.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
163
164
165
---
- hosts: testing
sudo: yes
gather_facts: yes
tasks:
### Update repos and distr
# - name: update repos and upgrade distr
# 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 rules.v4 from template
template:
src: templates/rules.v4.j2
dest: /etc/iptables/rules.v4
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: set VCS="git" in 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 ans bsd-mailx
apt: name={{ item }} state=latest update_cache=yes
with_items:
- ssmtp
- bsd-mailx
- name: copy ssmtp.conf from template
template:
src: templates/ssmtp.conf.j2
dest: /etc/ssmtp/ssmtp.conf
owner: root
group: root
mode: 0644
- name: copy mail.rc from template
template:
src: templates/mail.rc.j2
dest: /etc/mail.rc
owner: root
group: root
mode: 0644
### Install zabbix-agent and config
- name: download zabbix repo v.2.4. (deb)
get_url:
url: http://repo.zabbix.com/zabbix/2.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_2.4-1+trusty_all.deb
dest: /tmp
- name: install zabbix repo v.2.4. (deb)
apt:
deb: /tmp/zabbix-release_2.4-1+trusty_all.deb
- name: install zabbix-agent
apt:
name: zabbix-agent
state: latest
update_cache: yes
- name: copy zabbix_agentd.conf from template
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: install fail2ban
apt:
name: fail2ban
state: latest
update_cache: yes
- name: copy jail.conf from template
template:
src: templates/jail.conf.j2
dest: /etc/fail2ban/jail.conf
owner: root
group: root
mode: 0644
### Install logwatch and config
- name: install logwatch
apt:
name: logwatch
state: latest
update_cache: yes
- name: mdkir /var/cache/logwatch
file:
path: /var/cache/logwatch
state: directory
mode: 0755
- name: copy logwatch.conf from template
template:
src: templates/logwatch.conf.j2
dest: /etc/logwatch/conf/logwatch.conf
owner: root
group: root
mode: 0644
- name: execute logwatch --output mail
shell: /usr/sbin/logwatch --output mail
### Config ntpdate
- name: set NTP-server
lineinfile:
dest: /etc/crontab
line: "0 * * * * root ntpdate 10.59.3.38 >/dev/null"