Ansible configuration to initialize debian server
Find a file
2026-03-05 12:05:32 +01:00
playbooks Forgejo config deleted 2026-03-05 12:01:06 +01:00
.gitignore gitignore updated 2025-11-06 16:12:42 +01:00
ansible-navigator.yml WIP Change ssh port 2025-08-18 11:44:17 +02:00
execution-environment.yml Forgejo added 2025-11-06 16:48:58 +01:00
forgejo-vars.yml Forgejo playbook created 2025-11-26 14:28:14 +01:00
LICENSE License added 2026-03-05 12:05:32 +01:00
nginx-https-vars.yml Forgejo playbook created 2025-11-26 14:28:14 +01:00
README.MD Readme updated 2026-03-05 11:57:49 +01:00
vars.yml VPS initial user variable added 2026-03-05 11:42:33 +01:00

Ansible Debian Bootstrap

Here is my ansible configuration which I use to initialize debian vps. Bootstrap playbook is used first ton configure the server, while Site playbook is used for maintenance and server evolution.

I could have use a bash script but..

Ansible idempotency makes it easy to iterate over modifications without caring about what's already in place. This repository can also be used as a base config that can evolve with more services depending on server needs. Finally, it can handle bootstrapping multiple servers at the same time.

How to use it

To use it, you must complete your variable secrets in vault represented in vars.yml with ansible-vault:

ansible-vault create vault.yml

Then, run :

ansible-navigator run playbooks/[PLAYBOOKNAME].yml --vault-password-file [PASSWORDFILENAME].txt

Bootstrap playbook

Bootstrap playbook is used to setup at first launch a debian server with :

  • New user
  • No root login
  • A custom ssh port
  • Fail2ban basic setup
  • UFW as firewall
  • no password authentification, only ssh key.

To use the bootstrap playbook:

  • Write your inventory.ini with your ip and root login prodided by your hosting service.
  • Make a vault file with your secret variables corresponding to those in vars.yml
  • Launch your playbook mentionning your var file and secret
  • If successful, rewrite your inventory.ini with the good ansible_user variable.

Site playbook

Site playbook is used to maintain the server.