Created
May 8, 2017 16:30
-
-
Save Znuff/feeaa7459df445b306de28a7d3dcd05e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node# cat myuuid.fact | |
"e48aeb68-ebb7-4e53-971d-0b4b59d242c4" | |
--- | |
master# ansible cloudini-hosts -m setup -a "filter=ansible_local" | |
bu-x40092.appnor.net | SUCCESS => { | |
"ansible_facts": { | |
"ansible_local": { | |
"myuuid": "e48aeb68-ebb7-4e53-971d-0b4b59d242c4" | |
} | |
}, | |
"changed": false | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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: myuuid is not defined | |
- name: save to facts | |
set_fact: | |
myuuid: "{{ uuidgen.stdout }}" | |
when: myuuid is not defined | |
- name: save to facts.d | |
template: | |
src: templates/uuid_template.j2 | |
dest: /etc/ansible/facts.d/myuuid.fact | |
force: False | |
- name: re-read facts | |
setup: filter=ansible_local | |
- name: configure libvirtd.conf with myuuid | |
template: | |
src: templates/libvirtd.conf.j2 | |
dest: /etc/libvirt/libvirtd.conf | |
force: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ myuuid | to_nice_json }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment