Compare commits
2 Commits
a1c7052e85
...
acda51a6b4
Author | SHA1 | Date | |
---|---|---|---|
acda51a6b4 | |||
cd736a2606 |
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
sudo apt update --yes && sudo apt upgrade --yes
|
sudo apt update --yes && sudo apt upgrade --yes
|
||||||
sudo apt install --yes virtualbox vagrant ansible
|
sudo apt install --yes virtualbox vagrant ansible
|
||||||
ansible-galaxy install -r ./requirements.yml
|
ansible-galaxy collection install -r requirements.yml
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
---
|
---
|
||||||
# ansible-galaxy requirements for this repository
|
# ansible-galaxy requirements for this repository
|
||||||
collections:
|
collections:
|
||||||
- 'community.postgresql'
|
- community.postgresql
|
||||||
|
26
service.py
26
service.py
@ -18,9 +18,11 @@ RE_TEXT = re.compile(r"^\w+$")
|
|||||||
RE_NUM = re.compile(r"^\d+$")
|
RE_NUM = re.compile(r"^\d+$")
|
||||||
|
|
||||||
|
|
||||||
def _take_input(prompt: str, pattern: re.Pattern) -> str:
|
def _take_input(prompt: str, pattern: re.Pattern, default: str="") -> str:
|
||||||
while True:
|
while True:
|
||||||
i = input(prompt)
|
i = input(prompt)
|
||||||
|
if i == "":
|
||||||
|
i = default
|
||||||
if pattern.match(i):
|
if pattern.match(i):
|
||||||
return i
|
return i
|
||||||
|
|
||||||
@ -36,22 +38,22 @@ def main() -> int:
|
|||||||
break
|
break
|
||||||
|
|
||||||
if c == "1":
|
if c == "1":
|
||||||
customer_name = _take_input("Customer name (example=opc): ",
|
customer_name = _take_input("Customer name (example=opg): ",
|
||||||
RE_TEXT)
|
RE_TEXT)
|
||||||
env_name = _take_input("Environment name (example=prod): ",
|
env_name = _take_input("Environment name (example=prod): ",
|
||||||
RE_TEXT)
|
RE_TEXT)
|
||||||
amnt_nginx_web = _take_input(
|
amnt_nginx_web = _take_input(
|
||||||
"Number of nginx webservers (example=1): ", RE_NUM)
|
"Number of nginx webservers (default=1): ", RE_NUM, default="1")
|
||||||
amnt_nginx_lb = _take_input(
|
amnt_nginx_lb = _take_input(
|
||||||
"Number of nginx loadbalancers (example=1): ", RE_NUM)
|
"Number of nginx loadbalancers (default=1): ", RE_NUM, default="1")
|
||||||
amnt_psql = _take_input(
|
amnt_psql = _take_input(
|
||||||
"Number of postgres instances (example=1): ", RE_NUM)
|
"Number of postgres instances (default=1): ", RE_NUM, default="1")
|
||||||
ip_format = _take_input(
|
ip_format = _take_input(
|
||||||
"Format of ip (example=192.168.56.{}, `{}` will be replaced with the correct octet at runtime): ",
|
"Format of ip (default=192.168.56.{}, `{}` will be replaced with the correct octet at runtime): ",
|
||||||
re.compile(r".+"))
|
re.compile(r".+"), default="192.168.56.{}")
|
||||||
ip_int = _take_input(
|
ip_int = _take_input(
|
||||||
"Number to start formatting the IP from (example=10): ",
|
"Number to start formatting the IP from (default=10): ",
|
||||||
RE_NUM)
|
RE_NUM, default="10")
|
||||||
|
|
||||||
sub.call([
|
sub.call([
|
||||||
"python3", "cli.py", "create", customer_name, env_name,
|
"python3", "cli.py", "create", customer_name, env_name,
|
||||||
@ -61,21 +63,21 @@ def main() -> int:
|
|||||||
])
|
])
|
||||||
|
|
||||||
if c == "2":
|
if c == "2":
|
||||||
customer_name = _take_input("Customer name (example=opc): ",
|
customer_name = _take_input("Customer name (example=opg): ",
|
||||||
RE_TEXT)
|
RE_TEXT)
|
||||||
env_name = _take_input("Environment name (example=prod): ",
|
env_name = _take_input("Environment name (example=prod): ",
|
||||||
RE_TEXT)
|
RE_TEXT)
|
||||||
sub.call(["python3", "cli.py", "delete", customer_name, env_name])
|
sub.call(["python3", "cli.py", "delete", customer_name, env_name])
|
||||||
|
|
||||||
if c == "3":
|
if c == "3":
|
||||||
customer_name = _take_input("Customer name (example=opc): ",
|
customer_name = _take_input("Customer name (example=opg): ",
|
||||||
RE_TEXT)
|
RE_TEXT)
|
||||||
env_name = _take_input("Environment name (example=prod): ",
|
env_name = _take_input("Environment name (example=prod): ",
|
||||||
RE_TEXT)
|
RE_TEXT)
|
||||||
sub.call(["python3", "cli.py", "recover", customer_name, env_name])
|
sub.call(["python3", "cli.py", "recover", customer_name, env_name])
|
||||||
|
|
||||||
if c == "4":
|
if c == "4":
|
||||||
customer_name = _take_input("Customer name (example=opc): ",
|
customer_name = _take_input("Customer name (example=opg): ",
|
||||||
RE_TEXT)
|
RE_TEXT)
|
||||||
sub.call(["python3", "cli.py", "list", customer_name])
|
sub.call(["python3", "cli.py", "list", customer_name])
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user