Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repo include doesn't always occur before install so need to run twice #10

Closed
serenapotts3 opened this issue Dec 23, 2014 · 4 comments
Closed

Comments

@serenapotts3
Copy link

When I run this module in puppet I get the following errors the first time I run:
==> pithos.dev: Error: Could not update: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold --force-yes install cassandra=2.0.10' returned 100: Reading package lists...
==> pithos.dev: Building dependency tree...
==> pithos.dev: Reading state information...
==> pithos.dev: E: Version '2.0.10' for 'cassandra' was not found
==> pithos.dev: Wrapped exception:
==> pithos.dev: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold --force-yes install cassandra=2.0.10' returned 100: Reading package lists...
==> pithos.dev: Building dependency tree...
==> pithos.dev: Reading state information...
==> pithos.dev: E: Version '2.0.10' for 'cassandra' was not found
==> pithos.dev: Error: /Stage[main]/Cassandra::Install/Package[dsc]/ensure: change from purged to 2.0.10 failed: Could not update: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold --force-yes install cassandra=2.0.10' returned 100: Reading package lists...
==> pithos.dev: Building dependency tree...
==> pithos.dev: Reading state information...
==> pithos.dev: E: Version '2.0.10' for 'cassandra' was not found
==> pithos.dev: Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install python-cql' returned 100: Reading package lists...
==> pithos.dev: Building dependency tree...
==> pithos.dev: Reading state information...
==> pithos.dev: E: Unable to locate package python-cql
==> pithos.dev: Error: /Stage[main]/Cassandra::Install/Package[python-cql]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install python-cql' returned 100: Reading package lists...
==> pithos.dev: Building dependency tree...
==> pithos.dev: Reading state information...
==> pithos.dev: E: Unable to locate package python-cql

It appears to repo include doesn't happen first as expected since the redhat or debian repo classes not having a contains relationship to the repo class.

https://docs.puppetlabs.com/puppet/latest/reference/lang_containment.html

One way to solve this is to use the anchor pattern. Have done this and raised a pull request with one possible solution which you could include. #9

If you are using > puppet 3.4 you can use the 'contain' keyword. for compatibility < puppet 3.4 there is the anchor containment pattern, which I see you have used already as well.

@msimonin
Copy link
Owner

msimonin commented Jan 9, 2015

Hi @serenakeating, could you tell me more about your use case.
Maybe can we have a look to your site.pp ?

@serenapotts3
Copy link
Author

Hi @msimonin, I was just trying to do a simple install of cassandra nothing too fancy. We are using it with Pithos (an S3 interface that runs on top of cassandra so hence the settings I need). Though I got this error initially and consistently, without even having any of these specific settings. To get it to run for us have had to make this change. I have the following in a .pp file

class xxx::cassandra (
$max_heap_size = '256m',
$heap_newsize = '64m',
$package_name = 'cassandra',
$start_native_transport = 'true',
$rpc_server_type = 'sync',
$version = '2.0.10',
$seeds,
$listen_address,
$rpc_address,
) {

class {'::cassandra':
max_heap_size => $max_heap_size,
heap_newsize => $heap_newsize,
package_name => $package_name,
start_native_transport => $start_native_transport,
rpc_server_type => $rpc_server_type,
seeds => $seeds,
listen_address => $listen_address,
rpc_address => $rpc_address,
version => $version,
}

anchor {'xxx::cassandra::begin': } -> Class['::cassandra'] -> anchor {'xxx::cassandra::end': }
}

@msimonin
Copy link
Owner

Thanks @serenakeating for raising the issue. I agree that repo installed has to be contained.
I'll merge your pr #9 if everything is fine with everyone here.

I just would like to be sure to reproduce correctly the issue :

Here are my files :

# /etc/puppet/modules/containment/manifests/init.pp
class containment (
  $max_heap_size = '256m',
  $heap_newsize = '64m',
  $package_name = 'cassandra',
  $start_native_transport = 'true',
  $rpc_server_type = 'sync',
  $version = '2.0.10',
  $seeds,
  $listen_address,
  $rpc_address,
) {

  class {'cassandra':
    max_heap_size          => $max_heap_size,
    heap_newsize           => $heap_newsize,
    package_name           => $package_name,
    start_native_transport => $start_native_transport,
    rpc_server_type        => $rpc_server_type,
    seeds                  => $seeds,
    listen_address         => $listen_address,
    rpc_address            => $rpc_address,
    version                => $version,
  }
}
# dummy test class which will be chained before cassandra
class ntp {
   package { 'ntp':
      ensure => installed
   }
}
# site.pp
node 'node1' {
  class { 'containment':
    seeds          => [ '192.168.100.2'],
    listen_address => "192.168.100.3",
    rpc_address => "192.168.100.3"
  }
  include 'ntp'

  Class['containment'] -> Class['ntp']
}

Output :

Notice: Compiled catalog for node1.localdomain in environment production in 0.78 seconds
Notice: /Stage[main]/Ntp/Package[ntp]/ensure: ensure changed 'purged' to 'present'
Notice: /Stage[main]/Cassandra::Repo::Debian/Apt::Pin[hold_cassandra_at_2.0.10]/File[hold_cassandra_at_2.0.10.pref]/ensure: created
Notice: /Stage[main]/Cassandra::Repo::Debian/Apt::Source[datastax]/Apt::Pin[datastax]/File[datastax.pref]/ensure: created
Notice: /Stage[main]/Cassandra::Repo::Debian/Apt::Source[datastax]/Apt::Key[Add key: B999A372 from Apt::Source datastax]/Apt_key[Add key: B999A372 from Apt::Source datastax]/ensure: created
Notice: /Stage[main]/Cassandra::Repo::Debian/Apt::Source[datastax]/File[datastax.list]/ensure: created

Here we can see that ntp package is installed before, that's the issue.

@msimonin
Copy link
Owner

As a follow up of the previous example. It seems that anchoring at the containment class level solve to issue as @serenakeating did.
I'm wondering if we need to anchor at the repo level as well as it is suggested in pr #9 ?

The containment class :

class containment{
...
anchor {'xxx::cassandra::begin': } -> Class['::cassandra'] -> anchor {'xxx::cassandra::end': }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants