Vagrant + nginx+Ansible

  1. Download virtualbox
  2. Download vagrant
  3. Vagrantfile: Change config.vm.box = "ubuntu/trusty64", to set ubuntu server of your choice.
  4. Commands:vagrant up To boot vagrant environment and now we have virtual machine running Ubuntuvagrant ssh to ssh into machine
  5. To change default key:ssh-keygen —> generate a new key pair (let's say vagrant and vagrant.pub)Vagrantfile: add the config.ssh.private_key_path = ["~/vagrant"]Do vagrant ssh
  6. Check vagrant config file vagrant ssh-config, make a note of default ip, port and the ssh it is using.
  7. Ansible install: pip install ansible --user.. sometimes this ansible says command not found..for this, export PATH="~/Library/Python/2.7/bin:$PATH" (we can add this to ~/.bash_profile to make it permanent)
  8. hosts file with 127.0.0.1:2222 ( default ip and port of vagrant)install_nginx.yml with codes to install ngnixand ansible-playbook command: ansible-playbook --private-key=~/vagrant -u vagrant -i hosts filename.yml
Creates a ubuntu vagrant and installs nginx with ansible
Creates a ubuntu vagrant and installs nginx with ansible - Vagrantfile