How do you bootstrap brand new servers?
IntermediateProductionProject Structure and Design
Answer
A dedicated bootstrap.yml play, run once with the initial credentials (root or the cloud default user), that does only what the normal runs depend on:
- ensure Python (using
rawif needed) - create the
ansibleautomation user with SSH key and a sudoers drop-in - disable password SSH logins, set hostname, time sync, base packages
After it, every later run uses the automation user. Keeping bootstrap separate means normal playbooks never need a root password or special connection settings.
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