How to parametrize a deployment? #1034
Unanswered
sfermigier
asked this question in
Q&A
Replies: 1 comment
-
Not sure to well understand but it seems better to use hosts groups : # in inventory.py:
dev = ["srvdev1"]
prod = ["srvprod1", "srvprod2"]
# then in your deploy.py:
if "prod" in host.groups:
... You can also use host data: # in inventory.py:
my_app_servers = [
("srvprod1", {"run_env": "prod"}),
("srvprod2", {"run_env": "prod"}),
("srvdev1", {"run_env": "dev"}),
]
# then in your deploy.py:
if host.data.run_env == "prod":
...
elif host.data.run_env == "dev":
...
else:
raise DeployError("Unknown run_env") |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to parametrize a deployment script for an application. I want a "dev" deployment (-> vagrant) and a "prod" deployment (-> production server), possibly with extra parameters (e.g. app name and ports, for multi-instance deployments).
So far I have found 2 options:
PROFILE=dev pyinfra @vagrant deploy.py
, withdeploy.py
interpreting the env variable to use the intended parameters (which are hardcoded in the script).deploy-dev.py
,deploy-prod1.py
, etc.) that contain the proper parameters and call a common set of functions contained in another module (I called itrecipes.py
).Is this a common use case? Is there a recommended solution? Did I miss a way to pass a parameter or a config to the
pyinfra
CLI?Beta Was this translation helpful? Give feedback.
All reactions