forked from theforeman/ovirt-node-plugin-foreman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ovirt-node-plugin-foreman.spec.in
200 lines (170 loc) · 6.4 KB
/
ovirt-node-plugin-foreman.spec.in
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# vim: ts=4:sw=4:et
#
# Copyright (C) 2013 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA. A copy of the GNU General Public License is
# also available at http://www.gnu.org/copyleft/gpl.html.
Summary: A plugin for Foreman Discovery nodes
Name: ovirt-node-plugin-foreman
Version: @VERSION@
Release: 1%{?BUILD_NUMBER}%{?extra_release}%{?dist}
Source0: %{name}-%{version}.tar.gz
License: GPLv2+
Group: Applications/System
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
URL: http://www.ovirt.org/
Requires: ovirt-node >= 3.0.0
Requires: facter
Requires: foreman-proxy
Requires: sudo
%if "@PLUGIN_DEBUG@" == "1"
Requires: openssh-server
Requires: vim-minimal
Requires: file telnet lsof
%endif
BuildArch: noarch
%if 0%{?rhel} == 6
Requires: chkconfig initscripts
%else
BuildRequires: systemd
%endif
%define app_root %{_datadir}/%{name}
%define recipe_root %{_datadir}/ovirt-node-recipe
%description
Provides Foreman Proxy and Discovery component for automatic registration
of nodes in Foreman and provisioning.
%package recipe
Summary: Kickstarts for building Node isos including %{name}
Group: Applications/System
Requires: ovirt-node-recipe >= 2.6.0
%description recipe
Provides kickstart files for generating an oVirt Node ISO image containing
%{name}.
%prep
%setup -q
%build
%if "@PLUGIN_DEBUG@" == "1"
%configure --enable-debug
%else
%configure
%endif
%install
%{__rm} -rf %{buildroot}
make install DESTDIR=%{buildroot}
%post
# Modify login issue
sed -i 's/oVirt Node Hypervisor release/Foreman Discovery/' %{_sysconfdir}/issue
# Reserve tty1 only for logs
%if 0%{?rhel} == 6
sed -i 's/^.*ACTIVE_CONSOLES.*$/ACTIVE_CONSOLES=\/dev\/tty\[2-6\]/' %{_sysconfdir}/sysconfig/init
%else
rm -f %{_sysconfdir}/systemd/system/getty.target.wants/[email protected]
%endif
# In development mode set password and enable ssh daemon (with root access)
%if "@PLUGIN_DEBUG@" == "1"
echo "root:development" | chpasswd
sed -i 's/^.*PasswordAuthentication.*$/PasswordAuthentication yes/' %{_sysconfdir}/ssh/sshd_config
sed -i 's/^.*PermitRootLogin.*$/PermitRootLogin yes/' %{_sysconfdir}/ssh/sshd_config
%endif
# Configure foreman-proxy
%if "@PLUGIN_DEBUG@" == "1"
LOGLEVEL="DEBUG"
%else
LOGLEVEL="ERROR"
%endif
sed -i "s/.*:log_level:.*/:log_level: $LOGLEVEL/" %{_sysconfdir}/foreman-proxy/settings.yml
sed -i 's/.*:bmc:.*/:bmc: true/' %{_sysconfdir}/foreman-proxy/settings.yml
sed -i 's/.*:bmc_default_provider:.*/:bmc_default_provider: shell/' %{_sysconfdir}/foreman-proxy/settings.yml
# Connect smart-proxy standard output to tty1
# TODO: on RHEL6 setup ownership of /dev/tty1 for o+w
%if 0%{?rhel} == 6
sed -i 's|.*:log_file:.*|:log_file: /dev/null|' %{_sysconfdir}/foreman-proxy/settings.yml
%else
sed -i 's|.*:log_file:.*|:log_file: /dev/stdout|' %{_sysconfdir}/foreman-proxy/settings.yml
sed '/^ExecStart/aStandardOutput=tty' -i /usr/lib/systemd/system/foreman-proxy.service
sed '/^ExecStart/aTTYPath=/dev/tty1' -i /usr/lib/systemd/system/foreman-proxy.service
%endif
# Enable Foreman Proxy service
%if 0%{?rhel} == 6
chkconfig foreman-proxy on
%else
systemctl enable foreman-proxy.service
%endif
# Enable Discover Host service (must be executed as the last - idle - service)
%if 0%{?rhel} == 6
chkconfig --add discover-host
chkconfig discover-host on
%else
systemctl enable discover-host.service
%endif
# Set extra directory for facter
%if 0%{?rhel} == 6
echo "FACTERLIB=/usr/share/ovirt-node-plugin-foreman" >> %{_sysconfdir}/sysconfig/foreman-proxy
%else
sed -i '/\[Service\]/a Environment="FACTERLIB=/usr/share/ovirt-node-plugin-foreman"' /usr/lib/systemd/system/foreman-proxy.service
%endif
# Add foreman-proxy user to sudo and disable interactive tty for reboot
sed -i -e 's/^Defaults.*requiretty/Defaults !requiretty/g' %{_sysconfdir}/sudoers
echo "foreman-proxy ALL=NOPASSWD: /sbin/shutdown" >> %{_sysconfdir}/sudoers
# Limit maximum use of logs (it is kept in memory for stateless)
%if 0%{?rhel} == 6
sed -i -e 's/^weekly$/daily/g' %{_sysconfdir}/logrotate.conf
sed -i -e 's/^rotate 4$/rotate 1/g' %{_sysconfdir}/logrotate.conf
%else
sed -i -e 's/^.*SystemMaxUse.*$/SystemMaxUse=20M/g' %{_sysconfdir}/systemd/journald.conf
%endif
# Setup network
%if 0%{?rhel} == 6
# Not using NetworkManager - configure network manually for first six ifaces (random order)
sed -i -e 's/^.*NETWORKING=.*$/NETWORKING=yes/g' %{_sysconfdir}/sysconfig/network
for DEVICE in eth0 eth1 eth2 eth3 eth4 eth5; do
cat > %{_sysconfdir}/sysconfig/network-scripts/ifcfg-$DEVICE <<EONS
DEVICE=$DEVICE
NM_CONTROLLED=no
ONBOOT=yes
BOOTPROTO=dhcp
EONS
done
chkconfig network on
# Enable smart-proxy port in firewall
iptables -I INPUT 1 -m state --state NEW -m tcp -p tcp --dport 8443 -j ACCEPT
service iptables save
%else
# Systemd only - force NetworkManager to wait for IP address
systemctl enable NetworkManager-wait-online.service
# Enable smart-proxy port in firewall
# TODO: Move rule from discover-host.service in here and test in Fedora 18+ and RHEL7
%endif
# When using ntpdate during start, do not pause when time servers not available
[ -f %{_sysconfdir}/sysconfig/ntpdate ] && sed -i -e 's/^.*RETRIES.*$/RETRIES=0/g' %{_sysconfdir}/sysconfig/ntpdate
%files recipe
%{recipe_root}
%files
%{_bindir}/discover-host.rb
%{_bindir}/find-missing-libs
%{_datadir}/%{name}/discovery-version-fact.rb
%if 0%{?rhel} == 6
%{_sysconfdir}/rc.d/init.d/discover-host
%else
%{_unitdir}/discover-host.service
%endif
%{_sysconfdir}/ovirt-plugins.d
%changelog
* Thu Dec 19 2013 Lukas Zapletal <[email protected]> 0.2.0-1
- Logging on tty1
- Changes to /etc/issue
- Faster start
* Wed Oct 30 2013 Lukas Zapletal <[email protected]> 0.1.0-1
- Initial version