1

I am using chef for provisioning a vpn-server in my infrastructure. Below is the code which is used to install few components of libreswan-ipsec vpn.

%w( libnss3-dev libnspr4-dev pkg-config libpam0g-dev libcap-ng-dev
    libcap-ng-utils libselinux1-dev libcurl4-nss-dev libgmp3-dev
    flex bison gcc make libunbound-dev libnss3-tools wget vim traceroute ).each do |pkg|
      package pkg do
        action :install
      end
    end

Now I need to add more components to this list for installation however I need to install them to after all above components are install. Below is the code for those 2 packages for installations.

%w( libevent-dev xmlto ).each do |pkg|
      package pkg do
        action :install
      end
    end

But when I run recipe it takes all of them together and installs and breaks things on server on debian package manager. Basically all I want is to fix the installation flow cause when I install those packages manually, it works. how can i achieve this? Below is log of package manager which is broken now.

[2016-12-26T15:59:11+00:00] INFO: Starting Chef Run for ip-10-0-10-19
[2016-12-26T15:59:11+00:00] INFO: Running start handlers
[2016-12-26T15:59:11+00:00] INFO: Start handlers complete.
[2016-12-26T15:59:11+00:00] INFO: Application light-weight resource already initialized -- overriding!
[2016-12-26T15:59:11+00:00] INFO: Preparing removal of dependency: dpkg landscape-common
[2016-12-26T15:59:11+00:00] INFO: Preparing removal of dependency: dpkg landscape-client
[2016-12-26T15:59:11+00:00] INFO: Preparing removal of dependency: dpkg popularity-contest
[2016-12-26T15:59:11+00:00] INFO: Preparing installation of dependency: dpkg htop
[2016-12-26T15:59:11+00:00] INFO: Preparing installation of dependency: dpkg lynx
[2016-12-26T15:59:11+00:00] INFO: Preparing installation of dependency: dpkg vim-nox
[2016-12-26T15:59:11+00:00] INFO: Preparing installation of dependency: dpkg git
[2016-12-26T15:59:11+00:00] INFO: Preparing installation of dependency: dpkg curl
[2016-12-26T15:59:11+00:00] INFO: Preparing installation of dependency: dpkg libcurl3-dev
[2016-12-26T15:59:11+00:00] INFO: Preparing installation of dependency: dpkg tree
[2016-12-26T15:59:11+00:00] INFO: Preparing installation of dependency: dpkg screen
[2016-12-26T15:59:11+00:00] INFO: Preparing installation of dependency: dpkg traceroute
[2016-12-26T15:59:12+00:00] INFO: Preparing installation of dependency: dpkg libpq-dev
[2016-12-26T15:59:12+00:00] INFO: Preparing installation of dependency: gem bundler
[2016-12-26T15:59:12+00:00] INFO: Preparing installation of dependency: gem ruby-shadow
[2016-12-26T15:59:12+00:00] INFO: Preparing installation of dependency: gem pg
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for service[postfix] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous service[postfix]: /var/chef/vendor/cookbooks/postfix/recipes/default.rb:30:in `from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  service[postfix]: /var/chef/vendor/cookbooks/postfix/recipes/default.rb:63:in `from_file'
[2016-12-26T15:59:12+00:00] WARN: require_recipe is deprecated and will be removed in a future release, please use include_recipe
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for group[sudo] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous group[sudo]: /var/chef/vendor/cookbooks/user/recipes/data_bag.rb:46:in `block (2 levels) in from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  group[sudo]: /var/chef/vendor/cookbooks/user/recipes/data_bag.rb:46:in `block (2 levels) in from_file'
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for group[sudo] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous group[sudo]: /var/chef/vendor/cookbooks/user/recipes/data_bag.rb:46:in `block (2 levels) in from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  group[sudo]: /var/chef/vendor/cookbooks/user/recipes/data_bag.rb:46:in `block (2 levels) in from_file'
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for group[sudo] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous group[sudo]: /var/chef/vendor/cookbooks/user/recipes/data_bag.rb:46:in `block (2 levels) in from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  group[sudo]: /var/chef/vendor/cookbooks/user/recipes/data_bag.rb:46:in `block (2 levels) in from_file'
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for group[sudo] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous group[sudo]: /var/chef/vendor/cookbooks/user/recipes/data_bag.rb:46:in `block (2 levels) in from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  group[sudo]: /var/chef/vendor/cookbooks/user/recipes/data_bag.rb:46:in `block (2 levels) in from_file'
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for group[sudo] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous group[sudo]: /var/chef/vendor/cookbooks/user/recipes/data_bag.rb:46:in `block (2 levels) in from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  group[sudo]: /var/chef/vendor/cookbooks/user/recipes/data_bag.rb:46:in `block (2 levels) in from_file'
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for group[sudo] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous group[sudo]: /var/chef/vendor/cookbooks/user/recipes/data_bag.rb:46:in `block (2 levels) in from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  group[sudo]: /var/chef/vendor/cookbooks/user/recipes/data_bag.rb:46:in `block (2 levels) in from_file'
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for group[sudo] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous group[sudo]: /var/chef/vendor/cookbooks/user/recipes/data_bag.rb:46:in `block (2 levels) in from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  group[sudo]: /var/chef/vendor/cookbooks/user/recipes/data_bag.rb:46:in `block (2 levels) in from_file'
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for package[vim-nox] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous package[vim-nox]: /var/chef/cookbooks/initial_setup/recipes/install_packages.rb:3:in `block in from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  package[vim-nox]: /var/chef/cookbooks/vim/recipes/default.rb:29:in `from_file'
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for directory[/etc/logstash] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous directory[/etc/logstash]: /var/chef/cookbooks/logstash/recipes/default.rb:24:in `from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  directory[/etc/logstash]: /var/chef/cookbooks/logstash/definitions/logstash_file.rb:8:in `block in from_file'
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for service[logstash] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous service[logstash]: /var/chef/cookbooks/logstash/definitions/logstash_file.rb:3:in `block in from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  service[logstash]: /var/chef/cookbooks/logstash/recipes/shipper.rb:18:in `from_file'
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for package[wget] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous package[wget]: /var/chef/cookbooks/newrelic/recipes/default.rb:1:in `from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  package[wget]: /var/chef/cookbooks/ipsec/recipes/default.rb:18:in `block in from_file'
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for package[traceroute] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous package[traceroute]: /var/chef/cookbooks/initial_setup/recipes/install_packages.rb:3:in `block in from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  package[traceroute]: /var/chef/cookbooks/ipsec/recipes/default.rb:18:in `block in from_file'
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for service[ipsec] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous service[ipsec]: /var/chef/cookbooks/ipsec/recipes/default.rb:9:in `from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  service[ipsec]: /var/chef/cookbooks/karma_ipsec/recipes/default.rb:4:in `from_file'
[2016-12-26T15:59:12+00:00] INFO: ohai plugins will be at: /etc/chef/ohai_plugins
[2016-12-26T15:59:12+00:00] INFO: Processing remote_directory[/etc/chef/ohai_plugins] action create (ohai::default line 30)
[2016-12-26T15:59:12+00:00] INFO: Processing cookbook_file[/etc/chef/ohai_plugins/README] action create (dynamically defined)
[2016-12-26T15:59:12+00:00] INFO: Processing ohai[custom_plugins] action reload (ohai::default line 44)
[2016-12-26T15:59:12+00:00] INFO: ohai[custom_plugins] reloaded
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for service[nginx] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous service[nginx]: /var/chef/vendor/cookbooks/nginx/recipes/default.rb:42:in `from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  service[nginx]: /var/chef/vendor/cookbooks/nginx/recipes/default.rb:54:in `from_file'
[2016-12-26T15:59:12+00:00] WARN: Cloning resource attributes for service[nginx] from prior resource (CHEF-3694)
[2016-12-26T15:59:12+00:00] WARN: Previous service[nginx]: /var/chef/vendor/cookbooks/nginx/recipes/default.rb:54:in `from_file'
[2016-12-26T15:59:12+00:00] WARN: Current  service[nginx]: /var/chef/cookbooks/karma_dante/recipes/default.rb:17:in `from_file'
[2016-12-26T15:59:12+00:00] INFO: Processing execute[apt-get-update] action run (apt::default line 22)
[2016-12-26T15:59:12+00:00] INFO: Processing execute[apt-get update] action nothing (apt::default line 29)
[2016-12-26T15:59:12+00:00] INFO: Processing execute[apt-get autoremove] action nothing (apt::default line 36)
[2016-12-26T15:59:12+00:00] INFO: Processing execute[apt-get autoclean] action nothing (apt::default line 42)
[2016-12-26T15:59:12+00:00] INFO: Processing package[update-notifier-common] action install (apt::default line 48)
[2016-12-26T15:59:12+00:00] INFO: Processing execute[apt-get-update-periodic] action run (apt::default line 52)
[2016-12-26T15:59:12+00:00] INFO: Processing directory[/var/cache/local] action create (apt::default line 62)
[2016-12-26T15:59:12+00:00] INFO: Processing directory[/var/cache/local/preseeding] action create (apt::default line 62)
[2016-12-26T15:59:12+00:00] INFO: Processing package[landscape-common] action purge (initial_setup::remove_packages line 3)
[2016-12-26T15:59:12+00:00] INFO: Processing package[landscape-client] action purge (initial_setup::remove_packages line 3)
[2016-12-26T15:59:12+00:00] INFO: Processing package[popularity-contest] action purge (initial_setup::remove_packages line 3)
[2016-12-26T15:59:12+00:00] INFO: Processing package[htop] action install (initial_setup::install_packages line 3)
[2016-12-26T15:59:12+00:00] INFO: Processing package[lynx] action install (initial_setup::install_packages line 3)
[2016-12-26T15:59:12+00:00] INFO: Processing package[vim-nox] action install (initial_setup::install_packages line 3)
[2016-12-26T15:59:12+00:00] INFO: Processing package[git] action install (initial_setup::install_packages line 3)
[2016-12-26T15:59:12+00:00] INFO: Processing package[curl] action install (initial_setup::install_packages line 3)
[2016-12-26T15:59:12+00:00] INFO: Processing package[libcurl3-dev] action install (initial_setup::install_packages line 3)
[2016-12-26T15:59:13+00:00] INFO: package[libcurl3-dev] is a virtual package, actually acting on package[libcurl4-openssl-dev]

