Using Vagrant to manage development and production environments?

前端 未结 4 1649
北荒
北荒 2021-02-13 10:57

How are people handling simple automation (with puppet) for dev / prod environments with vagrant (ideally from the same vagrantfile)?

Use case I\'m trying to sol

4条回答
  •  情歌与酒
    2021-02-13 11:41

    what I came up with to work with this scenario is to manage 2 distincts .vagrant folder.

    Note: most of the other answers deal with setting up multi-provider assuming you will run dev and prod on different provider, in most cases this might be true but you can definitely have cases where you have same provider for dev and prod. Lets say you're using aws and you want to use dev and prod as ec2 instance it will be the same provider.

    Say you want to manage dev and prod instances, potentially using different providers (but could also very well be on the same provider) so you'll do:

    • set up dev instance with normal vagrant up --provider . This will create a dev VM that you can manage

    • back up the .vagrant folder created in your project directory and rename it like .vagrant.dev

    • set up prod instance with your provider of choice vagrant up --provider . This now creates your prod VM

    • back up the newly .vagrant folder created in your project directory and rename it like .vagrant.prod

    now, depending if you want to work on dev or prod, you'll rename the .vagrant.dev or .vagrant.prod directory as .vagrant and vagrant will operate the right VM.

    I did not come up with a script as mainly the most of the time I work with dev and very few times I need to switch to the other provider. but I dont think it will be too hard to read the parameter from CLI and make the renaming more dynamic.

提交回复
热议问题