So far the play works in the sense that it does what it is supposed to do. It downloads the fonts, extracts the archives, does a little magic by patching a buggy font and splitting another font that comes in the wrong format. It installs the fonts in a place that makes sense and updates the font cache.
Now I’m relatively new to Ansible, and one thing I wonder about now is how to make this idempotent. So I thought I’d rather ask the Ansible gurus here for the odd suggestion.
This looks nice! Ansible really is a great tool with many uses!
There are a few ways to do add idempotency. One way would be to register the output of fc-list and use a when statement to search for CAMBRIA.TTF and CAMBRIA-MATH.TTF.
So kinda like this:
tasks:
- name: Create variable from command
command: "echo Hello"
register: command_output
- debug: msg="{{command_output.stdout}}"
block:
- task: do all the installing process here
when: '"cambria.tt" not in command.stdout' and '"cambra-math.tt" not in command.stdout'
Another way is to put more functionality into the handler and call it when things are changed…aka they needed changing cause stuff is not installed…
I’m sure there are other ways as well but hopefully this will assist you and get you headed in a good direction!
I experimented some more and found a solution that sticks to the KISS principle. The trick here is to keep downloaded files and archives in a place that makes sense like /var/tmp/download, since /var/tmp is a temporary directory that is supposed to keep its contents after a reboot. Now the script is 100% idempotent and more straightforward:
We gathered MS fonts and packed them into a RPM. We had local repo where that package (and many others) were. We even had some of our configs in RPM packages, installed within kickstart.