Skip to content

Instantly share code, notes, and snippets.

@Znuff
Created May 8, 2017 15:22
Show Gist options
  • Select an option

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

Select an option

Save Znuff/21e421f6c6a0ed5e42d6de9a721b7dc1 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: myuuidgen is not defined
- name: save to facts
set_fact:
myuuidgen: "{{ uuidgen.stdout }}"
when: myuuidgen is not defined
- name: save to facts.d
template:
src: templates/uuid_template.j2
dest: /etc/ansible/facts.d/uuidgen
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