Currently i'm using Vagrant and bash scripts to provision a local dev environment. I'm working on moving this to Puppet and running into an issue with creating a symlink to my apache document root that I cant seem to sort out.
These are the commands in the bash script i'm trying replace/replicate
sudo rm -rf /var/www/html
sudo ln -s /vagrant/public /var/www/html
in my puppet manifest I have the following
file{ 'docroot':
path => '/var/www/html',
ensure => absent,
purge => true,
recurse => true,
force => true,
}
file{ '/vagrant/public':
ensure => link,
force => true,
target => '/var/www/html',
require => File['docroot'],
}
The output when the manifist runs is
==> default: Debug: /Stage[main]/Main/File[docroot]: Removing existing directory for replacement with absent
==> default: Notice: /Stage[main]/Main/File[docroot]/ensure: removed
==> default: Debug: /Stage[main]/Main/File[docroot]: The container docroot will propagate my refresh event
==> default: Debug: /Stage[main]/Main/File[/var/www/html/index.html]: Nothing to manage: no ensure and the resource doesn't exist
==> default: Debug: docroot: The container Class[Main] will propagate my refresh event
==> default: Info: /Stage[main]/Main/File[/vagrant/public]: Recursively backing up to filebucket
==> default: Debug: /Stage[main]/Main/File[/vagrant/public]: Removing existing directory for replacement with link
==> default: Info: /Stage[main]/Main/File[/vagrant/public]: Recursively backing up to filebucket
==> default: Debug: /Stage[main]/Main/File[/vagrant/public]: Removing existing directory for replacement with /var/www/html
==> default: Error: Could not remove existing file
==> default: Error: /Stage[main]/Main/File[/vagrant/public]/ensure: change from directory to link failed: Could not remove existing file
Which seems to indicate it couldn't remove a file... /var/www/html did have an index.html file in it. With Purge => true and ensure => absent the index.html and the html folder its self are both gone as expected. Yet I still get the could not remove existing file message while trying to create the link.
I have tried setting ensure=> directory in File[ 'docroot' ] to leave an empty html directory and still get the same error. So clearly i'm doing something wrong... any help would be apprichated. Thanks.