Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Commit

Permalink
Mysql proxy (#6)
Browse files Browse the repository at this point in the history
* mysql support
* fqcn
* editorconfig
  • Loading branch information
kdpuvvadi authored Jul 4, 2023
1 parent ea42ca0 commit 169e645
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 18 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

[![lint](https://github.com/kdpuvvadi/proxy/actions/workflows/lint.yml/badge.svg?event=push)](https://github.com/kdpuvvadi/proxy/actions/workflows/lint.yml)

Playbook works on both Debian & Red Hat family hosts. Using Ubuntu 20.04 pc as control node.

You need at least 2.9 or higher version of ansible.

## Setup

1. Install pip `sudo apt install python3-pip -y`
Expand Down Expand Up @@ -38,4 +34,5 @@ Password: changeme

## Portainer

To install portainer set `portainer_enable` value to `true`.
To install portainer, set `portainer_enable` value to `true`.
To install proxy manager with MySQL instead of SQLite, set `proxy_with_mysql` to true
31 changes: 18 additions & 13 deletions main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@

pre_tasks:
- name: Config
include_vars: vars.yml
ansible.builtin.include_vars: vars.yml

- name: apt cache update
apt:
- name: Apt cache update
ansible.builtin.apt:
update_cache: true
cache_valid_time: 3600
when:
- ansible_facts.os_family == "Debian"

- name: apt Upgrade
apt:
- name: Apt Upgrade
ansible.builtin.apt:
upgrade: true
when:
- ansible_facts.os_family == "Debian"

- name: yum cache update & upgrade
yum:
- name: Yum cache update & upgrade
ansible.builtin.yum:
name: "*"
state: latest
update_cache: true
Expand All @@ -30,14 +30,19 @@
tasks:

- name: Install packages/prerequisites
import_tasks: tasks/packages.yml
ansible.builtin.import_tasks: tasks/packages.yml

- name: Setup Docker.
import_tasks: tasks/docker.yml
ansible.builtin.import_tasks: tasks/docker.yml

- name: Install Nginx Proxy Manager
import_tasks: tasks/proxy.yml
- name: Install Nginx Proxy Manager with SQLite
ansible.builtin.import_tasks: tasks/proxy.yml
when: not proxy_with_mysql

- name: install portainer
import_tasks: tasks/portainer.yml
- name: Install Nginx Proxy Manager with MySQL
ansible.builtin.import_tasks: tasks/proxy-mysql.yml
when: proxy_with_mysql

- name: Install portainer
ansible.builtin.import_tasks: tasks/portainer.yml
when: portainer_enable
46 changes: 46 additions & 0 deletions tasks/proxy-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
- name: Create a network for proxy manager
community.docker.docker_network:
name: "{{ network }}"

- name: Deploy mysql/mariadb
community.docker.docker_container:
name: "{{ mysql_host }}"
image: jc21/mariadb-aria:latest
ports:
- "3306:3306"
volumes:
- "/data/mysql:/var/lib/mysql"
env:
MYSQL_ROOT_PASSWORD: "{{ mysql_root_password }}"
MYSQL_DATABASE: "{{ mysql_database }}"
MYSQL_USER: "{{ mysql_database }}"
MYSQL_PASSWORD: "{{ mysql_password }}"
restart_policy: unless-stopped
networks:
- name: "{{ network }}"
container_default_behavior: compatibility
network_mode: "{{ network }}"


- name: Nginx Proxy Manager deploy
community.docker.docker_container:
name: nginx_proxy
image: jc21/nginx-proxy-manager:latest
ports:
- "80:80"
- "81:81"
- "443:443"
volumes:
- "/data:/data"
- "/letsencrypt:/etc/letsencrypt"
env:
DB_MYSQL_HOST: "{{ mysql_host }}"
DB_MYSQL_PORT: "3306"
DB_MYSQL_USER: "{{ mysql_user }}"
DB_MYSQL_PASSWORD: "{{ mysql_password }}"
DB_MYSQL_NAME: "{{ mysql_database }}"
restart_policy: unless-stopped
networks:
- name: "{{ network }}"
network_mode: "{{ network }}"
8 changes: 8 additions & 0 deletions vars.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ network: proxy

# portainer
portainer_enable: false

# Mysql vars
proxy_with_mysql: false
mysql_root_password: npm
mysql_database: npm
mysql_user: npm
mysql_password: npm
mysql_host: mysql

0 comments on commit 169e645

Please sign in to comment.