How to setup test enviroment using the same vagrant provisioner - vagrant

Currrently, we are setting up development environment using Vagrant. All software (php, mysql, apache, memcached..) are installed using Vagrant Chef solo provisioner.
Now we want to create a test environment using a physical machine (it has same OS to the Vagrant virtual machine).
I don't want to install all required softwares on the test server manually, instead of that I want to setup test server automatically using same Vagrant provisioner. Is it posible and how can I do that?

You can use/run chef-client in local mode on that server see https://docs.chef.io/ctl_chef_client.html#run-in-local-mode
Chef solo https://docs.chef.io/chef_solo.html is also an option but I think chef-client local mode is preferred now.
Another option is to create a free hosted Chef account, upload your cookbooks to hosted Chef, bootstrap your server and run the chef-client.
The best approach I think is to use an actual Chef server. Use hosted Chef or setup your own Chef server. Assuming you will want to also easily update the configuration of the test server as you make changes to your recipes, using an actual Chef server is the best approach.

Related

Use Windows with Virtual Box as Host and VM guest for managing with Vagrant and Ansible

Is there a way for next scenario as I am planing to setup lab environment:
physical desktop running Windows 8 platform
on Windows 8, I plan to install ONLY Virtual Box 5.1
then on VirtualBox to setup CentOS system
and then on CentOS will be running Vagrant and Ansible (no VirtualBox installation)
Question: Is there any way that this setup will work to create new environments via CentOS as Vagrant-Ansible manage servers?
------------------------edit----------------------
Thank you for your answer. I try to setup as I mentioned above without luck. I am new user of Vagrant and Ansible so I am having trouble to make it work. I setup Linux system on VB, install vagrant, install Ansible but when I hit 'vagrant up' I am getting error that "No usable default provider could be found for your". I am following documentation form official sites but can;t make it work. Then I try to install VirtualBox inside Linux system and now it is working but defined machines with Vagrant installs inside Linux machine (where are Vagrant and Ansible installed) and not on Host VirtualBox. Any advice? I hope it is clearer now. Thanks
I have had some success in using a Windows Ansible Host and running using Vagrant with this host.
I have scripted how to setup Win Ansible and the shims at:
https://github.com/taliesins/win-ansible
The important bit is to setup shims that call bash scripts running under cygwin.
Another important thing to consider is, is that it is probably better to generate your own inventory file (put it in the vagrant file before you create VMs) then to use an auto-generated inventory file.
If you environment is not simple consider not using Vagrant provisioner for Ansible, but rather call Ansible via command line at the end of the vagrant file (after you have created the VMs).

Do I Need Ruby and Chef On My Vagrant Box

I am using the trusty64 vagrant box and I provision it using puppet.
I just noticed today that ruby and chef are installed and I don't use either of them for my VM work.
Do I need them there for Vagrant to do its magic?
Can I remove them after my VM is provisioned or will vagrant halt and vagrant up stop working?
so to the question
Do I Need Ruby and Chef On My Vagrant Box
Its mainly up to you.
no, more seriously:
Ruby comes install with Linux distro, generally some older version but its a fact that it is delivered (as python, perl ...) so you should leave it. It is not doing any harm and some other tools (including chef and puppet) relies on Ruby to be installed so if you provision with puppet you must leave ruby
Vagrant does not rely on ruby to be installed on the guest to do its magic, its mainly issuing ssh script command to do the update on network/hostname ...
trustry64 box is an official box from hashicorp (the company behind vagrant) and vagrant does support out of the box chef and puppet provisioning those tools are installed. Again they don't make any harm even if you're not using it.
The thing is that your box will have ruby and chef installed and whenever you boot a new VM from this box, it will contain ruby and chef, I think you will spend more time cleaning the booted VM at the end of the day, specially if you have to destroy/rebuild the VM.
If you want a minimalist box that contains only the thing you need, you can look at packer - packer is a tool to automate the creation of vagrant box, so you can really control what is install from the iso file of the OS to the libraries and 3rd party tools.
Vagrant does rely on ruby installed in the box if you are using chef or puppet provisioner. chef/puppet runs happen inside the guest box which vagrant orchestrates using ssh.
You can remove chef when you will use chef provisioner,vagrant will download and install it again but you would need ruby for puppet.
See puppet install dependency here

