Skip to content

Commit

Permalink
Finally working versions. Seems the _server variables have to be fixe…
Browse files Browse the repository at this point in the history
…d in the json, not on the command line. Force using local server for images, pick random UK mirror for repo
  • Loading branch information
Tony Wildish committed Aug 16, 2019
1 parent f8a4697 commit 3676d65
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 18 deletions.
36 changes: 25 additions & 11 deletions doit.openstack.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

packer_log=packer.openstack.log
[ -f $packer_log ] && cp /dev/null $packer_log
export PACKER_LOG_PATH=packer.openstack.log
[ -f $PACKER_LOG_PATH ] && cp /dev/null $PACKER_LOG_PATH

set -ex
ksServer='ks-server'
Expand Down Expand Up @@ -35,21 +35,35 @@ else
fi
fi

base_url="http://mozart.ee.ic.ac.uk/CentOS"
repo_server="$base_url"
iso_server="$base_url"
# centos_mirror="http://mozart.ee.ic.ac.uk/CentOS"
if [ $RANDOM_MIRROR ]; then
CENTOS_MIRROR=`./get-centos-uk-mirror.sh`
fi
centos_mirror=${CENTOS_MIRROR:=http://45.86.170.150/CentOS}
repo_server=${REPO_SERVER:=$centos_mirror}
iso_server=http://45.86.170.150/CentOS # "http://mozart.ee.ic.ac.uk/CentOS" #${ISO_SERVER:=$centos_mirror}

template="templates/os/${image}.json.template"
target="http/builds/packer/os/${image}.json"
target2="templates/os/${image}.json"
cat $template \
| sed -e "s%__REPO_SERVER__%$repo_server%g" \
-e "s%__ISO_SERVER__%$iso_server%g" \
| tee $target \
| tee $target2 \
> /dev/null

headless=true
PACKER_LOG=1 \
# opts="-on-error=ask -debug"
export ANSIBLE_DEBUG=0
export ANSIBLE_SSH_ARGS="-C -o ControlMaster=auto -o ControlPersist=60s -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
export ANSIBLE_SSH_ARGS="-v $ANSIBLE_SSH_ARGS"
export headless=true
export PACKER_LOG=1
packer build --force \
-var-file=http/builds/packer/site.json \
-var-file=http/builds/packer/os/$image.json \
$opts \
--only=openstack \
-var ks_server=http://$host_ip:$port/ \
-var headless=$headless \
-var iso_server=$iso_server \
-var repo_server=$repo_server \
templates/main.json


22 changes: 15 additions & 7 deletions doit.virtualbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,28 @@ fi
if [ $RANDOM_MIRROR ]; then
CENTOS_MIRROR=`./get-centos-uk-mirror.sh`
fi
centos_mirror=${CENTOS_MIRROR:=http://mirror.nsc.liu.se/CentOS}
centos_mirror=${CENTOS_MIRROR:=http://45.86.170.150/CentOS}
repo_server=${REPO_SERVER:=$centos_mirror}
iso_server=${ISO_SERVER:=$centos_mirror}
iso_server=http://45.86.170.150/CentOS # "http://mozart.ee.ic.ac.uk/CentOS" #${ISO_SERVER:=$centos_mirror}

template="templates/os/${image}.json.template"
target="http/builds/packer/os/${image}.json"
target2="templates/os/${image}.json"
cat $template \
| sed -e "s%__REPO_SERVER__%$repo_server%g" \
-e "s%__ISO_SERVER__%$iso_server%g" \
| tee $target \
| tee $target2 \
> /dev/null

vb_version=`VBoxManage -v | awk -Fr '{ print $1 }'`
vbga_iso="VBoxGuestAdditions_${vb_version}.iso"
[ -f $vbga_iso ] || wget -O $vbga_iso https://download.virtualbox.org/virtualbox/${vb_version}/$vbga_iso

# opts="-on-error=ask -debug"
# export ANSIBLE_DEBUG=1
# export ANSIBLE_SSH_ARGS="-C -o ControlMaster=auto -o ControlPersist=60s"
# export ANSIBLE_SSH_ARGS="-v $ANSIBLE_SSH_ARGS"
export headless=true
export PACKER_LOG=1
packer build --force \
Expand All @@ -57,9 +70,4 @@ packer build --force \
--only=virtualbox \
-var ks_server=http://$host_ip:$port/ \
-var headless=$headless \
-var guest_additions_path=$vbga_iso \
-var iso_server=$iso_server \
-var repo_server=$repo_server \
templates/main.json

# echo qemu-img convert -p -O qcow2 source-image-file.vmdk converted-image-file.qcow2
9 changes: 9 additions & 0 deletions templates/os/CentOS-7.6.1810.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"vm_name": "CentOS-7.6.1810",
"os_name": "CentOS",
"os_version": "7.6.1810",
"iso": "CentOS-7-x86_64-NetInstall-1810",
"iso_checksum": "19d94274ef856c4dfcacb2e7cfe4be73e442a71dd65cc3fb6e46db826040b56e",
"iso_server": "__ISO_SERVER__",
"repo_server": "__REPO_SERVER__"
}

0 comments on commit 3676d65

Please sign in to comment.