================================================================================
Error executing action `install` on resource 'package[libcurl3-dev]'
================================================================================

Chef::Exceptions::Exec
----------------------
apt-get -q -y install libcurl3-dev returned 100, expected 0

Resource Declaration:
---------------------
# In /var/chef/cookbooks/initial_setup/recipes/install_packages.rb

  3:   package pkg do
  4:     action :install
  5:   end
  6: end

Compiled Resource:
------------------
# Declared in /var/chef/cookbooks/initial_setup/recipes/install_packages.rb:3:in `block in from_file'

package("libcurl3-dev") do
  action [:install]
  retries 0
  retry_delay 2
  package_name "libcurl3-dev"
  version "7.35.0-1ubuntu2.10"
  cookbook_name :initial_setup
  recipe_name "install_packages"
end

[2016-12-26T15:59:15+00:00] ERROR: Running exception handlers
[2016-12-26T15:59:15+00:00] ERROR: Exception handlers complete
[2016-12-26T15:59:15+00:00] FATAL: Stacktrace dumped to /var/cache/chef-solo/chef-stacktrace.out
[2016-12-26T15:59:15+00:00] FATAL: Chef::Exceptions::Exec: package[libcurl3-dev] (initial_setup::install_packages line 3) had an error: Chef::Exceptions::Exec: apt-get -q -y install libcurl3-dev returned 100, expected 0
ssutar@i-production-base:~$ sudo apt-get -q -y install libcurl3-dev 
Reading package lists...
Building dependency tree...
Reading state information...
libcurl4-openssl-dev is already the newest version.
The following package was automatically installed and is no longer required:
  libcurl3-nss
