This Ansible playbook automates the setup of an Ubuntu VM with Docker, enhanced security settings, and useful tools. It's designed to be idempotent and can be rerun for updates.
git clone https://github.com/laurnts/vmfordockercontainer.git
nano setup.yml
- Updates and upgrades system packages
- Configures system settings (sysctl)
- Sets up SSH with secure configurations
- Installs and configures Docker
- Installs Docker Compose and Python SDK for Docker
- Sets up UFW (Uncomplicated Firewall) with Docker integration
- Configures unattended upgrades
- Installs ctop for Docker container monitoring
- Generates SSH key for root user
- Ubuntu target system (tested on Ubuntu 20.04 LTS and newer)
- Ansible 2.9 or newer on the control machine
- SSH access to the target system with sudo privileges
-
Clone this repository:
git clone git@github.com:laurnts/vmfordockercontainer.git
-
Review and adjust variables in
setup.yml
if needed, particularly:project_user
ssh_public_key
security_*
variables for SSH configurationctop_version
-
Ensure you have the following files in the same directory:
setup.yml
(the main playbook)20auto-upgrades.j2
50unattended-upgrades.j2
-
Run the playbook:
sh install.sh
- Updates and upgrades all system packages
- Configures sysctl settings for better performance
- Sets up SSH with custom security configurations
- Installs and configures Docker and Docker Compose
- Sets up UFW and integrates it with Docker
- Configures unattended upgrades for automatic system updates
- Installs ctop for Docker container monitoring
- Generates an SSH key for the root user
https://gitlab.com/-/user_settings/personal_access_tokens
git clone https://<username>:<access_token>@gitlab.com/<username>/<repository>.git