Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Generate generic unique machine id integer" fails on LVM root #31

Open
artur-fijalkowski opened this issue Jan 19, 2018 · 1 comment
Open

Comments

@artur-fijalkowski
Copy link

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
@jaytaylor
Copy link
Owner

Hi @artur-fijalkowski,

Thanks for taking the time to dig in and identify a possible remedy.

PRs welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants