Compare commits

..

No commits in common. "a9623b63f13da9d711a5e628a2bff657a59c338a" and "e4b0ed2fc2c8949aeab4fe3823cc79191bfadcdb" have entirely different histories.

19 changed files with 50 additions and 185 deletions

1
.gitignore vendored
View File

@ -1,3 +1,2 @@
.venv
.vscode
.vault_pass

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "services"]
path = services
url = https://git.lgoon.xyz/gabriel/lgoon-services

View File

@ -6,20 +6,13 @@ This playbook was tested against a debian 12 image.
## Usage
```bash
ansible-playbook run.yml
ansible-playbook run.yml --ask-pass --ask-become-pass
ansible-playbook run.yml --vault-password-file .vault_pass
```
## Variables
Should be defined in `group_vars/server/vars.yml`:
- **services_dir**: folder path containing all folders with docker-compose stacks. they should have the scructure `<service>/docker-compose.yml` and optionally include `<service>/.env` files
- **services_dir**: fodler path containing all folders with docker-compose stacks. they should have the scructure `<service>/docker-compose.yml` and optionally include `<service>/.env` files
- **services**: list of services in the service_dir container all `<service>` folders
- **packages**: utils packages for linxu environment
## Secrets
```bash
ansible-vault create secret.yml
ansible-vault edit secret
ansible-vault view secret
ansible-vault encrypt secret.yml
```

View File

@ -1,8 +0,0 @@
packages:
- git
- htop
- rsync
- wget
base_services:
- managers
services_configs_dir: ""

View File

@ -1,3 +0,0 @@
group_services:
- gitea
services: "{{ base_services + group_services }}"

View File

@ -1,5 +0,0 @@
group_services:
- nextcloud
- syncthing
- immich
services: "{{ base_services + group_services }}"

View File

@ -1,9 +0,0 @@
group_services:
# - pinry
# - piped
# - immich
# - monica
# - piwigo
# - vikunja
- syncthing
services: "{{ base_services + group_services }}"

View File

@ -1,9 +0,0 @@
group_services:
# - pinry
# - piped
# - immich
# - monica
# - piwigo
# - vikunja
- syncthing
services: "{{ base_services + group_services }}"

View File

@ -1,9 +0,0 @@
services:
# - pinry
# - piped
# - immich
# - monica
# - piwigo
# - vikunja
- syncthing
services: "{{ base_services + services }}"

View File

@ -1,10 +1,10 @@
group_services:
# - pinry
# - piped
# - immich
# - monica
# - piwigo
# - vikunja
- syncthing
services: "{{ base_services + group_services }}"
packages:
- git
- htop
services:
- pinry
- immich
- monica
- piwigo
- vikunja
services_dir: /home/gabriel/hosted

View File

@ -1,9 +0,0 @@
group_services:
# - pinry
# - piped
# - immich
# - monica
# - piwigo
# - vikunja
- syncthing
services: "{{ global_services + group_services }}"

View File

@ -1,24 +1,8 @@
file-server:
server:
hosts:
debianpx:
ansible_host: 192.168.122.177
ansible_user: gabriel
ansible_become: yes
ansible_become_method: sudo
ec2-13-239-10-136.ap-southeast-2.compute.amazonaws.com:
vars:
source_services_dir: /home/gabriel/hosted
server_services_dir: /home/srv/services/configs
PERSISTENT_DIRECTORY: /home/srv/services/persistent
# VOLATILE_DIRECTORY: /home/gabriel/hosted/volatile
# BACKUPDIR: /home/gabriel/hosted/backup
# APPSDIR: /home/gabriel/hosted/apps
# MEDIADIR: /home/gabriel/hosted/media
media-servers:
hosts:
algrroca:
ansible_user: root
# ansible_ssh_private_key_file: /home/gabriel/.ssh/aws_ec2_ssh.pem
# PERSISTENT_DIRECTORY: /home/srv/raidded
# VOLATILE_DIRECTORY: /home/srv/mstorage
# ansible_sudo_pass:
ansible_user: admin
ansible_ssh_private_key_file: /home/gabriel/dev/terraform/terraform-lab/ec2ml/my_ssh.pem
PERSISTENT_DIRECTORY: /persistent
VOLATILE_DIRECTORY: /volatile %

View File

@ -1 +0,0 @@
ansible

