0

I am using Debian 7.x

This is such odd behavior

  1. I am invoking puppet through vagrant provisioner
  2. I am using puppetlabs/debian-7.8-64-puppet as the base image

Why is Apache loading even though there is no reference to apache anywhere in my puppet script?

Here is the entire puppet script:

#
# Install all required packages
#

$packages = [
    "curl",

    "nginx",

    #"php5-gd",        
    #"php5-cli", 
    "php5-fpm", 
    "php5-ldap",
    #"php5-mysql",

    "mysql-server",

    "htmldoc",
]

package { $packages:
    ensure => present,
}

#
# Configure PHP-FPM
#

service { "php5-fpm":
    ensure => running,
    require => Package['php5-fpm'],
}

#
# Configure NGINX
#

service { "nginx":
  require => Package["nginx"],
  ensure => running,
  enable => true
}

file { "/etc/nginx/sites-available/default":
  ensure => "file",
  require => Package["nginx"],
  content => file("/var/www/.vagrant/puppet/modules/nginx/files/aerospace"),
}

file_line { "Append required Cadorath Aerospace NGINX parameters":
  require => Package["nginx"],
  path => "/etc/nginx/fastcgi_params",
  line => file("/var/www/.vagrant/puppet/modules/nginx/files/params.conf"),
}

Whenever I uncomment php5-gd or php5-mysql - Apache is somehow magically loaded and takes precedence over NGINX???

I literally will uncomment that line - rebuild machine SSH and run a ps -aux and suddenly I see Apache not NGINX serving my pages

Ideas?

  • Debian's PHP5 package requires *one* of `libapache2-mod-php5`, `libapache2-mod-php5filter`, `php5-cgi` or `php5-fpm`. https://packages.debian.org/wheezy/php5 I'm not hugely familiar with Puppet, but would moving the `php5-fpm` up after `nginx` get it to install before the other PHP packages? – ceejayoz Apr 05 '16 at 19:41
  • Negative. I don't understand WTF puppet is doing. I moved nginx to the top of the packages list bottom and everywhere in between and Apache still somehow gets installed over top if I require those php5-xxx packages :s – Alex.Barylski Apr 05 '16 at 20:00
  • 1
    @ceejayoz: Puppet doesn't follow any implicit order you might try by listing things in a specific order. This is a very basic principle of it. Instead, if items depend on each other, you have to make this explicity, e.g. by `require` statements. So, in this case it might be necessary to have the service `pfp5-fpm` also to require `Package['nginx']` (or whatever is necessary to get the package dependencies right. – Sven Apr 05 '16 at 22:18
  • How do I prevent apache from installing tho? Or how do I install php5-mysql without bringing on Apache? – Alex.Barylski Apr 05 '16 at 22:27
  • 1
    I think you'd want to make all the other PHP packages require `php5-fpm`. Once `php5-fpm` is installed, it won't try to install Apache anymore. – ceejayoz Apr 06 '16 at 01:02

1 Answers1

1

The order you specify for the packages in the $packages list is irrelevant, Puppet will create a number of package objects from it and execute them in an arbitrary order, with each object resulting in one call to apt-get install, which prevents apt to do its own dependency resolution with the full list of packages you want to install and might result in pulling in a default package to resolve problems (Apache in this case).

One way around this should work somewhat like the following:

$packages = [
    "curl",
 # "nginx",   ## Not nginx!
    "php5-gd",        
    "php5-cli", 
    "php5-fpm", 
    "mysql-server",
    "htmldoc",
]

package { 'nginx': 
  ensure => present,
}

package { $packages:
    ensure => present,
    require => Package['nginx'],
}

so you make sure that nginx is the first package installed (it might be necessary to do this for other or additional packages instead of nginx, depending on how the actual dependency tree works out.

Sven
  • 98,649
  • 14
  • 180
  • 226