Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant/Puppet --- ensure: change from present failed: Could not set 'present on ensure: No such file or dir

I am using Vagrant and Puppet to install Apache and PHP on Ubuntu. However I am getting the error below during vagrant up. I think the path for the templates are correct, then why the error?

I'm using the setup here modified to ensure apt-get update runs before anything else

Error

←[1;35merr: /Stage[main]/Php/File[/etc/php5/apache2/apc.ini]/ensure: change from absent to present failed: Could not set 'present on ensure: No such file or dir ectory - /etc/php5/apache2/apc.ini.puppettmp_6187 at /tmp/vagrant-puppet/modules -0/php/manifests/init.pp:44←[0m

←[1;35merr: /Stage[main]/Php/File[/etc/php5/apache2/php.ini]/ensure: change from absent to present failed: Could not set 'present on ensure: No such file or dir ectory - /etc/php5/apache2/php.ini.puppettmp_6687 at /tmp/vagrant-puppet/modules -0/php/manifests/init.pp:36←[0m

/modules/php/manifests/init.pp

file { "/etc/php5/apache2/php.ini":
  ensure => present,
  mode => 644,
  content => template("php/etc/php5/conf.d/php.ini.erb"),
  require => Package["php5"],
  notify => Service["apache"];
}

file { "/etc/php5/apache2/apc.ini":
  ensure => present,
  mode => 644,
  content => template("php/etc/php5/conf.d/apc.ini.erb"),
  require => [ Package["php5"], Package["php-apc"], Package["apache"] ],
  notify => Service["apache"];
}

Templates

  • /modules/php/templates/etc/php5/conf.d/apc.ini.erb
  • /modules/php/templates/etc/php5/conf.d/php.ini.erb
like image 215
Nyxynyx Avatar asked Dec 16 '22 18:12

Nyxynyx


2 Answers

Just ensure that directory /etc/php5/apache2 exists.

file { [ "/etc", "/etc/php5", "/etc/php5/apache2" ]:
   ensure => directory,
   before => File['/etc/php5/apache2/php.ini'],
}

or little less Puppet-ish

exec { "ensure /etc/php5/apache2":
  command => "mkdir -p /etc/php5/apache2",
  creates => "/etc/php5/apache2"
}

All this is probably because of assumptions on the order of execution.

More info @ the puppet docs

like image 148
Vladan Avatar answered Jan 04 '23 22:01

Vladan


Are you sure Package["php5"] it's creating the path for you?

It seems to me that it's complaining because /etc/php5/apache2 folder does not exist when it tries to create the files from the templates.

If you want to discard your puppetmaster side you can find puppetmaster process id and run:

strace -v -f -ff -p $PID -o strace.log

Then, run the agent again and go to puppetmaster and run:

grep "etc/php5/apache2" strace.log.*

If puppetmaster it's ok you will see the reading call without errors, else you will see that puppetmaster receives "no such file or directory" when trying to open the file. Anyway as you I don't think the problem it's with template call, seems ok to me,.

like image 44
Valor Avatar answered Jan 04 '23 22:01

Valor