cleanup mirror-image
Change-Id: Iba39ddce46cff01e41e34b8c26970bc3cb46ff48
diff --git a/mirror-image/http/bootstrap.saltstack.com.sh b/mirror-image/files/tmp/bootstrap.saltstack.com.sh
similarity index 100%
rename from mirror-image/http/bootstrap.saltstack.com.sh
rename to mirror-image/files/tmp/bootstrap.saltstack.com.sh
diff --git a/mirror-image/run.example.sh b/mirror-image/run.example.sh
index 9b50ebc..3f7328c 100644
--- a/mirror-image/run.example.sh
+++ b/mirror-image/run.example.sh
@@ -35,16 +35,17 @@
export VM_FLAVOR="3c4fe514-3eb6-464d-a419-7be09d72cf1e"
export VM_FLOATING_IP_POOL="095f43ed-65ba-48ce-8185-d4080e430a88"
export IMAGE_NAME="mcp-offline-mirror-$(date '+%Y-%m-%d-%H-%M-%S')"
-export VM_IMAGE="9953a40d-1fa2-4f26-b146-0507dbc912dc"
-export OS_TENANT_ID=$OS_PROJECT_ID
-export OS_DOMAIN_NAME="ldap"
-export OS_TENANT_NAME="azvyagintsev"
-
-#rm -rf images/
-#cloud-localds --hostname ubuntu --dsmode local config-drive/cloudata.iso config-drive/user-data.yaml
-rm -rf ~/.packer.d/
+export VM_IMAGE="9953a40d-1fa2-4f26-b146-0507dbc912dc" # ubuntu cloud img
+# May be need, if cloud with keystone v3 used
+#export OS_TENANT_ID=$OS_PROJECT_ID
+#export OS_DOMAIN_NAME="xxxx"
+#export OS_TENANT_NAME="xxxxx"
export PACKER_LOG=1
-#packer build -only=qemu -parallel=false -on-error=ask template.openstack.json
+# For qemu test-build:
+#cloud-localds --hostname ubuntu --dsmode local config-drive/cloudata.iso config-drive/user-data.yaml
+# packer build -only=qemu -parallel=false -on-error=ask template.json
+# rm -rf ~/.packer.d/
+
+# For openstack test-build
packer build -only=openstack -parallel=false -on-error=ask template.json
-#packer build -only=openstack -parallel=false -on-error=ask template.json
diff --git a/mirror-image/scripts/base.sh b/mirror-image/scripts/base.sh
index 1487f42..d23be8b 100644
--- a/mirror-image/scripts/base.sh
+++ b/mirror-image/scripts/base.sh
@@ -9,6 +9,13 @@
echo "Acquire::CompressionTypes::Order gz;" >/etc/apt/apt.conf.d/99compression-workaround-salt
echo "Acquire::EnableSrvRecords false;" >/etc/apt/apt.conf.d/99enablesrvrecords-false
+echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99aws-s3-mirrors-workaround-salt
+echo "APT::Install-Recommends false;" > /etc/apt/apt.conf.d/99dont_install_recommends-salt
+echo "APT::Install-Suggests false;" > /etc/apt/apt.conf.d/99dont_install_suggests-salt
+echo "Acquire::Languages none;" > /etc/apt/apt.conf.d/99dont_acquire_all_languages-salt
+echo "APT::Periodic::Update-Package-Lists 0;" > /etc/apt/apt.conf.d/99dont_update_package_list-salt
+echo "APT::Periodic::Download-Upgradeable-Packages 0;" > /etc/apt/apt.conf.d/99dont_update_download_upg_packages-salt
+echo "APT::Periodic::Unattended-Upgrade 0;" > /etc/apt/apt.conf.d/99disable_unattended_upgrade-salt
sysctl -w fs.file-max=100000
# Overwrite default mirrors
diff --git a/mirror-image/scripts/cleanup.sh b/mirror-image/scripts/cleanup.sh
index 01dd605..295d4cb 100644
--- a/mirror-image/scripts/cleanup.sh
+++ b/mirror-image/scripts/cleanup.sh
@@ -6,7 +6,8 @@
rm -f /usr/sbin/policy-rc.d || true
echo "cleaning up hostname"
-sed -i "/.*ubuntu-1604.*/d" /etc/hosts
+sed -i "/.*ubuntu.*/d" /etc/hosts
+sed -i "/.*salt.*/d" /etc/hosts
echo "cleaning up guest additions"
rm -rf VBoxGuestAdditions_*.iso VBoxGuestAdditions_*.iso.? || true
diff --git a/mirror-image/scripts/mirrors.sh b/mirror-image/scripts/mirrors.sh
index 9dd7599..23bd679 100644
--- a/mirror-image/scripts/mirrors.sh
+++ b/mirror-image/scripts/mirrors.sh
@@ -3,7 +3,7 @@
salt-call -t 5 --retcode-passthrough --no-color state.sls docker.host
#docker run --restart always -d -p 5000:5000 --name registry registry:2
salt-call -t 5 --retcode-passthrough state.sls docker.client.registry
-docker system prune --all --force
+#docker system prune --all --force
#aptly
salt-call -t 5 --no-color state.sls aptly
diff --git a/mirror-image/scripts/reboot.sh b/mirror-image/scripts/reboot.sh
deleted file mode 100644
index 52adc95..0000000
--- a/mirror-image/scripts/reboot.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-pgrep -f "sshd: root@" | xargs kill -9
-reboot now
\ No newline at end of file
diff --git a/mirror-image/scripts/salt_bootstrap.sh b/mirror-image/scripts/salt_bootstrap.sh
index 9732123..8dec3ce 100644
--- a/mirror-image/scripts/salt_bootstrap.sh
+++ b/mirror-image/scripts/salt_bootstrap.sh
@@ -1,6 +1,7 @@
#!/bin/bash -xe
-# CLUSTER_MODEL_REF=
+CLUSTER_MODEL_REF=${CLUSTER_MODEL_REF:-master}
+FORMULA_VERSION=${FORMULA_VERSION:-testing}
SALTSTACK_GPG=${SALTSTACK_GPG:-"https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub"}
SALTSTACK_REPO=${SALTSTACK_REPO:-"http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3 xenial main"}
APT_MIRANTIS_GPG=${APT_MIRANTIS_GPG:-"http://apt.mirantis.com/public.gpg"}
@@ -27,8 +28,9 @@
export APT_REPOSITORY=" deb [arch=amd64] ${APT_MIRANTIS_SALT_REPO} "
export APT_REPOSITORY_GPG=${APT_MIRANTIS_GPG}
if [[ ! -z "${PACKER_OFFLINE_BUILD}" ]];then
- echo "offline detected!"
- export BOOTSTRAP_SALTSTACK_COM="http://${PACKER_HTTP_ADDR}/bootstrap.saltstack.com.sh"
+ echo "INFO: build in offline detected!"
+ export BOOTSTRAP_SALTSTACK_COM="file:///tmp/bootstrap.saltstack.com.sh"
+ # extra opts will push bootstrap script NOT install upstream repos.
export BOOTSTRAP_SALTSTACK_OPTS=${BOOTSTRAP_SALTSTACK_OPTS:- -dXr $BOOTSTRAP_SALTSTACK_VERSION }
fi
#
diff --git a/mirror-image/template.json b/mirror-image/template.json
index 1bd1360..b1a7171 100644
--- a/mirror-image/template.json
+++ b/mirror-image/template.json
@@ -6,7 +6,7 @@
"image_name": "{{ env `IMAGE_NAME` }}",
"VM_IMAGE": "{{ env `VM_IMAGE` }}",
"floating_ip_pool": "{{ env `VM_FLOATING_IP_POOL` }}",
- "VM_FLAVOR" : "{{ env `VM_FLAVOR` }}",
+ "VM_FLAVOR": "{{ env `VM_FLAVOR` }}",
"disk_size": "150000",
"cluster_model": "{{ env `CLUSTER_MODEL` }}",
"cluster_model_ref": "{{ env `CLUSTER_MODEL_REF` }}",
@@ -34,6 +34,11 @@
"destination": "/root/minion.conf"
},
{
+ "type": "file",
+ "source": "files/tmp/bootstrap.saltstack.com.sh",
+ "destination": "/tmp/bootstrap.saltstack.com.sh"
+ },
+ {
"environment_vars": [
"CLUSTER_MODEL={{ user `cluster_model` }}",
"CLUSTER_MODEL_REF={{ user `cluster_model_ref` }}",
@@ -51,24 +56,11 @@
],
"type": "shell",
"expect_disconnect": "true",
- "override": {
- "openstack": {
- "scripts": [
- "scripts/base.sh",
- "scripts/network.sh",
- "scripts/salt_bootstrap.sh",
- "scripts/salt.sh"
- ]
- },
- "qemu": {
- "scripts": [
- "scripts/base.sh",
- "scripts/network.sh",
- "scripts/salt_bootstrap.sh",
- "scripts/salt.sh"
- ]
- }
- }
+ "scripts": [
+ "scripts/base.sh",
+ "scripts/network.sh",
+ "scripts/salt_bootstrap.sh"
+ ]
},
{
"environment_vars": [
@@ -76,18 +68,9 @@
],
"type": "shell",
"expect_disconnect": "true",
- "override": {
- "openstack": {
- "scripts": [
- "scripts/salt.sh"
- ]
- },
- "qemu": {
- "scripts": [
- "scripts/salt.sh"
- ]
- }
- }
+ "scripts": [
+ "scripts/salt.sh"
+ ]
},
{
"environment_vars": [
@@ -95,23 +78,12 @@
"MCP_VERSION={{ user `mcp_version` }}"
],
"type": "shell",
- "pause_before": "180s",
- "override": {
- "openstack": {
- "scripts": [
- "scripts/mirrors.sh",
- "scripts/security.sh",
- "scripts/cleanup.sh"
- ]
- },
- "qemu": {
- "scripts": [
- "scripts/mirrors.sh",
- "scripts/security.sh",
- "scripts/cleanup.sh"
- ]
- }
- }
+ "pause_before": "120s",
+ "scripts": [
+ "scripts/mirrors.sh",
+ "scripts/security.sh",
+ "scripts/cleanup.sh"
+ ]
},
{
"type": "file",
@@ -131,7 +103,7 @@
"ssh_password": "{{user `password`}}",
"image_name": "{{user `image_name`}}",
"floating_ip_pool": "{{user `floating_ip_pool`}}",
- "reuse_ips" : "true",
+ "reuse_ips": "true",
"security_groups": [
"open_all"
],