Skip to content

Commit

Permalink
Merge pull request #80 from duftler/centos-tweaks
Browse files Browse the repository at this point in the history
Use sudo to run yum in packer templates.
  • Loading branch information
Matt Duftler committed Mar 25, 2016
2 parents ff07148 + 7dd5917 commit ba340af
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions rosco-web/config/packer/aws-ebs.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"vpc_id": "{{user `aws_vpc_id`}}",
"region": "{{user `aws_region`}}",
"ssh_username": "{{user `aws_ssh_username`}}",
"ssh_pty": true,
"instance_type": "{{user `aws_instance_type`}}",
"source_ami": "{{user `aws_source_ami`}}",
"ami_name": "{{user `aws_target_ami`}}",
Expand Down
2 changes: 2 additions & 0 deletions rosco-web/config/packer/gce.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"account_file": "{{user `gce_account_file`}}",
"zone": "{{user `gce_zone`}}",
"network": "{{user `gce_network`}}",
"ssh_username": "packerio",
"ssh_pty": true,
"source_image": "{{user `gce_source_image`}}",
"image_name": "{{user `gce_target_image`}}",
"use_internal_ip": "{{user `gce_use_internal_ip`}}",
Expand Down
15 changes: 8 additions & 7 deletions rosco-web/config/packer/install_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ function provision_deb() {
# https://www.packer.io/docs/builders/amazon-chroot.html look at gotchas at the end.
if [[ "$disable_services" == "true" ]]; then
echo "creating /usr/sbin/policy-rc.d to prevent services from being started"
echo '#!/bin/sh' > /usr/sbin/policy-rc.d
echo 'exit 101' >> /usr/sbin/policy-rc.d
chmod a+x /usr/sbin/policy-rc.d
echo '#!/bin/sh' | sudo tee /usr/sbin/policy-rc.d > /dev/null
echo 'exit 101' | sudo tee -a /usr/sbin/policy-rc.d > /dev/null
sudo chmod a+x /usr/sbin/policy-rc.d
fi

if [[ "$repository" != "" ]]; then
Expand All @@ -41,26 +41,27 @@ function provision_deb() {
# https://www.packer.io/docs/builders/amazon-chroot.html look at gotchas at the end.
if [[ "$disable_services" == "true" ]]; then
echo "removing /usr/sbin/policy-rc.d"
rm -f /usr/sbin/policy-rc.d
sudo rm -f /usr/sbin/policy-rc.d
fi
}

function provision_rpm() {
if [[ "$repository" != "" ]]; then
cat > /etc/yum.repos.d/spinnaker.repo <<EOF
cat > /tmp/spinnaker.repo <<EOF
[spinnaker]
name=spinnaker
baseurl=$repository
gpgcheck=0
enabled=1
EOF
sudo mv /tmp/spinnaker.repo /etc/yum.repos.d/
fi

if [[ "$upgrade" == "true" ]]; then
yum -y update
sudo yum -y update
fi

yum -y install $packages
sudo yum -y install $packages
}

function main() {
Expand Down

0 comments on commit ba340af

Please sign in to comment.