How do you migrate legacy shell scripts and manual runbooks into Ansible?
IntermediateProductionProject Structure and Design
Answer
Do it in slices, not as a rewrite. First wrap the script in a playbook with script: or command: and guards, so it is at least run in a controlled way. Then replace segments with modules one by one, verifying idempotency (second run changed=0) each time. Capture decisions as variables.
Start with the most frequently run or riskiest runbook, such as patching or user management. Keep the old script until the playbook has been used a few times in production.
More on Project Structure and Design
What does a production Ansible repository look like?BeginnerMonorepo or separate repos for roles? How do you decide?IntermediateHow do you structure inventories for dev, stage and prod?BeginnerHow do you prevent someone from running a playbook against production by accident?IntermediateWhat does "thin playbooks, fat roles" mean?IntermediateWhat makes a well-designed role?Intermediate