day01 Updates
* Day01:
- remove reclass data from node
- Force maas in unconfigured state
- if you will try to run maas - it will automatically start
import processes = > which fail.
- If you will try to wrap and disable imports (formula allow to do it)
=> maas_config step will never pass.
* Misc:
- for to use freezed bootstrap.saltstack.com.sh
- add qemu-packer disk_compression true - require packer 1.10 +
- decrease mirror image size to 100gb
- apt_preserve_sources_list - force cloud-init to not re-create sources.list
Change-Id: If7c731284f3fd6ca21fe253c05c8ab78213cf9c5
diff --git a/day01-image/files/etc/cloud/cloud.cfg b/day01-image/files/etc/cloud/cloud.cfg
index c3cbb03..94b618d 100644
--- a/day01-image/files/etc/cloud/cloud.cfg
+++ b/day01-image/files/etc/cloud/cloud.cfg
@@ -4,6 +4,7 @@
# This will cause the set+update hostname module to not operate (if true)
preserve_hostname: false
+apt_preserve_sources_list: true
# Better let managing of /etc/hosts on salt and others
# manage_etc_hosts: localhost
diff --git a/day01-image/run.example.sh b/day01-image/run.example.sh
index e9ada77..aeee71e 100755
--- a/day01-image/run.example.sh
+++ b/day01-image/run.example.sh
@@ -11,7 +11,7 @@
# External script sources:
# http/bootstrap.saltstack.com.sh https://github.com/saltstack/salt-bootstrap
#
-
+export IMAGE_NAME="cfg01"
#
export CLUSTER_MODEL=https://github.com/Mirantis/mcp-drivetrain-model.git
export CLUSTER_MODEL_REF=master
diff --git a/day01-image/scripts/cleanup.sh b/day01-image/scripts/cleanup.sh
index 0968dd5..2b5ccbc 100644
--- a/day01-image/scripts/cleanup.sh
+++ b/day01-image/scripts/cleanup.sh
@@ -1,18 +1,23 @@
#!/bin/bash -xe
-chmod +x /var/lib/maas/.maas_login.sh
apt-get purge salt-formula-* -y
apt-get -y autoremove --purge
apt-get -y clean
+rm -rf /var/lib/ntp/ntp.conf.dhcp || true
rm -rf /var/lib/apt/lists/*
-rm -rf /etc/apt/sources.list.d/*
-echo "" > /etc/apt/sources.list
+rm -rv /etc/apt/sources.list.d/* || true
+echo > /etc/apt/sources.list || true
+rm -vf /usr/sbin/policy-rc.d || true
-rm -rf /srv/salt/reclass/classes/*
-rm /srv/salt/reclass/nodes/cfg01.mcp-day01.local.yml
-mkdir -p /srv/salt/reclass/classes/service
-rm -f /usr/sbin/policy-rc.d || true
+echo "cleaning up reclass"
+rm -rf /srv/salt/reclass || true
+rm -rf /srv/salt/scripts || true
+rm -rf /usr/share/salt-formulas/env || true
+#
+mkdir -p /srv/salt/reclass/
+mkdir -p /usr/share/salt-formulas/reclass/service/
+mkdir -p /usr/share/salt-formulas/env/
echo "cleaning up hostname"
sed -i "/.*ubuntu.*/d" /etc/hosts
@@ -35,6 +40,13 @@
echo "cleaning up resolvconf"
sed -i '/172\.18\.208\.44/d' /etc/resolvconf/resolv.conf.d/base
-# Clear\drop cache's
-sync
+# stop and disable services, for healthy zerodisk
+# They should be enabled after cfg01 init
+stop_services="postgresql.service salt-api salt-master salt-minion jenkins maas-rackd.service maas-regiond.service"
+for s in ${stop_services} ; do
+ systemctl stop ${s} || true
+ systemctl disable ${s} || true
+done
+
echo 3 > /proc/sys/vm/drop_caches
+sync
diff --git a/day01-image/scripts/salt.sh b/day01-image/scripts/salt.sh
index 16bafc8..78cdd79 100644
--- a/day01-image/scripts/salt.sh
+++ b/day01-image/scripts/salt.sh
@@ -2,28 +2,36 @@
FORMULA_VERSION=${FORMULA_VERSION:-2018.3.1}
APT_MIRANTIS_SALT_REPO=${APT_MIRANTIS_SALT_REPO:-"http://apt.mirantis.com/xenial/ $FORMULA_VERSION salt"}
+SALT_OPTS="-t 10 --retcode-passthrough --no-color"
-salt-call -t 5 --retcode-passthrough reclass.validate_pillar
+salt-call ${SALT_OPTS} reclass.validate_pillar
echo "deb [arch=amd64] ${APT_MIRANTIS_SALT_REPO}" > /etc/apt/sources.list.d/mcp_salt.list
apt-get update
apt-get install salt-formula* -y
+
salt-call saltutil.refresh_pillar
salt-call saltutil.sync_all
-salt-call -t 5 --retcode-passthrough --no-color state.sls salt
-salt-call -t 5 --retcode-passthrough --no-color state.sls linux.system.repo,linux.system.package,linux.system.user,linux.system.directory,linux.system.config
-salt-call -t 5 --retcode-passthrough --no-color state.sls linux.network
-salt-call -t 5 --retcode-passthrough --no-color state.sls openssh
-salt-call -t 5 --retcode-passthrough --no-color state.sls git.server
-salt-call -t 5 --retcode-passthrough --no-color state.sls postgresql
-salt-call -t 5 --no-color state.sls maas
+salt-call ${SALT_OPTS} state.sls salt
+salt-call ${SALT_OPTS} state.sls linux.system.repo,linux.system.package,linux.system.user,linux.system.directory,linux.system.config
+salt-call ${SALT_OPTS} state.sls linux.network
+salt-call ${SALT_OPTS} state.sls openssh
+salt-call ${SALT_OPTS} state.sls git.server
+salt-call ${SALT_OPTS} state.sls postgresql
+# install only MAAS packages, don't configure anything.
+# Configuration will be processed during cfg01 initialization.
+# Those step, required to have clean MAAS configuration - w\o auto import and etc.
+salt-call ${SALT_OPTS} state.sls_id maas_cluster_packages maas
+salt-call ${SALT_OPTS} state.sls_id maas_region_packages maas
+
# linux.system.file only for backwards compatibility of jenkins - mcp-common-scripts
-salt-call -t 5 --retcode-passthrough --no-color state.sls jenkins.master,linux.system.file
+salt-call ${SALT_OPTS} state.sls jenkins.master,linux.system.file
sleep 60
salt-call -t 5 --no-color state.sls jenkins.client.plugin
systemctl restart jenkins
sleep 60
# Jenkins Mirantis theme
+# FIXME move those into cluster model
git clone https://github.com/Mirantis/docker-jenkins.git
cp -r docker-jenkins/theme /var/lib/jenkins/userContent
chown -R jenkins:jenkins /var/lib/jenkins/userContent/*
@@ -34,5 +42,5 @@
salt-call -t 5 --no-color state.sls jenkins.client
systemctl restart jenkins
sleep 60
-salt-call -t 5 --retcode-passthrough --no-color state.sls jenkins.client
+salt-call ${SALT_OPTS} state.sls jenkins.client
diff --git a/day01-image/template.json b/day01-image/template.json
index 6cc5ce5..4db83f2 100644
--- a/day01-image/template.json
+++ b/day01-image/template.json
@@ -52,7 +52,8 @@
"GIT_SALT_FORMULAS_SCRIPTS={{ user `git_salt_formulas_scripts` }}",
"APT_REPOSITORY={{ user `apt_repository` }}",
"APT_REPOSITORY_GPG={{ user `apt_repository_gpg` }}",
- "APT_MIRANTIS_SALT_REPO={{ user `apt_mirantis_salt_repo` }}"
+ "APT_MIRANTIS_SALT_REPO={{ user `apt_mirantis_salt_repo` }}",
+ "PACKER_OFFLINE_BUILD=true"
],
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}",
@@ -119,6 +120,7 @@
"vm_name": "{{ user `image_name` }}-{{ isotime \"200601021504\" }}",
"output_directory": "images/{{ user `image_name` }}-qemu-{{ isotime \"200601021504\" }}",
"format": "qcow2",
+ "disk_compression": true,
"iso_checksum": "566efef1d6f12e7d3a994c2405bdb642",
"iso_checksum_type": "md5",
"iso_url": "http://cloud-images.ubuntu.com/releases/xenial/release-20180306/ubuntu-16.04-server-cloudimg-amd64-disk1.img",
@@ -128,6 +130,8 @@
"headless": true,
"ssh_username": "{{user `user`}}",
"ssh_password": "{{user `password`}}",
+ "ssh_host_port_min": 7000,
+ "ssh_host_port_max": 7050,
"shutdown_command": "shutdown -P now",
"boot_wait": "2s",
"ssh_wait_timeout": "360s"