I wish there was a statically typed version of Ansible. There is Pulumi but it's mostly tied to cloud API's and not Linux system administration (setting up HAProxy, NGINX, PostgreSQL, users)
You could always make an Ansible module but then there's the overhead to managing/installing that
Data wrangling can also make idempotent playbooks a bit clunky, too. You get into this 2-4 play "run check, reshape results, conditionally run play" pattern