Use 'apt-get autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 96 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up dante-server (1.4.1-1) ...
Starting Dante SOCKS daemon: invoke-rc.d: initscript danted, action "start" failed.
dpkg: error processing package dante-server (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 dante-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
ssutar@i-production-base:~$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  libcurl3-nss
0 upgraded, 0 newly installed, 1 to remove and 96 not upgraded.
1 not fully installed or removed.
After this operation, 563 kB disk space will be freed.
Do you want to continue? [Y/n] 
(Reading database ... 97703 files and directories currently installed.)
Removing libcurl3-nss:amd64 (7.35.0-1ubuntu2.10) ...
Processing triggers for libc-bin (2.19-0ubuntu6.9) ...
Setting up dante-server (1.4.1-1) ...
Starting Dante SOCKS daemon: invoke-rc.d: initscript danted, action "start" failed.
dpkg: error processing package dante-server (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 dante-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
ssutar@i-production-base:~$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 96 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up dante-server (1.4.1-1) ...
Starting Dante SOCKS daemon: invoke-rc.d: initscript danted, action "start" failed.
dpkg: error processing package dante-server (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 dante-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
Shailesh Sutar
  • 1,517
  • 5
  • 23
  • 41
  • apt should be able to arrange the proper ordering. What do you mean by "breaks things on server on debian package manager?" Please post exact log messages rather than an interpretation. – Mark Wagner Dec 30 '16 at 00:05

1 Answers1

1

If apt does not handle the ordering one option would be to create separate install recipes/files with the individual packages, then use include_recipe with appropriate depends statements as mentioned in this answer

Matt
  • 2,751
  • 1
  • 14
  • 20