ansible-kafka
ansible-kafka copied to clipboard
"Generate generic unique machine id integer" fails on LVM root
Problem is caused by fact that tr on empty string is ok (command return 0). So tr -d '-' || echo '0' behaves different then expected.
Proper order of commands below
- name: "Generate generic unique machine id integer"
NB: This uses a combination of root partition UUID + network interface MAC address.
shell: ( (test -r /etc/fstab && ls -l /dev/disk/by-uuid/ | grep $(mount | grep ' / ' | cut -d' ' -f1 | cut -d'/' -f3) | grep --ignore-case --only-matching --extended-regexp --max 1 '[0-9a-f]{3,}[0-9a-f-]+' || echo '0') | tr -d '-' ; ifconfig | grep --ignore-case --only-matching --extended-regexp '([0-9a-f]{2}:){5}[0-9a-f]{2}' | tr -d ':' | tr -d '\n') | python -c 'import sys; x, y = sys.stdin.read().split(chr(10))[0:2]; x = int(x, 16); y = int(y, 16); sys.stdout.write((str(x + y)[-9:])); sys.exit(1 if x == 0 and y == 0 else 0)' register: machineidinteger changed_when: False when: kafka_generate_broker_id | bool tags:- kafka-cfg
Hi @artur-fijalkowski,
Thanks for taking the time to dig in and identify a possible remedy.
PRs welcome :)