- name: "Install packages: uuid-runtime"
  package:
    name: uuid-runtime
    state: present

- name: Does /etc/iiab/uuid exist?
  stat:
    path: /etc/iiab/uuid
  register: uuid_file

- name: If not, run 'uuidgen' to create a uuid, in register uuid_response
  command: uuidgen
  register: uuid_response
  when: not uuid_file.stat.exists

- name: Save it to /etc/iiab/uuid
  shell: echo {{ uuid_response.stdout_lines[0] }} > /etc/iiab/uuid
  when: not uuid_file.stat.exists

- name: Load /etc/iiab/uuid, into register stored_uuid
  command: cat /etc/iiab/uuid
  register: stored_uuid

- name: Store it in Ansible variable 'uuid'
  set_fact:
    uuid: "{{ stored_uuid.stdout_lines[0] }}"
