python - How to pass arguments to deployment script? -
python - How to pass arguments to deployment script? -
i have construction deployment this:
on target machine have /versions/ directory built versions: /versions/1.0/ /versions/2.0/ etc to deploy version 2, run next command: ssh host /versions/2.0/deploy.sh var1 var2 var3 var4 var5the problem it's unflexible passing many variables that. like:
ssh host /versions/2.0/deploy.py config.jsonor like
ssh host /version/2.0/deploy.py "{var1: '', var2: '', var3: '', var4: '', var5: ''}"the first solution requires me first come temporary file name, re-create config file host machine, execute deploy script, , remove config file.
the sec solution i'm not sure if it's safe pass json on command line.
any ideas on how can pass configuration object/file deployment script?
you can pass json on command line, illustration not valid json. note json requires keys quoted double quotes , values cannot single quoted must double quoted well. you'll want set single quotes around entire json blob can avoid shell interaction json info itself.
another alternative utilize environment variables instead of json. although, can ugly if passing them via ssh; however, can utilize env
command help this:
ssh host env var1=value1 var2=value2 var3=value3 /version/2.0/deploy.py
inside python script can access environment variables via os.environ
dictionary.
python linux bash deployment ssh
Comments
Post a Comment