Author SHA1 Message Date
alessandrovitali ce9b5d58b4 feat: add standalone playbook 2026-06-17 14:09:19 +02:00
alessandrovitali 2c29ea2780 initial commit 2026-06-17 14:09:10 +02:00
8 changed files with 31 additions and 59 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
# Ansible Collection
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.
Opinionated set of roles to configure reasonable defaults for newly provisioned Debian / Ubuntu VMs running Docker. The repository provides:
- 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.
+2 -3
View File
@@ -3,9 +3,8 @@
namespace: studio
name: ansible
readme: README.md
version: 0.0.1
version: 1.0.0
authors:
- Studio Vitali
description: Studio Ansible collection containing common roles
license:
- MIT
license: MIT
+5
View File
@@ -0,0 +1,5 @@
[target]
target_host ansible_host="{{ ansible_host }}"
[all:vars]
ansible_user="{{ ansible_user }}"
+11
View File
@@ -0,0 +1,11 @@
---
- name: Setup machines
hosts: all
become: true
roles:
- base
- users
- security
- docker
# - backup
+2
View File
@@ -10,6 +10,7 @@
update_cache: true
upgrade: dist
cache_valid_time: 3600
when: ansible_facts['os_family'] == "Debian" ## only on Debian / Ubuntu systems
become: true
- name: Install essential system utilities
@@ -25,6 +26,7 @@
- unattended-upgrades
state: present
update_cache: true
when: ansible_facts['os_family'] == "Debian"
become: true
#
# - name: Enable unattended-upgrades
+5 -52
View File
@@ -1,58 +1,18 @@
---
- name: Install Docker prerequisites
- name: Install necessary Docker packages
ansible.builtin.apt:
name:
- ca-certificates
- curl
- docker.io
- docker-compose
state: present
update_cache: true
when: ansible_facts['os_family'] == "Debian" ## Debian / Ubuntu
become: true
- 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
- name: Ensure Docker service is running
ansible.builtin.service:
name: docker
state: started
enabled: true
become: true
- name: Create docker user for container execution
ansible.builtin.user:
@@ -65,13 +25,6 @@
create_home: false
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
ansible.builtin.file:
path: /opt/docker
+1 -1
View File
@@ -1,5 +1,5 @@
---
- name: Restart sshd
ansible.builtin.service:
name: ssh
name: sshd
state: restarted
+2
View File
@@ -24,6 +24,7 @@
name:
- fail2ban
state: present
when: ansible_facts['os_family'] == "Debian"
become: true
- name: Start fail2ban
@@ -31,3 +32,4 @@
name: fail2ban
state: started
enabled: yes
when: ansible_facts['os_family'] == "Debian"