I'd guess that installing new modules are restarting the service. You probably need something with better ordering.

class apache {
  contain ::apache::install
  contain ::apache::config
  contain ::apache::service
  Class['::apache::install'] ->
  Class['::apache::config'] ~>
  Class['::apache::config']
}
class apache::install {
  package { 'libapache2-mpm-itk':
    ensure => latest,
  }
  package { 'apache2':
    ensure => latest,
  }
  # etc etc
}
class apache::config {
  file { '/etc/apache2/ports.conf':
    ensure  => file,
    content => "Listen 8080\n",
  }
}
class apache::service {
  service { 'apache':
    ensure => running
    enable => true,
  }
}
class nginx {
  package { 'nginx-light':
    ensure => latest,
  }
}
class profile::webstack {
  include ::apache
  include ::nginx
  Class['::apache'] -> Class['nginx']
}

On 5/13/17 2:45 AM, Anton Gorlov wrote:
Hi.

I need stop service (apache) after it install from puppet.
platform is debian 9 and puppet version is 4.8.2

I my class i wrote:

========
class webpackages {

exec { 'apachechk':
        command => "/bin/systemctl stop apache2;",
        onlyif => "/bin/grep -c 'Listen 80' /etc/apache2/ports.conf",
}

package { 'libapache2-mpm-itk':
ensure => latest,
   }

package { 'apache2':
require => Exec['apachechk'],
ensure => latest,
   }

package { 'apache2-dev':
ensure => latest,
   }
package { 'apache2-suexec-pristine':
ensure => latest,
   }
package { 'apache2-utils':
ensure => latest,
   }
package { 'apache2-bin':
ensure => latest,
   }
package { 'apachetop':
ensure => latest,
   }
package { 'libapache2-mod-rpaf':
ensure => latest,
   }
package { 'nginx-light':
require => Exec['apachechk'],
ensure => latest,
        }

}
===

but apache not stopping and install nginx is fail because port is busy
by apache

May 13 12:21:29 debian9-lab3 nginx[19538]: nginx: [emerg] listen() to
[::]:8…se)
May 13 12:21:29 debian9-lab3 nginx[19538]: nginx: [emerg] listen() to
0.0.0.…se)
May 13 12:21:29 debian9-lab3 nginx[19538]: nginx: [emerg] listen() to
[::]:8…se)
May 13 12:21:30 debian9-lab3 nginx[19538]: nginx: [emerg] listen() to
0.0.0.…se)
May 13 12:21:30 debian9-lab3 nginx[19538]: nginx: [emerg] listen() to
[::]:8…se)
May 13 12:21:30 debian9-lab3 nginx[19538]: nginx: [emerg] still could
not bind()

What is wrong and what is right way to do it?


--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/1da0051d-a3d1-6472-2ad6-3af335f7503a%40badapple.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to