Giter Club home page Giter Club logo

Comments (8)

shaunrampersad avatar shaunrampersad commented on September 25, 2024 1

@alexjfisher

Can you confirm what version of puppet you're using?

Puppet v4.6.2. This problem occurred recently, so it might just be something that's changed from v4.6.1 to v4.6.2. I will try to confirm when we upgraded puppet.
We use puppet in Userspace so this process is confined to /opt/${::jboss::user} and runs as the jboss user.

Are you using the target parameter too? Is there anymore you can share?

I'm making use of the staging module within a custom jboss module. We do not manage the $staging_dir in the jboss module and leave this to the staging module.

This is the code where we make use of the staging resources

  class { '::staging':
    path  => "/opt/${::jboss::user}/.staging",
    mode  => '0700',
    owner => $::jboss::user,
    group => $::jboss::group,
  }

  if $jboss::cumulative_patch_version != 'UNSET' {
    staging::file { "jboss-${::jboss::cumulative_patch_version}-patch.zip":
      source => "${::jboss::download_url}/jboss-${::jboss::cumulative_patch_version}-patch.zip",
    }
  }

  staging::file { "jboss-${::jboss::version}.zip":
    source => "${::jboss::download_url}/jboss-${::jboss::version}.zip",
  } ->

  staging::extract { "jboss-${::jboss::version}.zip":
    target  => "/opt/${::jboss::user}",
    creates => "/opt/${::jboss::user}/jboss-${::jboss::version}/version.txt",
    require => Staging::File["jboss-${::jboss::version}.zip"],
  } 

Values for above are as follows:

${::jboss::download_url} = http://x.x.x.x/jboss
${::jboss::cumulative_patch_version} = 'eap-6.4.6'
${::jboss::version} = 'eap-6.3'
${::jboss::user} = 'jboss4'
$::jboss::group = 'jboss4'

from puppet-staging.

alexjfisher avatar alexjfisher commented on September 25, 2024 1

It's actually really easy to reproduce something similar (perhaps not exactly the same issue), but I can get a duplicate resource error in a single line...

puppet apply -e 'staging::file { "master.zip": source => "https://github.com/voxpupuli/puppet-staging/archive/master.zip"}'
Notice: Compiled catalog for alex-virtualbox.ordsvy.gov.uk in environment production in 0.30 seconds
Error: Cannot alias File[/opt/staging/] to ["/opt/staging"] at /home/alex/.puppetlabs/etc/code/modules/staging/manifests/file.pp:40; resource ["File", "/opt/staging"] already declared at /home/alex/.puppetlabs/etc/code/modules/staging/manifests/init.pp:23

@shaunrampersad Your code where you call staging from? Is it in a module? If not, $caller_module_name (and $subdir) will be an empty string.

$staging_dir = "${staging::path}/${subdir}" will then result in a directory path that ends with a / and is the same directory as already declared in init.pp. The if !defined won't trigger as the title of the resource in init.pp won't have the trailing /.

This shouldn't be too hard to fix. Meanwhile, if you explicitly set $subdir, I think your problem will go away. You might also consider migrating to puppet-archive. I think this is the preferred module for downloading stuff these days.

from puppet-staging.

alexjfisher avatar alexjfisher commented on September 25, 2024

@shaunrampersad That's quite odd. I can't quite see why if ! defined wouldn't work (and presumably it does for most people??). ensure_resources, on the other hand, can lead to duplicate resources in situations where the resource has been declared previously but with different parameters (probably not common, but some users may have done this in their profiles - perhaps to set group or mode perhaps??)

Can you confirm what version of puppet you're using?

from puppet-staging.

Cinderhaze avatar Cinderhaze commented on September 25, 2024

I have seen a similar issue.. if the 'if ! defined' happens before your other code not wrapped in an if ! defined is executed, there will be conflicts. (I have seen the same behavior with ensure_resources). @shaunrampersad do you have a regular file resource in your catalog for that folder, or is it only created via staging?

from puppet-staging.

alexjfisher avatar alexjfisher commented on September 25, 2024

@Cinderhaze That does happen, but the error message suggests it's two instances of the same defined type conflicting. That I don't understand...

is already declared in file /etc/puppetlabs/code/environments/jboss_master/modules/staging/manifests/file.pp:39; cannot redeclare at /etc/puppetlabs/code/environments/jboss_master/modules/staging/manifests/file.pp:39

from puppet-staging.

bastelfreak avatar bastelfreak commented on September 25, 2024

@shaunrampersad can you tell us the value of ::jboss::version and ::jboss::download_url?

from puppet-staging.

alexjfisher avatar alexjfisher commented on September 25, 2024

I suspect that for some reason two values of $staging_dir aren't the same string, but refer to the same path. ie (/tmp/staging and /tmp/staging/) That would fool defined, but not the type for file which will munge the paths to be the same.

@shaunrampersad Are you using the target parameter too? Is there anymore you can share?

from puppet-staging.

shaunrampersad avatar shaunrampersad commented on September 25, 2024

@alexjfisher , I'm calling the staging module from within my jboss module.
Will look into migrating to puppet-archive. thanks!

from puppet-staging.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.