Right now I have a role/common that does a lot of “discovery” about the machine.
It does things like looks at the hostname and sets “machine_env” to dev/qa/prod.
It also does a lot of discovery to see what applications are installed and/or running on the box and then sets facts like “systemd_nginx_enabled: true” if nginx is enabled in systemd.
This all works fine, but there are like 30 checks that I am doing (for all the different apps etc) and it seems to add like 20m+ to the ansible run when I have a lot of machines.
It seems like it would be WAY more efficient to write a script that would quickly do the machine discovery and then output something like:
machine_env: prod
systemd_nginx_enabled: true
systemd_mongodb_enabled: false
systemd_redis_enabled: false
systemd_consul_enabled: true
systemd_apache_enabled: false
systemd_zookeeper_enabled: false
…
where the output could be iterated over and the respective facts are then set.
Is this possible? I am thinking it is some incantation with “map” and “list”, but I don’t know exactly how to do it.
Thanks!