View File

@ -1,10 +1,10 @@
---
- name: Update packages
ansible.builtin.apt:
update_cache: true
upgrade: true
apt:
update_cache: yes
upgrade: yes
- name: Install essential packages
ansible.builtin.package:
package:
name: "{{ packages }}"
state: latest

View File

@ -1,68 +1,46 @@
---
- name: Install aptitude
ansible.builtin.apt:
apt:
name: aptitude
state: latest
update_cache: true
- name: Install required system packages
ansible.builtin.apt:
apt:
pkg:
- apt-transport-https
- ca-certificates
- curl
- gnupg
- lsb-release
- software-properties-common
- python3-pip
- virtualenv
- python3-setuptools
state: latest
update_cache: true
- name: Download Docker GPG key
ansible.builtin.get_url:
- name: Add Docker GPG apt Key
apt_key:
url: https://download.docker.com/linux/debian/gpg
dest: /etc/apt/keyrings/docker.gpg
mode: '0644'
- name: Add Docker GPG key to apt keyring
ansible.builtin.shell: |
gpg --dearmor < /etc/apt/keyrings/docker.gpg > /etc/apt/keyrings/docker.gpg.gpg
chmod 644 /etc/apt/keyrings/docker.gpg.gpg
args:
creates: /etc/apt/keyrings/docker.gpg.gpg
state: present
- name: Add Docker Repository
ansible.builtin.apt_repository:
repo: "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg.gpg] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
apt_repository:
repo: deb https://download.docker.com/linux/debian bookworm stable
state: present
filename: docker
- name: Update apt and install docker-ce
ansible.builtin.apt:
apt:
name: docker-ce
state: latest
update_cache: true
- name: Update apt and install docker-compose
apt:
name: docker-compose
state: latest
update_cache: true
- name: Install Docker Module for Python
ansible.builtin.pip:
name: docker
extra_args: --break-system-packages
- name: adding existing user to group docker '{{ ansible_user }}'
ansible.builtin.user:
name: '{{ ansible_user }}'
groups: docker
append: true
- name: Ensure Docker service is started and enabled
ansible.builtin.service:
name: docker
state: started
enabled: true
- name: Ensure Docker Compose plugin is installed
ansible.builtin.apt:
name: docker-compose-plugin
state: latest
update_cache: true

View File

@ -1,5 +1,5 @@
---
- ansible.builtin.include_tasks: dependencies.yml
- ansible.builtin.include_tasks: install_docker.yml
- ansible.builtin.include_tasks: start_service.yml
- ansible.builtin.include_tasks: nginx_config.yml
- include_tasks: dependencies.yml
- include_tasks: install_docker.yml
- include_tasks: start_service.yml
- include_tasks: nginx_config.yml

View File

@ -1,6 +1,6 @@
---
- name: Copy service folder
ansible.builtin.copy:
copy:
src: "{{ services_dir }}/nginx-npm"
dest: /services/

View File

@ -1,32 +1,11 @@
---
- name: Ensure services destination directory exists
ansible.builtin.file:
path: "{{ server_services_dir }}"
state: directory
mode: '0755'
owner: "{{ ansible_user | default('root') }}"
group: "{{ ansible_user | default('root') }}"
- name: Copy service folder
ansible.builtin.copy:
src: "{{ source_services_dir }}/{{ item }}"
dest: "{{ server_services_dir }}"
mode: '0755'
owner: "{{ ansible_user | default('root') }}"
group: "{{ ansible_user | default('root') }}"
ansible.posix.synchronize:
src: "{{ services_dir }}/{{ item }}"
dest: /services/
with_items: "{{ services }}"
- name: Docker Compose Start Service
community.docker.docker_compose_v2:
project_src: "{{ server_services_dir }}/{{ item }}"
# environment: "{{ compose_env }}"
check_files_existing: true
assume_yes: true
build: policy
wait: true
register: output
- name: Start Docker compose
community.docker.docker_compose:
project_src: "/services/{{ item }}"
with_items: "{{ services }}"
async: 300
poll: 10

14
run.yml
View File

@ -1,17 +1,5 @@
---
- hosts: server
become: true
roles:
- role: webserver
# vars_files:
# - secret
- hosts: file-server
become: true
roles:
- role: webserver
- hosts: media-server
become: true
become: yes
roles:
- role: webserver