-
Notifications
You must be signed in to change notification settings - Fork 24
/
centos.7.cfg.j2
124 lines (107 loc) · 3.52 KB
/
centos.7.cfg.j2
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
install
lang en_US.UTF-8
keyboard us
auth --useshadow --enablemd5
services --enabled=network,sshd,snmpd,ntpd
eula --agreed
network --device={{ hostvars[item]['netdev'] | default('eth0') }} --onboot=yes --hostname={{ item }} {{ hostvars[item]['netargs'] | default('') }}
{%- if hostvars[item]['ip'] is defined %}
--bootproto=static --ip={{ hostvars[item]['ip'] }} --netmask={{ hostvars[item]['netmask'] }} --gateway={{ hostvars[item]['gateway'] }} --nameserver=
{%- for ns in hostvars[item]['nameservers'] %}
{{ ns }}{% if not loop.last %},{% endif %}
{%- endfor %}
{% else %}
--bootproto=dhcp
{% endif %}
rootpw --iscrypted {{ hostvars[item]['rootpw'] | default('$1$Jxif9H1Q$c5oIEvRdtkSDJs8ZBcRZ3/') }}
firewall --disabled
selinux --disabled
timezone --utc Europe/Moscow
firstboot --disable
skipx
text
ignoredisk --only-use={{ hostvars[item]['drive'] | default('sda') }}
bootloader --location=mbr --append="ipv6.disable=1 net.ifnames=0 biosdevname=0"
zerombr
clearpart --drives={{ hostvars[item]['drive'] | default('sda') }} --all
part swap --asprimary --fstype=swap --ondisk={{ hostvars[item]['drive'] | default('sda') }} --size=1024
part / --asprimary --fstype=xfs --ondisk={{ hostvars[item]['drive'] | default('sda') }} --size=1024 --grow
reboot
%packages
@base
@core
@hardware-monitoring
@system-admin-tools
net-tools
net-snmp
ntp
screen
vim-enhanced
%end
%post --log=/root/ks-post.log
sed -i -e 's|^# %wheel\tALL=(ALL)\tNOPASSWD: ALL|%wheel\tALL=(ALL)\tNOPASSWD: ALL|; s|^Defaults requiretty|#&|' /etc/sudoers
### DNS settings
cat << EOF > /etc/resolv.conf
domain {{ domain }}
search {{ domain }}
{% for item in hostvars[item]['nameservers'] %}
nameserver {{ item }}
{% endfor %}
EOF
### disable /etc/resolv.conf rewritting if NM is installed
[ -f /etc/NetworkManager/NetworkManager.conf ] && sed -i '/\[main\]/a dns=none' /etc/NetworkManager/NetworkManager.conf
### creating new /etc/hosts
cat << EOF > /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
EOF
### ntp.conf
#mv /etc/ntp.conf /etc/ntp.conf.orig
#cat << EOF > /etc/ntp.conf
#restrict default kod nomodify notrap nopeer noquery
#restrict 127.0.0.1
#server ntp1
#server ntp2
#driftfile /var/lib/ntp/drift
#keys /etc/ntp/keys
#EOF
# repository configuration
#find /etc/yum.repos.d/ -type f -exec mv '{}' '{}'.save ';'
#cat <<'EOF' >/etc/yum.repos.d/Local.repo
#[os]
#name=os
#baseurl={{ repo_url }}{{ hostvars[item]['os'] }}/{{ hostvars[item]['osver'] }}/os/x86_64/
#enabled=1
#
#[extras]
#name=os
#baseurl={{ repo_url }}{{ hostvars[item]['os'] }}/{{ hostvars[item]['osver'] }}/extras/x86_64/
#enabled=1
#EOF
### create snmp config
cat << EOF >/etc/snmp/snmpd.conf
com2sec notConfigUser default public
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
access notConfigGroup "" any noauth exact systemview none none
view systemview included .1
master agentx
agentxperms 770 770 daemon daemon
dontLogTCPWrappersConnects 1
interface lo 24 1000000000
EOF
install --mode=700 -d /root/.ssh
install --mode=700 /dev/null /root/.ssh/authorized_keys
{% if hostvars[item]['root_authorized_keys'] is defined %}
cat << 'EOF' >> /root/.ssh/authorized_keys
{{ hostvars[item]['root_authorized_keys'] }}
EOF
{% endif %}
{% if root_authorized_keys is defined %}
cat << 'EOF' >> /root/.ssh/authorized_keys
{{ root_authorized_keys }}
EOF
{% endif %}
%end