![]() ![]() It will be available in the "/vagrant" directory. Vagrant will try to install Ansible in the Vagrant machine and apply the provided playbook afterwards.ĭuring this process, Vagrant will sync the working directory in the Vagrant machine. If you don't have Ansible on your machine, you can consider using the Ansible Local provisioner. $ vagrant provision Ansible Local Provisioner Afterwards, you can test the deployment or change the playbook and run the provisioner again. Just run vagrant up to start the VM and run the provisioner. Vagrant will create an inventory automatically and run the "ansible-playbook" command, so the new inventory is used. ![]() In addition, you can see a new section "config.vm.provision", which will trigger the Ansible provisioning. nfigure("2") do |config|Ĭonfig.vm.provision "ansible" do |ansible|Īs you can see, we will spin-up a Fedora 34 machine. Edit the Vagrantfile with the editor of your choice. The last part, we need to add content for the Vagrantfile. Some content for the website may look like the below example. The module will look in the "files" directory on its own, and you don't need to specify the full path. Īs you can see, we want to copy a custom index.html, too. Edit the "playbook.yml" file and fill in some content like below. Let's write a simple playbook, that will install a basic web server. First, we need to create a small project and some files. You can use different Ansible Version in a "virtualenv" and run everything as, if the Vagrant Box is just another remote machine (stack). ![]() The Ansible Provisioner is very useful, if you are having Ansible installed on your machine anyway. If you don't know Ansible, I strongly recommend reading some articles about it. Same tool for production and develop is my preferred way. You can also consider Ansible, if you are using it anyway, to deploy and configure your infrastructure. Vagrant can help to spin up a machine and deploy your code on different Operating Systems and you can do much more, than in Docker or Podman containers. Much stuff can be done in containers, but sometimes you want to test virtualization, kernel parameters, certain security and firewall settings and just need some "real" machine. If you develop Ansible Playbooks, Roles or Collections, you may want to test them properly. The guide is tested on Fedora 34 with Vagrant 2.2.16. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |