The lesson is that shockingly few people have realized is that the problem space is not, nor has it ever been, served by declarative solutions. You can describe the state you want a system to be in but there will inevitably be
procedures involved to do some of the work. It is
unavoidable. At the point people began developing templating
around their configuration, ah, templates... which themselves have imperative language constructs awkwardly (and badly,
cough Golang) embedded in them, it should have been clear to everyone with a shred of talent that it wasn't a good solution.
Declarative configuration is wholly expressible by imperative languages. The converse is not true. Declarative configuration is appropriate for declaring state (i.e., values), and not for describing procedures.
Stop using half-baked YAML crap and start using real tools.