From c95399a43ac880e23245533a9824b87c333fbeb5 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Mon, 13 Mar 2017 14:35:13 -0600 Subject: [PATCH] Add remove-machine-id element Leaving /etc/machine-id on the image means that all nodes booted from this image will have the same machine-id, which is wrong. A new machine-id will be generated during the first boot. This element can be used to purge the machine-id from the image. Change-Id: Idd848cd307c179afa557618f44db34b2fb57d937 Related-Bug: #1672461 Co-Authored-By: Dmitry Tantsur (cherry picked from commit c7c1da513eb003c1a60822b236bde08ace7ea083) --- elements/remove-machine-id/README.md | 9 +++++++++ .../post-install.d/70-remove-machine-id | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100644 elements/remove-machine-id/README.md create mode 100755 elements/remove-machine-id/post-install.d/70-remove-machine-id diff --git a/elements/remove-machine-id/README.md b/elements/remove-machine-id/README.md new file mode 100644 index 00000000..41d4e18e --- /dev/null +++ b/elements/remove-machine-id/README.md @@ -0,0 +1,9 @@ +================= +remove-machine-id +================= + +Removes the hardcoded ``/etc/machine-id`` from the resulting image, so that it +is regenerated during the next boot. + +Leaving the file means that e.g. all instances will have the same machine-id. + diff --git a/elements/remove-machine-id/post-install.d/70-remove-machine-id b/elements/remove-machine-id/post-install.d/70-remove-machine-id new file mode 100755 index 00000000..463da18b --- /dev/null +++ b/elements/remove-machine-id/post-install.d/70-remove-machine-id @@ -0,0 +1,8 @@ +#!/bin/bash + +set -eu +set -o pipefail + +# In order to make sure not all nodes have the same machine id, we need to +# remove it from the image and it should be generated on boot. LP#1672461 +rm -f /etc/machine-id