Separate files needing GPL license
[csit.git] / resources / tools / testbed-setup / ansible / roles / cobbler / files / Dockerfile
1 # Copyright (c) 2019 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 FROM centos:7
15
16 MAINTAINER csit-dev <csit-dev@lists.fd.io>
17 LABEL Description="CSIT cobbler service image."
18 LABEL Version="0.1"
19
20 # Build arguments
21 ARG cobbler_sys_pass
22 ARG cobbler_web_pass
23 ARG cobbler_ip_addr
24 ARG cobbler_http_port=60080
25 ARG cobbler_https_port=60443
26
27 # Install dependencies
28 RUN yum -y install epel-release \
29     && yum -y install \
30         cobbler \
31         cobbler-web \
32         fence-agents \
33         python-pip \
34         curl \
35         dhcp \
36         bind \
37         file \
38         debmirror \
39         net-tools \
40         rsync \
41         pykickstart \
42         supervisor \
43         wget \
44         which \
45     && yum clean all \
46     && rm -rf /var/cache/yum
47
48 # Workaround for Cobbler 2.8.4 bug
49 RUN pip2.7 install -U django==1.9.13
50
51 # Copy CSIT configration
52 COPY supervisord/supervisord.conf /etc/supervisord.conf
53 COPY etc/cobbler/dhcp.template /etc/cobbler/dhcp.template
54 COPY var/lib/cobbler/kickstarts/* /var/lib/cobbler/kickstarts/
55 COPY etc/httpd/conf.d/cobbler_web.conf /etc/httpd/conf.d/cobbler_web.conf
56
57 RUN sed -i \
58     -e "/^default_password_crypted/ s|:.*$|: \"${cobbler_sys_pass}\"|" \
59     -e "/^next_server:/ s/:.*$/: ${cobbler_ip_addr}/" \
60     -e "/^server/ s/:.*$/: ${cobbler_ip_addr}/" \
61     -e "/^http_port:/ s/:.*$/: ${cobbler_http_port}/" \
62     -e "/^pxe_just_once:/ s/:.*$/: 1/" \
63     -e "/^manage_dhcp:/ s/:.*$/: 1/" \
64     /etc/cobbler/settings \
65     && sed -i "s/service %s restart/supervisorctl restart %s/g" \
66     /usr/lib/python2.7/site-packages/cobbler/modules/sync_post_restart_services.py \
67     && sed -i "s/Listen 80/Listen ${cobbler_http_port}/g" \
68     /etc/httpd/conf/httpd.conf \
69     && sed -i "s/Listen 443 https/Listen ${cobbler_https_port} https/g" \
70     /etc/httpd/conf.d/ssl.conf
71
72 # Change Cobbler WEB password
73 RUN echo -n "cobbler:Cobbler:${cobbler_web_pass}" \
74     | md5sum \
75     | cut -d' ' -f1 \
76     | xargs printf "%s:%s:%s\n" cobbler Cobbler  > "/etc/cobbler/users.digest"
77
78 # Create Cobbler directories
79 RUN mkdir -p /var/lib/cobbler/config/distros.d \
80     && mkdir -p /var/lib/cobbler/config/files.d \
81     && mkdir -p /var/lib/cobbler/config/images.d \
82     && mkdir -p /var/lib/cobbler/config/mgmtclasses.d \
83     && mkdir -p /var/lib/cobbler/config/packages.d \
84     && mkdir -p /var/lib/cobbler/config/profiles.d \
85     && mkdir -p /var/lib/cobbler/config/repos.d \
86     && mkdir -p /var/lib/cobbler/config/systems.d \
87     && mkdir -p /var/www/cobbler/links/ \
88     && touch /usr/share/cobbler/web/cobbler.wsgi
89
90 # Expose TFTP WWW COBBLER
91 EXPOSE 69
92 EXPOSE $cobbler_http_port
93 EXPOSE $cobbler_https_port
94 EXPOSE 25151
95
96 ENTRYPOINT /usr/bin/supervisord -c /etc/supervisord.conf