“But half of the steps in your scripts fail immediately because they were already applied to your system.”
Your setup script dies halfway. You fix the problem and run it again, and now it dies on the steps that already worked. mkdir -p, ln -sf and a grep before every append solve most of it. Ansible charges you a YAML habit for the same idea.