Search code examples
ubuntu-12.04puppetubuntu-server

Why does puppet magically install apache2 for me?


I'm new to puppet and thought to try something out. This simple tryout manifest should install PHP and then NGINX with no modification to any config files.

But every time I try it out I get unwanted apache2 installed. I'm on Ubuntu Server 12.04, using "http://apt.puppetlabs.com precise main". If anyone can spot the culprit I would apprechiate it. How to debug this kind of issue with puppet ?

Things I tried.. after apt-get purge apache* php* nginx*

  1. Install same packages via apt-get. WORKS properly.
  2. Apply manifest in steps with multile commenting of below sections /* */. This also worked, apache2 did not get installed.
  3. Search for "apache" string from from puppet "--debug" output. With using full manifest. String not found, but apache2 got installed anyway.
  4. Removed #hiera_include('classes') from sites.pp and put this manifest directly to sites.pp. Same results, apache2 got installed.

Manifest:

###### APT
include "apt"

apt::ppa { 'ppa:ondrej/php5': }
apt::key { "ondrej": key => "E5267A6C" }

apt::ppa { 'ppa:nginx/stable': }
apt::key { "nginx": key => "C300EE8C" }

###### PHP

$php_packages = [
"php5", 
"php5-fpm",
"php5-common", 
"php5-cli", 
"php5-curl",
"php5-ldap",
"php5-mysql",
"php5-pgsql", 
"php5-gd",
]

package { $php_packages:
    ensure  =>  'installed',
    require => Apt::Ppa['ppa:ondrej/php5' ],
    install_options => ['--no-install-recommends'],
}

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

###### NGINX

package { 'nginx':
    ensure  =>  'installed',
    require => [
        Package['php5-fpm'],
        Apt::Ppa['ppa:nginx/stable' ],
        ],
    notify => Service['php5-fpm'],
    install_options => ['--no-install-recommends'],
}
package { 'apache2':
    ensure => "purged",
}

service { 'nginx':
    ensure => running,
    require => Package['nginx'],
}

Results: 1) First run...

?#> puppet agent --no-daemonize --test --verbose
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for puppetclient.net
Info: Applying configuration version '1418303395'
Notice: /Stage[main]/Profiles::Userservices_common/Package[php5-mysql]/ensure: ensure changed 'purged' to 'present'
Notice: /Stage[main]/Profiles::Userservices_common/Package[php5-gd]/ensure: ensure changed 'purged' to 'present'
Notice: /Stage[main]/Profiles::Userservices_common/Package[php5]/ensure: ensure changed 'purged' to 'present'
Notice: /Stage[main]/Profiles::Userservices_common/Package[php5-fpm]/ensure: ensure changed 'purged' to 'present'
Notice: /Stage[main]/Profiles::Userservices_common/Package[nginx]/ensure: ensure changed 'purged' to 'present'
Info: /Package[nginx]: Scheduling refresh of Service[php5-fpm]
Notice: /Stage[main]/Profiles::Userservices_common/Package[php5-ldap]/ensure: ensure changed 'purged' to 'present'
Notice: /Stage[main]/Profiles::Userservices_common/Package[php5-pgsql]/ensure: ensure changed 'purged' to 'present'
Notice: /Stage[main]/Profiles::Userservices_common/Package[php5-curl]/ensure: ensure changed 'purged' to 'present'
Notice: /Stage[main]/Profiles::Userservices_common/Service[nginx]/ensure: ensure changed 'stopped' to 'running'
Info: /Stage[main]/Profiles::Userservices_common/Service[nginx]: Unscheduling refresh on Service[nginx]
Notice: /Stage[main]/Profiles::Userservices_common/Service[php5-fpm]: Triggered 'refresh' from 1 events
Notice: Finished catalog run in 86.97 seconds

2) Check apache folder... Why is apache2 installed at all ???

?#> la /etc/apa*
total 64K
drwxr-xr-x 2 root root  138 2014-12-11 15:10 conf-available
drwxr-xr-x 2 root root  138 2014-12-11 15:10 conf-enabled
drwxr-xr-x 2 root root 8,0K 2014-12-11 15:10 mods-available
drwxr-xr-x 2 root root 4,0K 2014-12-11 15:10 mods-enabled
drwxr-xr-x 2 root root   52 2014-12-11 15:10 sites-available
drwxr-xr-x 2 root root   29 2014-12-11 15:10 sites-enabled
-rw-r--r-- 1 root root 7,0K 2014-07-23 00:16 apache2.conf
-rw-r--r-- 1 root root 1,8K 2014-07-23 00:16 envvars
-rw-r--r-- 1 root root  31K 2014-07-23 00:16 magic
-rw-r--r-- 1 root root  320 2014-07-23 00:16 ports.conf

3) Second run...

?#> puppet agent --no-daemonize --test --verbose
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for puppetclient.net
Info: Applying configuration version '1418303395'
Notice: /Stage[main]/Profiles::Userservices_common/Package[apache2]/ensure: ensure changed '2.4.10-1+deb.sury.org~precise+1' to 'purged'
Notice: /Stage[main]/Profiles::Userservices_common/Service[nginx]/ensure: ensure changed 'stopped' to 'running'
Info: /Stage[main]/Profiles::Userservices_common/Service[nginx]: Unscheduling refresh on Service[nginx]
Notice: Finished catalog run in 12.32 seconds

4) Check apache folder... Ok this I understand, the ensure => "purged" takes affect.

?#> la /etc/apa*
ls: cannot access /etc/apa*: No such file or directory

Solution

  • because

      # apt-cache show php5|grep Depends
        Depends: libapache2-mod-php5 (>= 5.3.3-7+squeeze19) | libapache2-mod-php5filter (>= 5.3.3-7+squeeze19) | php5-cgi (>= 5.3.3-7+squeeze19), php5-common (>= 5.3.3-7+squeeze19)
    

    and

      # apt-cache show libapache2-mod-php5 |grep Depends
        Depends: libbz2-1.0, libc6 (>= 2.11), libcomerr2 (>= 1.01), libdb4.8, libgssapi-krb5-2 (>= 1.6.dfsg.2), libk5crypto3 (>= 1.6.dfsg.2), libkrb5-3 (>= 1.6.dfsg.2), libonig2 (>= 5.2.0), libpcre3 (>= 7.7), libqdbm14 (>= 1.8.74), libssl0.9.8 (>= 0.9.8m-1), libxml2 (>= 2.7.4), zlib1g (>= 1:1.1.4), mime-support, apache2-mpm-prefork (>> 2.0.52) | apache2-mpm-itk, apache2.2-common, php5-common (= 5.3.3-7+squeeze19), libmagic1, ucf, tzdata
        Depends: libbz2-1.0, libc6 (>= 2.11), libcomerr2 (>= 1.01), libdb4.8, libgssapi-krb5-2 (>= 1.6.dfsg.2), libk5crypto3 (>= 1.6.dfsg.2), libkrb5-3 (>= 1.6.dfsg.2), libonig2 (>= 5.2.0), libpcre3 (>= 7.7), libqdbm14 (>= 1.8.74), libssl0.9.8 (>= 0.9.8m-1), libxml2 (>= 2.7.4), zlib1g (>= 1:1.1.4), mime-support, apache2-mpm-prefork (>> 2.0.52) | apache2-mpm-itk, apache2.2-common, php5-common (= 5.3.3-7+squeeze23), libmagic1, ucf, tzdata
    

    Your manifest is installing php5, and that depends on apache. I got these versions/dependencies from Debian 6.0 but 12.04LTS will be similar