sup icon indicating copy to clipboard operation
sup copied to clipboard

Use environment variables in inventory

Open bborysenko opened this issue 9 years ago • 3 comments

I would like to be able dynamically generate inventory based on environment variables:

# Supfile

---
env:
  GCLOUD_INSTANCE_NAME: loadtesing-template

networks:
  cloud:
    inventory:
      echo "deploy@$(gcloud compute instances describe $GCLOUD_INSTANCE_NAME | grep natIP | awk '{print $2}'):22"

But it doesn't work:

$ sup
usage: gcloud compute instances describe  NAME [optional flags]
ERROR: (gcloud.compute.instances.describe) too few arguments
Networks:
- cloud
    - deploy@:22

$ sup -e GCLOUD_INSTANCE_NAME=loadtesing-master
usage: gcloud compute instances describe  NAME [optional flags]
ERROR: (gcloud.compute.instances.describe) too few arguments
Networks:
- cloud
    - deploy@:22

Is there some way to do it?

bborysenko avatar Sep 23 '16 15:09 bborysenko

Just in few minutes later I realized that it can be done in this way:

$ GCLOUD_INSTANCE_NAME=loadtesing-master sup -e GCLOUD_INSTANCE_NAME=loadtesing-master 

But in this case I have to specify this var twice, what is bit annoying.

bborysenko avatar Sep 23 '16 15:09 bborysenko

makes sense -- are you going to submit a PR?

VojtechVitek avatar Sep 26 '16 19:09 VojtechVitek

Sorry, but no. Have to learn golang before ...

bborysenko avatar Oct 07 '16 12:10 bborysenko