gabriel becker
1 year ago
commit
baa5bae5f2
12 changed files with 144 additions and 0 deletions
@ -0,0 +1,18 @@
|
||||
# Ansible Server |
||||
Ansible playbook to setup docker compose and start arbitraty number of compose stacks by using group_variables. |
||||
|
||||
This playbook was tested against a debian 12 image. |
||||
|
||||
## Usage |
||||
```bash |
||||
ansible-playbook run.yml |
||||
``` |
||||
|
||||
## Variables |
||||
Should be defined in `group_vars/server/vars.yml`: |
||||
- **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 |
||||
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
[defaults] |
||||
INVENTORY = inventory.yml |
||||
|
||||
[ssh_connections] |
||||
pipelining = true |
@ -0,0 +1,10 @@
|
||||
packages: |
||||
- git |
||||
- htop |
||||
services: |
||||
- pinry |
||||
- immich |
||||
- monica |
||||
- piwigo |
||||
- vikunja |
||||
services_dir: /home/gabriel/hosted |
@ -0,0 +1,8 @@
|
||||
server: |
||||
hosts: |
||||
ec2-13-239-10-136.ap-southeast-2.compute.amazonaws.com: |
||||
vars: |
||||
ansible_user: admin |
||||
ansible_ssh_private_key_file: /home/gabriel/dev/terraform/terraform-lab/ec2ml/my_ssh.pem |
||||
PERSISTENT_DIRECTORY: /persistent |
||||
VOLATILE_DIRECTORY: /volatile % |
@ -0,0 +1,3 @@
|
||||
--- |
||||
roles: |
||||
- name: community.docker.docker_compose |
@ -0,0 +1,10 @@
|
||||
--- |
||||
- name: Update packages |
||||
apt: |
||||
update_cache: yes |
||||
upgrade: yes |
||||
|
||||
- name: Install essential packages |
||||
package: |
||||
name: "{{ packages }}" |
||||
state: latest |
@ -0,0 +1,46 @@
|
||||
--- |
||||
- name: Install aptitude |
||||
apt: |
||||
name: aptitude |
||||
state: latest |
||||
update_cache: true |
||||
|
||||
- name: Install required system packages |
||||
apt: |
||||
pkg: |
||||
- apt-transport-https |
||||
- ca-certificates |
||||
- curl |
||||
- software-properties-common |
||||
- python3-pip |
||||
- virtualenv |
||||
- python3-setuptools |
||||
state: latest |
||||
update_cache: true |
||||
|
||||
- name: Add Docker GPG apt Key |
||||
apt_key: |
||||
url: https://download.docker.com/linux/ubuntu/gpg |
||||
state: present |
||||
|
||||
- name: Add Docker Repository |
||||
apt_repository: |
||||
repo: deb https://download.docker.com/linux/ubuntu jammy stable |
||||
state: present |
||||
|
||||
- name: Update apt and install docker-ce |
||||
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 |
@ -0,0 +1,5 @@
|
||||
--- |
||||
- include_tasks: dependencies.yml |
||||
- include_tasks: install_docker.yml |
||||
- include_tasks: start_service.yml |
||||
# - include_tasks: nginx_config.yml |
@ -0,0 +1,21 @@
|
||||
--- |
||||
- name: Copy service folder |
||||
copy: |
||||
src: "{{ services_dir }}/nginx" |
||||
dest: /services/ |
||||
|
||||
- name: Copy nginx subfolder file |
||||
copy: |
||||
src: "{{ item }}/nginx.conf" |
||||
dest: "/nginx.../{{ item }}.config.conf" |
||||
with_items: "{{ services }}" |
||||
|
||||
- name: Copy service folder |
||||
copy: |
||||
src: "{{ item }}/docker-compose.yml" |
||||
dest: /tmp/docker-compose.yml |
||||
with_items: "{{ services }}" |
||||
|
||||
- name: Start Docker compose |
||||
community.docker.docker_compose: |
||||
project_src: "/services/nginx/" |
@ -0,0 +1,11 @@
|
||||
--- |
||||
- name: Copy service folder |
||||
ansible.posix.synchronize: |
||||
src: "{{ services_dir }}/{{ item }}" |
||||
dest: /services/ |
||||
with_items: "{{ services }}" |
||||
|
||||
- name: Start Docker compose |
||||
community.docker.docker_compose: |
||||
project_src: "/services/{{ item }}" |
||||
with_items: "{{ services }}" |
Loading…
Reference in new issue