Generate a unique machine-id

The systemd machine-id needs to be unique on all network attached
devices. This change ensures that when a container comes online, a
unique machine-id is generated if one was not already present. When
the machine-id is created for the first time the container will restart
so the new ID can take effect.

More information on the machine-id can be found here:
https://www.freedesktop.org/software/systemd/man/machine-id.html

Change-Id: Ib25aeeecf1e6001e6c6b1a7d6b6d50eca7ab45fa
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
(cherry picked from commit 01fc5fa643)
This commit is contained in:
Kevin Carter 2018-02-14 09:12:50 -06:00 committed by Major Hayden
parent 365213d673
commit eabdc42c5e
1 changed files with 20 additions and 0 deletions

View File

@ -62,3 +62,23 @@
delay: 5
when:
- _lxc_container_state.stdout.find('STOPPED') != -1
- name: Generate machine-id
command: "systemd-machine-id-setup"
args:
creates: "/etc/machine-id"
notify:
- Lxc container restart
- name: Ensure the dbus directory exists
file:
path: "/var/lib/dbus"
state: "directory"
- name: Create dbus machine-id
copy:
src: "/etc/machine-id"
dest: "/var/lib/dbus/machine-id"
mode: "0444"
remote_src: "yes"
remote_user: root