Search code examples
vagrantpuppetpuphpet

Puphpet create directory


Probably my issue is quite trivial but I couldn't find anything about it. What I need is to have a directory always created in my vagrant with specific owner and mode. Is this possible somehow easily?


Solution

  • If you want the folder synced with your host system then add this line to your Vagrantfile within the Vagrant.configure(2) do |config| section:

    config.vm.synced_folder "host_dir", "guest_dir", create: true , group: "name_of_group", owner: "name_of_owner"
    

    If you just want to create a folder on the guest system you can use the inline shell provision:

    config.vm.provision "shell", inline: "mkdir -p guest_dir && chown -R owner:group guest_dir"
    

    ^Assuming you're running a linux vm.