Added the inventory information for ansible in the project and made it so that the file is only run once.

Updated python dependencies
This commit is contained in:
Amritanshu Agrawal 2022-06-07 18:30:39 +05:30
parent 98d3e212c3
commit 92023caadc
13 changed files with 31 additions and 399 deletions

View File

@ -7,23 +7,23 @@ authors = ["tanshu <git@tanshu.com>"]
[tool.poetry.dependencies]
python = "^3.10"
uvicorn = {extras = ["standard"], version = "^0.17.6"}
fastapi = "^0.76.0"
fastapi = "^0.78.0"
python-jose = {extras = ["cryptography"], version = "^3.3.0"}
passlib = {extras = ["bcrypt"], version = "^1.7.4"}
psycopg2-binary = "^2.9.2"
SQLAlchemy = {extras = ["mypy"], version = "^1.4.28"}
psycopg2-binary = "^2.9.3"
SQLAlchemy = {extras = ["mypy"], version = "^1.4.36"}
python-multipart = "^0.0.5"
PyJWT = "^2.3.0"
alembic = "^1.7.5"
itsdangerous = "^2.0.1"
PyJWT = "^2.4.0"
alembic = "^1.7.7"
itsdangerous = "^2.1.2"
python-dotenv = "^0.20.0"
pydantic = {extras = ["dotenv"], version = "^1.8.2"}
starlette = "^0.18.0"
pydantic = {extras = ["dotenv"], version = "^1.9.1"}
starlette = "^0.19.1"
[tool.poetry.dev-dependencies]
flake8 = "^4.0.1"
black = "^22.3.0"
isort = {extras = ["toml"], version = "^5.10.0"}
isort = {extras = ["toml"], version = "^5.10.1"}
mypy = "^0.950"
[build-system]

View File

@ -33,7 +33,4 @@ else
fi
cd "$parent_path/docker" || exit
docker save brewman:latest | bzip2 | pv | ssh vancity 'bunzip2 | sudo docker load'
ansible-playbook --limit vancity playbook-exp.yml
ansible-playbook --limit vancity playbook-hops.yml
ansible-playbook --limit vancity playbook-acc.yml
ansible-playbook --limit vancity playbook-mhl.yml
ansible-playbook --inventory hosts playbook.yml

14
docker/hosts Normal file
View File

@ -0,0 +1,14 @@
# - Comments begin with the '#' character
# - Blank lines are ignored
# - Groups of hosts are delimited by [header] elements
# - You can enter hostnames or ip addresses
# - A hostname/ip can be a member of multiple groups
[brewman]
acc ansible_host=vancity var_file=vars/acc.yml
exp ansible_host=vancity var_file=vars/exp.yml
hops ansible_host=vancity var_file=vars/hops.yml
mhl ansible_host=vancity var_file=vars/mhl.yml
[all:vars]
ansible_python_interpreter=/usr/bin/python3

View File

@ -1,68 +0,0 @@
#################################################
# DO Community Playbooks: Docker
#################################################
---
- hosts: all
become: true
vars_files:
- vars/acc.yml
tasks:
- name: Copy dockerfile
synchronize: src=app dest=/tmp
- name: Build brewman image
docker_image:
name: brewman:latest
build:
path: /tmp/app/
dockerfile: /tmp/app/Dockerfile
pull: yes
state: present
source: build
- name: Upload the .env file
template:
src: "files/.env-acc"
dest: "/var/lib/{{ host_directory }}/.env"
- name: Create brewman container
docker_container:
name: "{{ host_directory }}"
image: brewman:latest
state: started
restart_policy: "unless-stopped"
env_file: "/var/lib/{{ host_directory }}/.env"
published_ports:
- "127.0.0.1:{{ host_port }}:80"
volumes:
- "/var/lib/{{ host_directory }}/frontend:/frontend"
- name: Check if Nginx conf file exists
stat: path="/etc/nginx/sites-available/{{ http_conf }}"
register: status
- name: No need to reload Nginx
debug: msg= {{ "No need to reload Nginx as sites-available entries have already been created" }}
- name: Set Nginx conf file
when: status.stat.exists == false
template:
src: "files/nginx.conf.j2"
dest: "/etc/nginx/sites-available/{{ http_conf }}"
- name: Enable new site
when: status.stat.exists == false
file:
src: "/etc/nginx/sites-available/{{ http_conf }}"
dest: "/etc/nginx/sites-enabled/{{ http_conf }}"
state: link
notify: Reload Nginx
handlers:
- name: Reload Nginx
service:
name: nginx
state: reloaded

