Author SHA1 Message Date
alessandrovitali be8ad25a78 fix: arch discovery
refactor repository steps following official docker installation steps
2026-08-04 19:49:02 +02:00
alessandrovitali c7f19cd3b0 fix: simplify host arch discovery 2026-08-04 19:30:37 +02:00
alessandrovitali d1758b692e refactor: docker role 2026-08-04 19:26:33 +02:00
alessandrovitali 16e403a439 fix: use correct ssh daemon for debian 2026-07-23 17:45:06 +02:00
alessandrovitali d4587423a1 fix: galaxy.yml 2026-07-23 16:20:01 +02:00
alessandrovitali 9fbba9ffd6 fix: remove OS checks
either use the generic package module or OS-specific tasks that won't silently fail playbook runs
2026-07-09 16:17:30 +02:00
alessandrovitali 04e38f42b5 initial commit 2026-06-17 14:08:04 +02:00
8 changed files with 59 additions and 31 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
# Ansible Collection # Ansible Collection
Opinionated set of roles to configure reasonable defaults for newly provisioned Debian / Ubuntu VMs running Docker. The repository provides: Opinionated set of roles to configure reasonable defaults for newly provisioned virtual machines. The repository provides a ready-to-use Ansible Collection (`studio.ansible`) containing reusable roles.
- An Ansible Collection (`studio.ansible`) containing reusable roles. Use with ansible-galaxy's `requirements.yml`.
- A ready-to-use playbook configured by passing CLI vars `--extra-vars "ansible_host=${HOST_IP}` e.g. through CI / CD. Currently only supports Debian-based systems.
+3 -2
View File
@@ -3,8 +3,9 @@
namespace: studio namespace: studio
name: ansible name: ansible
readme: README.md readme: README.md
version: 1.0.0 version: 0.0.1
authors: authors:
- Studio Vitali - Studio Vitali
description: Studio Ansible collection containing common roles description: Studio Ansible collection containing common roles
license: MIT license:
- MIT
-5
View File
@@ -1,5 +0,0 @@
[target]
target_host ansible_host="{{ ansible_host }}"
[all:vars]
ansible_user="{{ ansible_user }}"
-11
View File
@@ -1,11 +0,0 @@
---
- name: Setup machines
hosts: all
become: true
roles:
- base
- users
- security
- docker
# - backup
-2
View File
@@ -10,7 +10,6 @@
update_cache: true update_cache: true
upgrade: dist upgrade: dist
cache_valid_time: 3600 cache_valid_time: 3600
when: ansible_facts['os_family'] == "Debian" ## only on Debian / Ubuntu systems
become: true become: true
- name: Install essential system utilities - name: Install essential system utilities
@@ -26,7 +25,6 @@
- unattended-upgrades - unattended-upgrades
state: present state: present
update_cache: true update_cache: true
when: ansible_facts['os_family'] == "Debian"
become: true become: true
# #
# - name: Enable unattended-upgrades # - name: Enable unattended-upgrades
+52 -5
View File
@@ -1,18 +1,58 @@
--- ---
- name: Install necessary Docker packages - name: Install Docker prerequisites
ansible.builtin.apt: ansible.builtin.apt:
name: name:
- docker.io - ca-certificates
- docker-compose - curl
state: present state: present
when: ansible_facts['os_family'] == "Debian" ## Debian / Ubuntu update_cache: true
become: true become: true
- name: Ensure Docker service is running - name: Ensure APT keyrings directory exists
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: "0755"
become: true
- name: Download Docker official GPG key
ansible.builtin.get_url:
url: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg"
dest: /etc/apt/keyrings/docker.asc
mode: "0644"
become: true
- name: Get system architecture
ansible.builtin.command: dpkg --print-architecture
register: dpkg_architecture
changed_when: false
become: true
- name: Add Docker official APT repository
ansible.builtin.apt_repository:
repo: "deb [arch={{ dpkg_architecture.stdout }} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
state: present
filename: docker
update_cache: yes
become: true
- name: Install modern Docker CE packages
ansible.builtin.apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: present
become: true
- name: Ensure Docker services are running and enabled
ansible.builtin.service: ansible.builtin.service:
name: docker name: docker
state: started state: started
enabled: true enabled: true
become: true
- name: Create docker user for container execution - name: Create docker user for container execution
ansible.builtin.user: ansible.builtin.user:
@@ -25,6 +65,13 @@
create_home: false create_home: false
become: true become: true
- name: Add deployment user to docker group
ansible.builtin.user:
name: deployment
groups: docker
append: true
become: true
- name: Create target for docker compose - name: Create target for docker compose
ansible.builtin.file: ansible.builtin.file:
path: /opt/docker path: /opt/docker
+1 -1
View File
@@ -1,5 +1,5 @@
--- ---
- name: Restart sshd - name: Restart sshd
ansible.builtin.service: ansible.builtin.service:
name: sshd name: ssh
state: restarted state: restarted
-2
View File
@@ -24,7 +24,6 @@
name: name:
- fail2ban - fail2ban
state: present state: present
when: ansible_facts['os_family'] == "Debian"
become: true become: true
- name: Start fail2ban - name: Start fail2ban
@@ -32,4 +31,3 @@
name: fail2ban name: fail2ban
state: started state: started
enabled: yes enabled: yes
when: ansible_facts['os_family'] == "Debian"