Unable to solve a require statement

71 views
Skip to first unread message

Jochen Häberle

unread,
Mar 2, 2018, 7:56:46 AM3/2/18
to puppet...@googlegroups.com
Hi,

I am having a problem installing wp-cli alongside MySQL on Debian 9.3 using latest Puppet 5.4

I am using rotes and Profiles and in my wordpress.pp I have:

# WP-CLI
# TODO install latest wp-cli
file { 'php-wpcli_latest_all.deb':
path => '/tmp/php-wpcli_latest_all.deb',
ensure => 'file',
source => 'puppet:///modules/profile/wordpress/php-wpcli_1.5.0_all.deb',
}

package { 'wpcli':
provider => dpkg,
ensure => installed,
source => '/tmp/php-wpcli_latest_all.deb',
# require => File['php-wpcli_latest_all.deb'],
# require => Service['mysql'],
# require => Service['mysql'],
}

You see some of the require Statements I already tried ;-)

To install MySQL (or MariaDB) I am using puppetlabs/mysql module from the Forge. I am setting this up in a mysql Profile which I require in the former mentioned wordpress.pp.

In my node definition, I include mysql.pp before wordpress.pp

The error I get is the following (among similar ones):

Error: Execution of '/usr/bin/dpkg --force-confold -i /tmp/php-wpcli_latest_all.deb' returned 1: Selecting previously unselected package php-wpcli.
(Reading database ... 62113 files and directories currently installed.)
Preparing to unpack /tmp/php-wpcli_latest_all.deb ...
Unpacking php-wpcli (1.5.0) ...
dpkg: dependency problems prevent configuration of php-wpcli:
php-wpcli depends on mysql-client | mariadb-client; however:
Package mysql-client is not installed.
Package mariadb-client is not installed.

dpkg: error processing package php-wpcli (--install):
dependency problems - leaving unconfigured
Processing triggers for man-db (2.7.6.1-2) ...
Errors were encountered while processing:
php-wpcli
Error: /Stage[main]/Profile::Software::Wordpress/Package[wpcli]/ensure: change from 'purged' to 'present' failed: Execution of '/usr/bin/dpkg --force-confold -i /tmp/php-wpcli_latest_all.deb' returned 1: Selecting previously unselected package php-wpcli.
(Reading database ... 62113 files and directories currently installed.)
Preparing to unpack /tmp/php-wpcli_latest_all.deb ...
Unpacking php-wpcli (1.5.0) ...
dpkg: dependency problems prevent configuration of php-wpcli:
php-wpcli depends on mysql-client | mariadb-client; however:
Package mysql-client is not installed.
Package mariadb-client is not installed.

dpkg: error processing package php-wpcli (--install):
dependency problems - leaving unconfigured
Processing triggers for man-db (2.7.6.1-2) ...
Errors were encountered while processing:
php-wpcli


as I can install wp-cli using puppet when MySQL is already installed through puppet, this is clearly an issue of sequence. But I cannot find a way to solve this and to have MySQL installied before wp-cli.

Can anyone help me out, please?

Thanks, erhards

Jochen



P C Kroon

unread,
Mar 2, 2018, 5:06:10 PM3/2/18
to puppet...@googlegroups.com

Hi Jochen,

 

Try the following:

require => [File[‘php-wpcli_latest_all.deb’], Package[‘mysql-client’]],

 

HTH

Peter

--

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...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/19ADAF36-F85F-445E-AF5C-B59E47237BB8%40gmail.com.

For more options, visit https://groups.google.com/d/optout.

 

Jochen Haeberle

unread,
Mar 3, 2018, 4:43:45 PM3/3/18
to puppet...@googlegroups.com
Hi Peter,

Thanks for the tip. I tried that already, but it results in a

Error: Could not find resource 'Package[mysql-client]' in parameter 'require' (file: /etc/puppetlabs/code/environments/production/modules/profile/manifests/software/wordpress.pp, line: 26) on node stretch.localdomain

I tried to require my profile::mysql class, where it set up the mailserver using puppetlabs-mysql, but this does not help.

Thanks,
Jochen

P C Kroon

unread,
Mar 5, 2018, 3:20:16 PM3/5/18
to puppet...@googlegroups.com

Hi,

 

Make sure you have that module also install the MySQL client, and require mysql::client. I’m deliberately vague on the exact syntax since I’m not sure.

 

Peter

Jochen Haeberle

unread,
Mar 6, 2018, 3:48:34 AM3/6/18
to puppet...@googlegroups.com
Hi Peter,

The MySQL profile does indeed install the MySQL-client. But I can’t require it in the other profile class.

In class profile::software::wordpress I put  require profile::software::mysql, where I call the puppetlabs-mysql module to do the actual installation. Is there a better way to  describe the dependency?

Jochen

P C Kroon

unread,
Mar 6, 2018, 2:50:28 PM3/6/18
to puppet...@googlegroups.com

Hi Jochen,

 

I’m going to give this back to the rest of the list since I’m out of my depth, and I don’t have the time to figure out the details at the moment. Good luck though 😊

jcbollinger

unread,
Mar 7, 2018, 9:47:06 AM3/7/18
to Puppet Users


On Tuesday, March 6, 2018 at 1:50:28 PM UTC-6, P.C. Kroon wrote:

Hi Jochen,

 

I’m going to give this back to the rest of the list since I’m out of my depth, and I don’t have the time to figure out the details at the moment. Good luck though 😊


In the first place, since you are using dpkg instead of apt to install the DEB, and especially to the extent that you care which of the two alternative packages are used to satisfy the package dependency, your Package['wpcli'] should express a direct or indirect resource dependency on the MySQL client Package you want to use.  Since you're using puppetlabs-mysql, perhaps you want to depend on Class['::mysql::client'], but if you're wrapping that inside a profile (different from the one in which your problem occurs), then you should probably depend on the profile class instead.  As a matter of good form and style, however, you should not attempt to express relationships with resources managed by other classes, especially across module boundaries.

You may express an explicit relationship with the DEB File resource, too, but you do not need to do, because Puppet will automatically generate dependencies between Packages and their managed source files (see the "Autorequires" section in the resource type's documentation).

Thus, you might want something like this:

$debfile = '/tmp/php-wpcli_latest_all.deb'

file
{ "$debfile" :
 
ensure => 'file',
  source
=> 'puppet:///modules/profile/wordpress/php-wpcli_1.5.0_all.deb',
}

package { 'wpcli':
 
ensure   => 'installed',
  provider
=> 'dpkg',
  source  
=> "$debfile",
}

# 1. This assumes that you have a profile class '::profile::mysql_client' wrapping the PL
#    ::mysql::client class.  If not, then you could depend directly on
#    Class['::mysql::client'].
# 2. You could express this same relationship with a 'require' attribute, if you prefer.
Class['::profile::mysql_client'] -> Package['wpcli']


Note well that for the dependency on your profile class to work reliably, you need to ensure that the profile provides proper containment of the appropriate application class (e.g. ::mysql::client), which you would achieve via appropriate use of the contain function / statement.

Ultimately, what I'm describing as not very different from what Peter recommended.  It may be that I've hit on a key detail that he missed, but without more information about your manifest set, it's hard to confidently offer a solution.  If the above does not solve your problem, then I think it would behoove you to present a minimal yet complete example manifest set that reproduces the problem for you, primarily stripped-down versions of the manifests you and your organization wrote.  Supposing that you're using off-the-shelf puppetlabs-mysql, do not include any of its manifests, but do, please, tell us which version you are using.


John

Reply all
Reply to author
Forward
0 new messages