View File

@ -2,10 +2,10 @@
# DO Community Playbooks: Docker
#################################################
---
- hosts: all
- hosts: brewman
become: true
vars_files:
- vars/exp.yml
- "{{ var_file }}"
tasks:
- name: Copy dockerfile
@ -23,7 +23,7 @@
- name: Upload the .env file
template:
src: "files/.env-exp"
src: "{{ env_file }}"
dest: "/var/lib/{{ host_directory }}/.env"
- name: Create brewman container

View File

@ -1,68 +0,0 @@
#################################################
# DO Community Playbooks: Docker
#################################################
---
- hosts: all
become: true
vars_files:
- vars/hops.yml
tasks:
- name: Copy dockerfile
synchronize: src=app dest=/tmp
- name: Build brewman image
docker_image:
name: brewman:latest
build:
path: /tmp/app/
dockerfile: /tmp/app/Dockerfile
pull: yes
state: present
source: build
- name: Upload the .env file
template:
src: "files/.env-hops"
dest: "/var/lib/{{ host_directory }}/.env"
- name: Create brewman container
docker_container:
name: "{{ host_directory }}"
image: brewman:latest
state: started
restart_policy: "unless-stopped"
env_file: "/var/lib/{{ host_directory }}/.env"
published_ports:
- "127.0.0.1:{{ host_port }}:80"
volumes:
- "/var/lib/{{ host_directory }}/frontend:/frontend"
- name: Check if Nginx conf file exists
stat: path="/etc/nginx/sites-available/{{ http_conf }}"
register: status
- name: No need to reload Nginx
debug: msg= {{ "No need to reload Nginx as sites-available entries have already been created" }}
- name: Set Nginx conf file
when: status.stat.exists == false
template:
src: "files/nginx.conf.j2"
dest: "/etc/nginx/sites-available/{{ http_conf }}"
- name: Enable new site
when: status.stat.exists == false
file:
src: "/etc/nginx/sites-available/{{ http_conf }}"
dest: "/etc/nginx/sites-enabled/{{ http_conf }}"
state: link
notify: Reload Nginx
handlers:
- name: Reload Nginx
service:
name: nginx
state: reloaded

View File

@ -1,68 +0,0 @@
#################################################
# DO Community Playbooks: Docker
#################################################
---
- hosts: all
become: true
vars_files:
- vars/mhl.yml
tasks:
- name: Copy dockerfile
synchronize: src=app dest=/tmp
- name: Build brewman image
docker_image:
name: brewman:latest
build:
path: /tmp/app/
dockerfile: /tmp/app/Dockerfile
pull: yes
state: present
source: build
- name: Upload the .env file
template:
src: "files/.env-mhl"
dest: "/var/lib/{{ host_directory }}/.env"
- name: Create brewman container
docker_container:
name: "{{ host_directory }}"
image: brewman:latest
state: started
restart_policy: "unless-stopped"
env_file: "/var/lib/{{ host_directory }}/.env"
published_ports:
- "127.0.0.1:{{ host_port }}:80"
volumes:
- "/var/lib/{{ host_directory }}/frontend:/frontend"
- name: Check if Nginx conf file exists
stat: path="/etc/nginx/sites-available/{{ http_conf }}"
register: status
- name: No need to reload Nginx
debug: msg= {{ "No need to reload Nginx as sites-available entries have already been created" }}
- name: Set Nginx conf file
when: status.stat.exists == false
template:
src: "files/nginx.conf.j2"
dest: "/etc/nginx/sites-available/{{ http_conf }}"
- name: Enable new site
when: status.stat.exists == false
file:
src: "/etc/nginx/sites-available/{{ http_conf }}"
dest: "/etc/nginx/sites-enabled/{{ http_conf }}"
state: link
notify: Reload Nginx
handlers:
- name: Reload Nginx
service:
name: nginx
state: reloaded

View File

@ -3,3 +3,4 @@ http_host: "acc.hopsngrains.com"
http_conf: "acc.hopsngrains.com.conf"
host_port: "8659"
host_directory: "brewman-acc"
env_file: "files/.env-acc"

View File

