Skip to content

Instantly share code, notes, and snippets.

@Znuff
Last active May 8, 2017 15:54
Show Gist options
  • Select an option

  • Save Znuff/e960d12fec30ccc758c79543bd6c1bcb to your computer and use it in GitHub Desktop.

Select an option

Save Znuff/e960d12fec30ccc758c79543bd6c1bcb to your computer and use it in GitHub Desktop.
---
- name: uuidgen for libvirtd config
hosts: cloudini-hosts
gather_facts: True
# facts.d will automatically be read, so that myuuidgen will be populated if it is defined
tasks:
- name: create directory for ansible custom facts
file: state=directory recurse=yes path=/etc/ansible/facts.d
- name: run uuidgen if necessary
shell: uuidgen
register: uuidgen
when: uuid is not defined
- name: save to facts
set_fact:
uuid: "{{ uuidgen.stdout }}"
when: uuid is not defined
- name: save to facts.d
template:
src: templates/uuid_template.j2
dest: /etc/ansible/facts.d/uuid
force: False
- name: re-read facts
setup: filter=ansible_local
- name: configure libvirtd.conf with uuid
template:
src: templates/libvirtd.conf.j2
dest: /etc/libvirt/libvirtd.conf
force: True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment