Ansible is being run in a world writable directory (/vagrant), ignoring it as an ansible.cfg source - ansible

trying to provision vagrant vm (ubuntu/trusty64) with ansible_local provisioner
from cygwin
[WARNING] Ansible is being run in a world writable directory (/vagrant), ignoring it as an ansible.cfg source. For more information see https://docs.ansible.com/ansible/devel/reference_appendices/config.html#cfg-in-world-writable-dir
can anyone help me with this
please suggest how to configure the ansible.cfg file in cygwin
what should be the content of this and where should this be ?

You can solve this with mount_options in the Vagrantfile:
srv.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: false, mount_options: ["dmode=775"]

Did R & D and got help from the github vagrant community members.
https://github.com/hashicorp/vagrant/issues/11707
previously before running ansible_local ,i had tried ansible provisioner.
so created new workspace folder and fired up vagrant up.
this time it worked from CYGWIN.

Related

How to write shell provision code for a vagrant box to change a file not in the shared folder?

I am setting up a vagrant box to create a django box and i need to make changes to the apache2 vhost configuration in the provision shell code.
how to edit a file in a shell command?
Most simple is if you can have a copy of the host file configuration that you want to apply to your VM. So on your host machine you have the file and during provisioning you will apply this file on the guest machine.
This can be done using the File Provisioner you will add the following in your Vagrantfile
config.vm.provision "file", source: "path/to/host_conf_file", destination: "/var/path/to/apache/conf/file"

vagrant windows folder setup

I'm setting up vagrant on my Windows 7 and configuring Vagrantfile. Can I set the actual folder and guest folder to be the same? Here is my code:
config.vm.synced_folder "C:\Users\dmitry\VM\code", "/vagrant/code"
Yes you can. I used the config like below and it worked beautifully:
config.vm.synced_folder "C:/git/ui", "/home/vagrant/ui"

Why is Vagrant hosting my project directory on the guest machine?

For a project with a file /foo/bar/Vagrantfile, Vagrant shares/syncs /foo/bar on the host machine as /vagrant on the guest machine.
Why is it doing this? It appears to be undesirable: the whole point is achieving isolation, but this sharing destroys isolation: a buggy VM can delete my project directory, and my tinkering with my project can affect the VM.
So, what is the point of this? Is it necessary for something I've overlooked?
Vagrant by default sync the project directory (where Vagrantfile resides) with /vagrant within the guest.
If it is NOT desired, it can be disabled by explicitly disable the synced folder config in Vagrantfile and then a vagrant reload is needed.
config.vm.synced_folder ".", "/vagrant", disabled: true
If one-off or manual sync is required, use the new rsync type added in vagrant 1.5.x.

config.vm.share_folder setting not found

I am getting this error with this line in my Vagrantfile during vagrant up, until I comment it out.
The setting is documented here:
http://docs-v1.vagrantup.com/v1/docs/config/vm/share_folder.html
Not sure why the following documented paramenter causes an error
config.vm.share_folder "puppetdir", "/etc/puppet", "/vagrant/mypuppetdir"
Bringing machine 'default' up with 'virtualbox' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:
vm:
* The following settings don't exist: share_folder
The latest virtualbox and latest vagrant. everything else works fine.
On Vagrant 1.1+ you should use config.vm.synced_folder, the docs you are looking at are for older versions. Please refer to the updated documentation for more info: http://docs.vagrantup.com/v2/synced-folders/basic_usage.html
Shared Folders has been renamed to Synded Folder since 1.1.
In your Vagrantfile you should be using the following
config.vm.synced_folder "../data", "/vagrant_data"
# by default enabled, uncomment to disable
# config.vm.synced_folder ".", "/vagrant", disabled: true
NOTE: By default, Vagrant will share your project directory (the directory where Vagrantfile resides) to /vagrant.
config.vm.synced_folder ".", "/vagrant", disabled: true
More flexible example
vagrant_data = File.expand_path("../vagrant_data", __FILE__)
Dir::mkdir(vagrant_data) unless FileTest::directory?(vagrant_data)
config.vm.synced_folder "vagrant_data", "/vagrant_data"
Take a look at this for more information => shared folders VS synced folders
Extending from https://github.com/mitchellh/vagrant/issues/936#issuecomment-7179034
if you need to mount a volume as a user that doesn't exist when the vm boots you can get there like so:
# Vagrantfile line
config.vm.synced_folder "host_folder", "/svr/fake_mount_folder", id: "whatever_name"
# ...
config.vm.provision "shell", inline: <<-SHELL
# ...
# In my case a package installed a user with UID 110, GID 116
mount -t vboxsf -o uid=110,gid=116 whatever_name /media/actual_mounted_folder
# ...
SHELL

puppet looking for hiera.yaml in the wrong place

I want puppet to look for hiera.yaml in /etc but it's looking for it in /etc/puppet. I put a line into puppet.conf:
hiera_config = /etc/hiera.yaml
But still gives me the hiera.yaml update warning when I run the script.
I'm running the script from Vagrant 1.2.2. Using puppet 3.2.2
I'm running Centos 6.4 in a vm.
I found that the puppet provisioner in vagrant now support hiera_config_path which does exactly what is desired.
config.vm.provision :puppet do |puppet|
# path on host machine to hiera.yaml
puppet.hiera_config_path = '/Users/me/vms/hiera/hiera.yaml'
# This sets the relative path for hiera data directories
puppet.working_directory = '/Users/me/vms/hiera'
end
This is documented in Vagrant: Up and Running but I didn't find it until I started looking into the vagrant source to implement this feature myself.
Hmmm... On Vagrant 1.2.2 and Puppet 3.2.3, I am able to set hiera_config in puppet.conf without problems. I would double-check that you are editing /etc/puppet.conf on the Vagrant vm, not on the host machine, and that the hiera_config line is the [main] block, not just in the [master] block.
If both of those conditions are true and it is still not working, you might try explicitly setting hiera_config in your Vagrantfile:
config.vm.provision :puppet do |puppet|
...
puppet.options = '--hiera_config=/etc/hiera.yaml'
end
Good luck!
Puppet provisioning runs as root user, not vagrant, so that's why it doesn't take notice of your puppet.conf in /vagrant.
If you run puppet config print inside the vm from user vagrant and root you see ALL puppet config settings per user and compare.

Resources