@ -3,3 +3,4 @@ http_host: "exp.tanshu.com"
http_conf: "exp.tanshu.com.conf"
host_port: "8656"
host_directory: "brewman-exp"
env_file: "files/.env-exp"

View File

@ -3,3 +3,4 @@ http_host: "hops.hopsngrains.com"
http_conf: "hops.hopsngrains.com.conf"
host_port: "8658"
host_directory: "brewman-hops"
env_file: "files/.env-hops"

View File

@ -3,3 +3,4 @@ http_host: "mhl.hopsngrains.com"
http_conf: "mhl.hopsngrains.com.conf"
host_port: "8657"
host_directory: "brewman-mhl"
env_file: "files/.env-mhl"

View File

@ -1,89 +0,0 @@
DROP TABLE recipe_items;
DROP TABLE recipes;
DROP TABLE menu_items;
ALTER TABLE products RENAME TO products_old;
CREATE TABLE products (
"ProductID" UUID NOT NULL,
"Code" INTEGER,
"Name" VARCHAR(255) NOT NULL,
"Units" VARCHAR(255) NOT NULL,
"Fraction" NUMERIC NOT NULL,
"FractionUnits" VARCHAR(255) NOT NULL,
"ProductYield" NUMERIC NOT NULL,
"ProductGroupID" UUID NOT NULL,
"LedgerID" UUID NOT NULL,
cost_price NUMERIC NOT NULL,
sale_price NUMERIC NOT NULL,
"IsActive" BOOLEAN NOT NULL,
"IsFixture" BOOLEAN NOT NULL,
is_purchased BOOLEAN NOT NULL,
is_sold BOOLEAN NOT NULL,
PRIMARY KEY ("ProductID"),
UNIQUE ("Name", "Units"),
UNIQUE ("Code"),
FOREIGN KEY ("ProductGroupID") REFERENCES product_groups ("ProductGroupID"),
FOREIGN KEY ("LedgerID") REFERENCES ledgers ("LedgerID")
);
INSERT INTO products (
"ProductID", "Code", "Name", "Units", "Fraction", "FractionUnits",
"ProductYield", "ProductGroupID", "LedgerID", cost_price, sale_price,
"IsActive", "IsFixture", is_purchased, is_sold)
SELECT
"ProductID",
"Code",
"Name",
"Units",
"Fraction",
"FractionUnits",
"ProductYield",
"ProductGroupID",
"LedgerID",
"Price",
0,
"IsActive",
"IsFixture",
TRUE,
FALSE
FROM products_old;
ALTER TABLE batches DROP CONSTRAINT "entities_batches_ProductID_fkey";
ALTER TABLE batches ADD CONSTRAINT "batches_ProductID_fkey" FOREIGN KEY ("ProductID")
REFERENCES products ("ProductID");
ALTER TABLE inventories DROP CONSTRAINT "entities_inventories_ProductID_fkey";
ALTER TABLE inventories ADD CONSTRAINT "inventories_ProductID_fkey" FOREIGN KEY ("ProductID")
REFERENCES products ("ProductID");
DROP TABLE products_old;
CREATE TABLE recipes (
recipe_id UUID NOT NULL,
product_id UUID NOT NULL,
quantity NUMERIC NOT NULL,
cost_price NUMERIC NOT NULL,
sale_price NUMERIC NOT NULL,
notes VARCHAR(255),
valid_from DATE NOT NULL,
valid_to DATE NOT NULL,
effective_from DATE NOT NULL,
effective_to DATE,
PRIMARY KEY (recipe_id),
FOREIGN KEY (product_id) REFERENCES products ("ProductID")
);
CREATE TABLE recipe_items (
recipe_item_id UUID NOT NULL,
recipe_id UUID NOT NULL,
product_id UUID NOT NULL,
quantity INTEGER NOT NULL,
price INTEGER NOT NULL,
PRIMARY KEY (recipe_item_id),
UNIQUE (recipe_id, product_id),
FOREIGN KEY (recipe_id) REFERENCES recipes (recipe_id),
FOREIGN KEY (product_id) REFERENCES products ("ProductID")
);

View File

