Author SHA1 Message Date
alessandrovitali 63b5d37883 fix: directory traversal permission 2026-08-19 19:50:22 +02:00
alessandrovitali 5308e5312d Merge branch 'main' into feat/coolify 2026-08-19 19:43:33 +02:00
alessandrovitali cba507b077 fix: user creation 2026-08-19 19:42:55 +02:00
alessandrovitali 4fdab81b9c feat: pre-seed admin user 2026-08-18 17:52:12 +02:00
alessandrovitali 472f04b98c feat: add coolify installation role 2026-08-17 17:52:01 +02:00
alessandrovitali 0974c13751 chore: add conditional to user configuration 2026-08-17 17:43:05 +02:00
alessandrovitali 6e4bd8eb92 feat: group tasks into logical blocks 2026-08-17 14:18:24 +02:00
alessandrovitali d1714e0fa4 feat: add conditionals to user creation 2026-08-17 00:08:39 +02:00
alessandrovitali 80a1ca0632 chore 2026-08-17 00:05:30 +02:00
alessandrovitali b031c08b66 fix: SSH config validation
remove validation step instead of running pointless validation on static template
2026-08-06 12:39:58 +02:00
alessandrovitali 1370cd2b8a refactor: user creation (#7)
parameterize sysadmin username
2026-08-05 16:24:11 +02:00
alessandrovitali 7c9d7050e9 fix: refresh apt cache before installing docker packages 2026-08-05 00:29:12 +02:00
alessandrovitali bdd1c07d76 refactor: use modern deb822 repository module 2026-08-04 22:12:05 +02:00
alessandrovitali f59952df2b fix: update outdated ansible_facts notation 2026-08-04 21:59:47 +02:00
alessandrovitali f9e26303d0 fix: docker container execution user permissions
do not add appuser to docker group (highly insecure) / hardcode GID:UID
2026-08-04 20:30:17 +02:00
alessandrovitali b6d861a8d4 fix: add runtime.yml with minimum supported ansible version 2026-08-04 20:03:01 +02:00
alessandrovitali ff9d9adc96 fix: arch discovery
refactor repository steps following official docker installation steps
2026-08-04 19:53:51 +02:00
alessandrovitali 960379bd16 refactor: docker role (#6)
use official docker images instead of outdated apt packages following official docker installation docs
2026-08-04 19:34:56 +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
10 changed files with 192 additions and 100 deletions
+3 -1
View File
@@ -1,3 +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 a ready-to-use Ansible Collection (`studio.ansible`) containing reusable roles. 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.
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
+2
View File
@@ -0,0 +1,2 @@
---
requires_ansible: ">=2.15.0"
-4
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
@@ -37,5 +35,3 @@
# APT::Periodic::Unattended-Upgrade "1"; # APT::Periodic::Unattended-Upgrade "1";
# mode: "0644" # mode: "0644"
# when: ansible_facts['os_family'] == "Debian" # when: ansible_facts['os_family'] == "Debian"
## SCHEDULE REBOOTS 4 kernel upgrades: with cron, unattended-upgrades or action workflows?
+16
View File
@@ -0,0 +1,16 @@
---
coolify_installer_url: "https://cdn.coollabs.io/coolify/install.sh"
coolify_installer_dest: "/tmp/coolify-install.sh"
coolify_data_dir: "/data/coolify"
coolify_compose_file: "{{ coolify_data_dir }}/source/docker-compose.yml"
## Pin to a release or leave empty for latest
coolify_version: ""
## Set to false to manage upgrades manually
coolify_autoupdate: true
## All 3 needed for sucessful user creation
coolify_root_username: ""
coolify_root_user_email: ""
coolify_root_user_password: ""
+30
View File
@@ -0,0 +1,30 @@
---
- name: Check if Coolify is already installed
become: true
ansible.builtin.stat:
path: "{{ coolify_compose_file }}"
register: coolify_installed
- name: Download Coolify installer
ansible.builtin.get_url:
url: "{{ coolify_installer_url }}"
dest: "{{ coolify_installer_dest }}"
mode: "0755"
when: not coolify_installed.stat.exists
- name: Run Coolify installer
become: true
ansible.builtin.command:
argv:
- "{{ coolify_installer_dest }}"
- "{{ coolify_version }}"
environment:
AUTOUPDATE: "{{ coolify_autoupdate | bool | ternary('true', 'false') }}"
ROOT_USERNAME: "{{ coolify_root_username }}"
ROOT_USER_EMAIL: "{{ coolify_root_user_email }}"
ROOT_USER_PASSWORD: "{{ coolify_root_user_password }}"
when: not coolify_installed.stat.exists
changed_when: true
async: 1800
poll: 15
no_log: true
+69 -28
View File
@@ -1,35 +1,76 @@
--- ---
- name: Install necessary Docker packages - name: Install Docker
ansible.builtin.apt:
name:
- docker.io
- docker-compose
state: present
when: ansible_facts['os_family'] == "Debian" ## Debian / Ubuntu
become: true become: true
block:
- name: Install Docker prerequisites
ansible.builtin.apt:
name:
- ca-certificates
- curl
- python3-debian ## needed for the deb822 module
state: present
update_cache: true
- name: Ensure Docker service is running - name: Add Docker official APT repository (DEB822 format)
ansible.builtin.service: ansible.builtin.deb822_repository:
name: docker name: docker
state: started types: deb
enabled: true uris: "https://download.docker.com/linux/{{ ansible_facts['distribution'] | lower }}"
suites: "{{ ansible_facts['distribution_release'] }}"
components: stable
signed_by: "https://download.docker.com/linux/{{ ansible_facts['distribution'] | lower }}/gpg"
state: present
- name: Create docker user for container execution - name: Install Docker CE packages
ansible.builtin.user: ansible.builtin.apt:
name: docker name:
state: present - docker-ce
system: true - docker-ce-cli
shell: /usr/sbin/nologin - containerd.io
groups: docker - docker-buildx-plugin
append: true - docker-compose-plugin
create_home: false state: present
update_cache: true
- name: Ensure Docker service is running and enabled
ansible.builtin.service:
name: docker
state: started
enabled: true
- name: Configure deployment user for Docker
when: deployment_public_ssh_key is defined
become: true become: true
block:
- name: Add deployment user to docker group
ansible.builtin.user:
name: deployment
groups: docker
append: 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
state: directory state: directory
owner: deployment owner: deployment
group: deployment group: deployment
mode: "0755" mode: "0755"
- name: Create app user for secure container execution
become: true become: true
block:
- name: Create appuser group
ansible.builtin.group:
name: appuser
state: present
gid: 9999
- name: Create appuser
ansible.builtin.user:
name: appuser
state: present
uid: 9999
group: appuser
system: true
shell: /usr/sbin/nologin
create_home: false
+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
+30 -30
View File
@@ -1,35 +1,35 @@
--- ---
- name: Create SSH drop-in directory - name: Harden SSH configuration
ansible.builtin.file:
path: /etc/ssh/sshd_config.d
state: directory
owner: root
group: root
mode: "0755"
become: true become: true
block:
- name: Create SSH drop-in directory
ansible.builtin.file:
path: /etc/ssh/sshd_config.d
state: directory
owner: root
group: root
mode: "0755"
- name: Harden SSH configuration with drop-in template - name: Harden SSH configuration with drop-in template
ansible.builtin.template: ansible.builtin.template:
src: sshd.conf.j2 src: sshd.conf.j2
dest: /etc/ssh/sshd_config.d/sshd.conf dest: /etc/ssh/sshd_config.d/sshd.conf
owner: root owner: root
group: root group: root
mode: "0644" mode: "0644"
validate: "sshd -t -f %s" notify: Restart sshd
notify: Restart sshd
- name: Enable fail2ban
become: true become: true
block:
- name: Install fail2ban
ansible.builtin.apt:
name:
- fail2ban
state: present
- name: Install fail2ban - name: Start fail2ban
ansible.builtin.apt: ansible.builtin.service:
name: name: fail2ban
- fail2ban state: started
state: present enabled: yes
when: ansible_facts['os_family'] == "Debian"
become: true
- name: Start fail2ban
ansible.builtin.service:
name: fail2ban
state: started
enabled: yes
when: ansible_facts['os_family'] == "Debian"
+38 -34
View File
@@ -1,38 +1,42 @@
--- ---
# - name: Create primary admin user - name: Set up primary sysadmin user
# ansible.builtin.user: when: sysadmin_public_ssh_key is defined
# name: sysadmin
# groups: sudo
# append: yes
# shell: /bin/bash
# create_home: yes
# become: true
# - name: Add SSH public key for sysadmin
# ansible.posix.authorized_key:
# user: sysadmin
# state: present
# key: "{{ sysadmin_public_ssh_key }}"
# become: true
# - name: Allow passwordless sudo to sysadmin user
# ansible.builtin.copy:
# dest: /etc/sudoers.d/sysadmin
# content: "sysadmin ALL=(ALL) NOPASSWD: ALL"
# mode: "0440"
# validate: /usr/sbin/visudo -cf %s
# become: true
- name: Create deployment user for CI/CD
ansible.builtin.user:
name: deployment
shell: /bin/bash
create_home: yes
become: true become: true
block:
- name: Create sysadmin user
ansible.builtin.user:
name: "{{ sysadmin_user }}"
groups: sudo
append: yes
shell: /bin/bash
create_home: yes
- name: Add SSH public key for deployment user - name: Add SSH public key
ansible.posix.authorized_key: ansible.posix.authorized_key:
user: deployment user: "{{ sysadmin_user }}"
state: present state: present
key: "{{ deployment_public_ssh_key }}" key: "{{ sysadmin_public_ssh_key }}"
- name: Allow passwordless sudo
ansible.builtin.copy:
dest: /etc/sudoers.d/sudo-nopasswd
content: "%sudo ALL=(ALL) NOPASSWD: ALL"
mode: "0440"
validate: /usr/sbin/visudo -cf %s
- name: Set up deployment user for CI/CD
when: deployment_public_ssh_key is defined
become: true become: true
block:
- name: Create deployment user
ansible.builtin.user:
name: deployment
shell: /bin/bash
create_home: yes
- name: Add SSH public key
ansible.posix.authorized_key:
user: deployment
state: present
key: "{{ deployment_public_ssh_key }}"