jenkins icon indicating copy to clipboard operation
jenkins copied to clipboard

Do not use `dpkg_autostart` for preventing Jenkins post install autostart

Open stuszynski opened this issue 7 years ago • 2 comments

Hi. I know it's a bit overkill but we step into the following issue a couple of days ago:

Cookbook version

5.0

Chef-client version

Chef: 12.17.44

Platform Details

Ubuntu 16.04.2 LTS

Scenario:

Current version of Jenkins cookbook is using a dpkg_autostart cookbook that, in fact, creates a /usr/sbin/policy-rc.d which breaks a default configuration of logrotate producing output to STDERR and makes cron ti send to us an alert each night when a postrotate occur (e.g. rsyslog )

The dpkg_autostart cookbook wasn't updated for about 2 years. I'm not sure if it still compatible with e.g. Ubuntu 16.04

Steps to Reproduce:

After installation from packages on ubuntu 16.04:

root@test:~# invoke-rc.d rsyslog rotate > /dev/null
invoke-rc.d: action rotate is unknown, but proceeding anyway.

Expected Result:

Find another way to prevent Jenkins to autostart after installation or manually control /usr/sbin/policy-rc.d file with compatibility for Ubuntu 16.04.

stuszynski avatar Apr 11 '17 17:04 stuszynski

Same here on Debian 8. This was added by @cheeseplus in commit: 36df55ff3ed95b617848138c00c4d028d4135b0d.

It's not clear to me from the commit message, what the actual issue was. I assume this avoids Jenkins starting up without our config / an additional restart of the service[jenkins]. Could this work also without dpkg_autostart? The template[/etc/default/jenkins] triggers an immediate restart.

StephenKing avatar Jun 23 '17 04:06 StephenKing

The dkpg_autostart cookbook is broken on Chef 16, which in turn makes this one unusable on Chef 16 as well:

================================================================================
Recipe Compile Error in /opt/kitchen/cache/cookbooks/omnibus/recipes/default.rb
================================================================================

NoMethodError
-------------
undefined method `dpkg_autostart' for cookbook: jenkins, recipe: _master_package :Chef::Recipe

Cookbook Trace:
---------------
  /opt/kitchen/cache/cookbooks/jenkins/recipes/_master_package.rb:35:in `from_file'
  /opt/kitchen/cache/cookbooks/jenkins/recipes/master.rb:31:in `from_file'
  /opt/kitchen/cache/cookbooks/omnibus/recipes/default.rb:51:in `from_file'

Relevant File Content:
----------------------
/opt/kitchen/cache/cookbooks/jenkins/recipes/_master_package.rb:

 28:    apt_repository 'jenkins' do
 29:      uri          node['jenkins']['master']['repository']
 30:      distribution 'binary/'
 31:      key          node['jenkins']['master']['repository_key']
 32:      keyserver    node['jenkins']['master']['repository_keyserver'] unless node['jenkins']['master']['repository_keyserver'].nil?
 33:    end
 34:
 35>>   dpkg_autostart 'jenkins' do
 36:      allow false
 37:    end
 38:  when 'rhel', 'amazon'
 39:    yum_repository 'jenkins-ci' do
 40:      baseurl node['jenkins']['master']['repository']
 41:      gpgkey  node['jenkins']['master']['repository_key']
 42:    end
 43:  end
 44:

System Info:
------------
chef_version=16.1.0
platform=ubuntu
platform_version=18.04
ruby=ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
program_name=/opt/chef/bin/chef-client
executable=/opt/chef/bin/chef-client

npmeyer avatar May 22 '20 21:05 npmeyer