Vagrant + nginx+Ansible
- Download virtualbox
- Download vagrant
- Vagrantfile: Change
config.vm.box = "ubuntu/trusty64"
, to set ubuntu server of your choice. - Commands:
vagrant up
To boot vagrant environment and now we have virtual machine running Ubuntuvagrant ssh
to ssh into machine - 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"]
Dovagrant ssh
- Check vagrant config file
vagrant ssh-config
, make a note of default ip, port and the ssh it is using. - 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) - 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