Properly handle machine-ids

/etc/machind-id needed to be removed from the image for cloud-init to
generate it, no simply blank.

/var/lib/dbus/machine-id needed to be symlinked to /etc/machine-id,
otherwise dbus was storing its ID into the generic image. Some NIC
drivers use this for generating unique MAC addresses, so duplicating
these IDs could cause duplicate MAC addressing.

Also correct spelling of "finalize".

Change-Id: Iaabd0730c4e6d2ae47e5ff1c25adc1b6eb65533b
This commit is contained in:
Anderson, Craig (ca846m) 2021-04-07 11:58:05 -07:00
parent 053c992218
commit 7a99dea948
5 changed files with 28 additions and 13 deletions
image-builder/assets/playbooks/roles/osconfig/tasks

@ -5,7 +5,7 @@
owner: root
group: root
mode: '0644'
- name: "Finalise | Reset MOTD"
- name: "Finalize | Reset MOTD"
file:
state: "{{ item }}"
path: "/etc/update-motd.d/"
@ -15,7 +15,7 @@
loop:
- absent
- directory
- name: "Finalise | Remove MOTD News config"
- name: "Finalize | Remove MOTD News config"
file:
state: "absent"
path: "/etc/default/motd-news"

@ -1,5 +0,0 @@
- name: "Finalise | Removing .pyc files"
shell:
cmd: |
find "/usr/" "/var/" \( -name "*.pyc" -o -name "__pycache__" \) -delete
apt -y clean

@ -0,0 +1,24 @@
- name: "Finalize | Removing .pyc files"
shell:
cmd: |
find "/usr/" "/var/" \( -name "*.pyc" -o -name "__pycache__" \) -delete
apt -y clean
- name: "Finalize | Ensure no /etc/machine-id is delivered in image"
file:
path: /etc/machine-id
state: absent
- name: "Finalize | remove /var/lib/dbus/machine-id"
file:
path: /var/lib/dbus/machine-id
state: absent
- name: "Finalize | symlink /var/lib/dbus/machine-id to /etc/machine-id"
file:
src: /etc/machine-id
dest: /var/lib/dbus/machine-id
owner: root
group: root
state: link
force: yes

@ -61,5 +61,5 @@
include_tasks: file-permissions.yaml
# Context-independent cleanup tasks
- name: "finalise rootfs"
include_tasks: finalise-rootfs.yaml
- name: "finalize rootfs"
include_tasks: finalize-rootfs.yaml

@ -1,7 +1,3 @@
- name: "Systemd | Remove machine id"
copy:
content: ""
dest: "/etc/machine-id"
- name: "Systemd | Link systemd to /sbin/init"
file:
src: /bin/systemd