Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit 5f0ad8c

Browse files
committed
fix issue with Jenkins not launching after install
1 parent 64fe104 commit 5f0ad8c

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

InstallJenkinsServer.sh

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ chef_server_name=$4
77
chef_server_org_shortname=$5
88

99
# make sure we have everythign we need
10+
echo "Fetch Apt Key for the Jenkins repo"
1011
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
1112
echo deb https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
1213

14+
echo "Install the pre-reqs"
1315
apt-get update
14-
apt-get -y install curl default-jdk jenkins
16+
apt-get -y install curl default-jdk
17+
18+
echo "Install Jenkins"
19+
apt-get -y install jenkins
1520

1621
sudo hostnamectl set-hostname ${jenkins_server_name}
1722

1823
echo "Installing ChefDK..."
1924
wget https://packages.chef.io/files/stable/chefdk/${chefdk_version}/ubuntu/16.04/chefdk_${chefdk_version}-1_amd64.deb
2025
dpkg -i chefdk_${chefdk_version}-1_amd64.deb
2126

27+
echo "Buildingthe chef_repo folders"
2228
# Build chef_repo structure
2329
if [ ! -d /var/lib/jenkins/chef_repo ]; then
2430
mkdir /var/lib/jenkins/chef_repo
@@ -39,14 +45,12 @@ if [ ! -d /var/lib/jenkins/chef_repo/roles ]; then
3945
mkdir /var/lib/jenkins/chef_repo/roles
4046
fi
4147

42-
# Fetch certificate
4348
if [ ! -f /var/lib/jenkins/chef_repo/.chef/$chef_server_user.pem ]; then
44-
# fetch token
4549
echo "Fetching the admin pem from the chef server"
4650
scp -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa ${chef_server_user}@${chef_server_name}:~/${chef_server_user}.pem /var/lib/jenkins/chef_repo/.chef/$chef_server_user.pem
4751
fi
4852

49-
# Build knife.rb
53+
echo "Building the knife.rb"
5054
if [ ! -f /var/lib/jenkins/chef_repo/.chef/knife.rb ]; then
5155
echo "# See https://docs.getchef.com/config_rb_knife.html for more information on knife configuration options" > /var/lib/jenkins/chef_repo/.chef/knife.rb
5256

@@ -60,8 +64,18 @@ if [ ! -f /var/lib/jenkins/chef_repo/.chef/knife.rb ]; then
6064
echo "ssl_verify_mode :verify_none" >> /var/lib/jenkins/chef_repo/.chef/knife.rb
6165
fi
6266

63-
# fix the permissions for Jenkins
67+
echo "Fixing the permissions for Jenkins"
6468
chown -R jenkins:jenkins /var/lib/jenkins/chef_repo
6569

66-
#
70+
echo "Setting up iptables rules"
71+
mv -f /home/${chef_server_user}/rc.local /etc/rc.local
72+
chmod +x /etc/rc.local
73+
74+
echo "one time run of iptables since rc.local won't play nice in terraform"
75+
#Requests from outside
76+
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
77+
#Requests from localhost
78+
iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080
79+
80+
# Done!
6781
echo "Your Jenkins server is ready!"

JenkinsServer.tf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ resource "azurerm_virtual_machine" "jenkins" {
109109
"sudo /tmp/InstalljenkinsServer.sh ${azurerm_public_ip.jenkins_pubip.fqdn} ${var.chefdk_version} ${var.username} ${azurerm_public_ip.chef_pubip.fqdn} ${var.chef_server_org_shortname} > install.log ",
110110
"sudo chmod +x /tmp/BootstrapNodes.sh",
111111
"sudo /tmp/BootstrapNodes.sh ${var.username} ${var.password}",
112-
"sudo mv -f ./rc.local /etc/rc.local",
113-
"sudo chmod +x /etc/rc.local",
114-
"sudo ./etc/rc.local",
115112
]
116113
}
117114
}

0 commit comments

Comments
 (0)