chef workstation setup softwares required

I am trying to execute chef commands and build the server for that I did below setup on MacOS but observed that I need to have vagrant and virtualbox but I am not sure if I need to install it on host macOS machine or Virtual machine. Could you please suggest on this.
Setup which I did so far is as below:
On Mac OS I have installed VirtualBox and created a base ubuntu Virtual Machine
Then Inside virtual machine having ubuntu as OS installed ChefDk, Hosted chef server setup, knife and git
created chef-repo repository
In order to complete setup, Do I need to install vagrant and one more instance of Virtualbox inside virtual machine on ubuntu OS and do I need any additional installation?
Install ChefDK and Vagrant as well as VirtualBox on your workstation. This allows you to use any editor/IDE to edit cookbooks and then provision a VM using Vagrant and Virtualbox (or other supported hypervisors).
In general, I would recommend to follow Learn Chef.
Honestly, the question is a little confusion on your objective. But from a high level, i can assume that you are trying to get started with chef using the hosted chef server. First i agree with #StephenKing pointing you to the learn chef site. That's a good starting point. But here are some things that should clear up your question:
Typically there will be a development workstation. In your case its the MacBook. This is where you will install chefDK and write your fancy cookbooks. It should have the chef-repo, knife.rb etc to talk with the chef server.
Once your initial cookbook writting is over, you upload the cookbook and other params like environment, data_bags, roles etc to the chef server (in the chef-org)
Its here you need a node to apply your cookbook. As a starter, use some nodes from a VPS that's far more easier rather then trying to use vagrant nodes or something. As the saying goes "one step at a time". Do not try to learn chef and vagrant or even more (which is what you will encounter with chef) at the same time.
Once you have the node, bootstrap the node to your chef-org where the cookbooks were uploaded. Then run chef-client on the node.
And you are on your way to the chef world.

Windows 8 HOST Vagrant spinup GUEST Ubuntu dev followed with Ansible manage dev stack from GUEST

I am working with Vagrant to provision Ubuntu servers using bash. I would like to cut my teeth on Ansible however I understand that Ansible does not currently run on Windows Host.
Is something like the following a reasonable work-around?
On Windows Host, use Vagrant to spin-up a basic Ubuntu Dev Box, including Ansible tools. From the Guest Dev Box use Ansible to run local tasks to further build it out. From the Dev Box I would use Ansible to spin-up/manage other Digital Ocean droplets from this Dev Box.
Your easiest workaround is probably to use virtualbox to start a linux/ubuntu virtual running on your Windows box, then to run Vagrant inside of that virtual. Yes, it's turtles all the way down- windows running virtualbox+ubuntu running virtualbox+ubuntu+vagrant.
Of course, the first layer won't be managed by Vagrant or Ansible, though you could do most of the configuration management after bootstrapping it.
Another option is to have a small dev box in your virtual hosting provider (Digital Ocean) where you manually install and launch vagrant/ansible from.
Alternately, dual boot or switch to a Linux or OSX machine :)

Does Puppet continue to run after startup when used as a provisioner in Vagrant?

The question is basically in the title, but to expound a little: I've got a puppet manifest that runs on startup in our development Vagrant VMs. I'd like to add a couple things that make life easier for our developers -- things like bouncing Apache when our source files change or rebuilding our translation files when the master file is changed.
All of that seems simple enough to do, but I'm not sure whether it's possible to make the puppet service continue to monitor the machine after the VM is provisioned, and the Vagrant documentation doesn't seem to mention it.
Provisioning is a part of the vagrant up process, once the VM is up and running, it's finished.
NOTE: Provisioners in Vagrant allow you to automatically install software, alter configurations, and more on the machine as part of the vagrant up process.
I am NOT an expert on Puppet (Chef user), I think to bounce Apache if config files are changed, you may need an agent running on the VM.
BTW: vagrant provision can be used to run updated Chef cookbooks or Puppet modules after the VM is up.
Update
Since Vagrant 1.3.0 (released Sep 5, 2013)
vagrant up will now only run provisioning by default the first time it is run. Subsequent reload or up will need to explicitly specify the --provision flag to provision. [GH-1776]
See change log => https://github.com/mitchellh/vagrant/blob/master/CHANGELOG.md

Resources