36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
import json
|
|
import ssl
|
|
import urllib.request
|
|
import pathlib
|
|
import getpass
|
|
|
|
ctx = ssl.create_default_context(cafile="secrets/ca.crt")
|
|
token = getpass.getpass("Operator root token: ")
|
|
|
|
for role in ("api", "worker", "operator"):
|
|
url = "https://localhost:8200/v1/secret/data/" + role
|
|
headers = {
|
|
"X-Vault-Token": token,
|
|
"Content-Type": "application/json"
|
|
}
|
|
|
|
req = urllib.request.Request(url, headers=headers)
|
|
with urllib.request.urlopen(req, context=ctx) as r:
|
|
data = json.load(r)["data"]["data"]
|
|
|
|
data["DATABASE_URL"] = data["DATABASE_URL"].split("?")[0]
|
|
data["DATABASE_URL"] += "?sslmode=verify-full&sslrootcert=/tls/ca.crt"
|
|
data["BROKER_URL"] = data["BROKER_URL"].replace(
|
|
"amqp://", "amqps://"
|
|
).replace("@broker:5672", "@broker:5671")
|
|
|
|
|
|
req = urllib.request.Request(
|
|
url,
|
|
data=json.dumps({"data": data}).encode(),
|
|
headers=headers,
|
|
method="POST"
|
|
)
|
|
|
|
with urllib.request.urlopen(req, context=ctx):
|
|
print(role + ": updated") |