Server baseline playbook
Apply a small, repeatable Linux baseline with packages, an operations group, time settings, and a running service.
A baseline playbook describes the settings every managed server should keep. Start small, use built-in modules, and make each task understandable without reading a shell script.
Create the playbook
Install the community.general collection before using its timezone module:
Commit a requirements.yml file when the project uses collections so CI and other operators install the same dependencies.
Add the template
The template task notifies the handler only when the rendered file changes. The handler then reloads Nginx once at the end of the play instead of restarting it after every task.
Handle family differences with variables
The generic package and service modules work across common Linux families, but package or service names sometimes differ. Put those differences in variables rather than duplicating the playbook.
Group hosts by family in inventory or include a variable file based on gathered facts. Test the exact versions your team supports; a shared family name does not guarantee identical repositories or defaults.
Check idempotence
Run the playbook twice against a disposable server. The first run should make the expected changes. The second should report no changes unless external state drifted.
Do not automate an SSH lockout
Manage SSH configuration in a separate, carefully tested play. Validate the candidate configuration with sshd -t, keep an existing session open, use a small serial value, and confirm a new connection before moving to the next host.