forked from David-VTUK/Rancher-Packer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.sh
79 lines (65 loc) · 2.4 KB
/
script.sh
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
#!/bin/bash
# purge files to make sure since we are going to recreate them
rm /etc/rhsm/facts/katello.facts
rm /etc/yum.repos.d/docker.repo
rm /etc/environment
rm /etc/systemd/system/docker.service.d/https-proxy.conf
rm /etc/profile.d/proxy.sh
# Proxy stuff
cat <<EOT >> /etc/profile.d/proxy.sh
export HTTP_PROXY=http://<<proxy_server>>:8080
export HTTPS_PROXY=http://<<proxy_server>>:8080
export http_proxy=http://<<proxy_server>>:8080
export https_proxy=http://<<proxy_server>>:8080
EOT
cat <<EOT >> /etc/environment
http_proxy=http://<<proxy_server>>:8080
https_proxy=http://<<proxy_server>>:8080
HTTP_PROXY=http://<<proxy_server>>:8080
HTTPS_PROXY=http://<<proxy_server>>:8080
EOT
mkdir /etc/systemd/system/docker.service.d
cat <<EOT >> /etc/systemd/system/docker.service.d/https-proxy.conf
[Service]
Environment="HTTP_PROXY=http://<<proxy_server>>:8080/"
Environment="HTTPS_PROXY=http://<<proxy_server>>:8080/"
Environment="NO_PROXY=<<rancher_url>>,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
EOT
# Do subscription manager stuff and update packages
cat <<EOT >> /etc/rhsm/facts/katello.facts
{"network.hostname-override":"<<yourdomain>>.local"}
EOT
rpm -Uvh http://<<your_rsat_server>>/pub/katello-ca-consumer-latest.noarch.rpm
subscription-manager register --org="<<org_name>>" --activationkey='<<activation_key>>'
subscription-manager repos --enable=rhel-7-server-extras-rpms
yum -y install vim nano net-tools bind-utils
yum -y update
cat <<EOT >> /etc/yum.repos.d/docker.repo
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=http://<<your_repo_server>>/docker-ce-stable-upstream/
failovermethod=priority
enabled=1
gpgcheck=0
EOT
yum clean packages
yum clean metadata
yum clean all
yum -y install container-selinux
#yum -y install containerd.io
#The upstream has an issue where containerd.io is hidden from the system in yum
yum -y --disablerepo="*" --enablerepo=docker-ce-stable install http://<<your_repo_server>>/docker-ce-stable/Packages/containerd.io-1.2.13-3.2.el7.x86_64.rpm
yum -y install docker-ce docker-ce-selinux
systemctl daemon-reload
service docker restart
systemctl enable docker
subscription-manager unregister
docker run hello-world
docker rm $(docker ps -a -f status=exited -f status=created -q)
docker rmi $(docker images -a -q)
# Reset the machine-id value. This has known to cause issues with DHCP
#
echo -n > /etc/machine-id
# Reset any existing cloud-init state
#
cloud-init clean -s -l