@ -1,90 +0,0 @@
-- rename ledgers to accounts and add the is_starred column
CREATE TABLE accounts
(
id uuid NOT NULL,
code integer NOT NULL,
name character varying(255) NOT NULL,
type integer NOT NULL,
account_type character varying(50) NOT NULL,
is_starred boolean NOT NULL,
is_active boolean NOT NULL,
is_reconcilable boolean NOT NULL,
cost_centre_id uuid NOT NULL,
is_fixture boolean NOT NULL,
CONSTRAINT accounts_pkey PRIMARY KEY (id),
CONSTRAINT accounts_cost_centre_id_fkey FOREIGN KEY (cost_centre_id)
REFERENCES cost_centres ("CostCentreID"),
CONSTRAINT "accounts_name_key" UNIQUE (name)
);
INSERT INTO accounts(
id, code, name, type, account_type, is_starred, is_active,
is_reconcilable, cost_centre_id, is_fixture)
SELECT "LedgerID", "Code", "Name", "Type", ledger_type, FALSE, "IsActive",
"IsReconcilable", "CostCentreID", "IsFixture"
FROM ledgers;
ALTER TABLE employees RENAME COLUMN "LedgerID" TO id;
ALTER TABLE employees DROP CONSTRAINT "entities_employees_LedgerID_fkey";
ALTER TABLE employees ADD CONSTRAINT "employees_id_fkey" FOREIGN KEY (id)
REFERENCES accounts (id);
ALTER TABLE journals RENAME COLUMN "LedgerID" TO account_id;
ALTER TABLE journals DROP CONSTRAINT "entities_journals_LedgerID_fkey";
ALTER TABLE journals ADD CONSTRAINT "journals_account_id_fkey" FOREIGN KEY (account_id)
REFERENCES accounts (id);
ALTER TABLE products RENAME COLUMN "LedgerID" TO account_id;
ALTER TABLE products DROP CONSTRAINT "products_LedgerID_fkey";
ALTER TABLE products ADD CONSTRAINT "products_account_id_fkey" FOREIGN KEY (account_id)
REFERENCES accounts (id);
DROP TABLE ledgers;
ALTER TABLE vouchers RENAME TO vouchers_old;
CREATE TABLE vouchers
(
"VoucherID" uuid NOT NULL,
date timestamp without time zone NOT NULL,
narration character varying(1000) NOT NULL,
creation_date timestamp with time zone NOT NULL,
last_edit_date timestamp with time zone NOT NULL,
voucher_type integer NOT NULL,
is_posted boolean NOT NULL,
poster_id uuid,
user_id uuid NOT NULL,
is_reconciled boolean NOT NULL,
reconcile_date timestamp without time zone NOT NULL,
is_starred boolean NOT NULL,
CONSTRAINT vouchers_pkey PRIMARY KEY ("VoucherID"),
CONSTRAINT vouchers_poster_id_fkey FOREIGN KEY (poster_id) REFERENCES public.auth_users ("UserID"),
CONSTRAINT vouchers_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.auth_users ("UserID")
);
INSERT INTO vouchers(
"VoucherID", date, reconcile_date, narration, creation_date, last_edit_date,
voucher_type, is_posted, poster_id, user_id, is_reconciled, is_starred)
SELECT "VoucherID", "Date", "ReconcileDate", "Narration", "CreationDate", "LastEditDate",
"VoucherType", "Posted", "PosterID", "UserID", "IsReconciled", FALSE
FROM vouchers_old;
ALTER TABLE inventories DROP CONSTRAINT "entities_inventories_VoucherID_fkey";
ALTER TABLE inventories ADD CONSTRAINT "inventories_VoucherID_fkey" FOREIGN KEY ("VoucherID")
REFERENCES vouchers ("VoucherID");
ALTER TABLE journals DROP CONSTRAINT "entities_journals_VoucherID_fkey";
ALTER TABLE journals ADD CONSTRAINT "journals_VoucherID_fkey" FOREIGN KEY ("VoucherID")
REFERENCES vouchers ("VoucherID");
ALTER TABLE salary_deductions DROP CONSTRAINT "entities_salarydeductions_VoucherID_fkey";
ALTER TABLE salary_deductions ADD CONSTRAINT "salary_deductions_VoucherID_fkey" FOREIGN KEY ("VoucherID")
REFERENCES vouchers ("VoucherID");
ALTER TABLE service_charges DROP CONSTRAINT service_charges_voucher_id_fkey;
ALTER TABLE service_charges ADD CONSTRAINT service_charges_voucher_id_fkey FOREIGN KEY (voucher_id)
REFERENCES vouchers ("VoucherID");
DROP TABLE vouchers_old;