Mindera / pm2-cookbook

Chef cookbook to install and manage PM2.
MIT License
23 stars 17 forks source link

pm2::default #13

Closed naumchenko closed 9 years ago

naumchenko commented 9 years ago

Recipe pm2::default keeps re-installing pm2 even if its installed on each Chef run, what is the proper way to make it skip if package already installed?

Cheers,

joaogbcravo commented 9 years ago

Hey @naumchenko,

We are forcing the re-installation when we define version = "latest" at https://github.com/Mindera/pm2-cookbook/blob/master/attributes/default.rb

If you want to avoid this reinstallation please override that attribute with a specific version like "0.14.7" on your role, environment, cookbook wrapper, or anything else that you are using to call the cookbook.

Let us know if you have any other problem.

Cheers, João

naumchenko commented 9 years ago

Still getting it re-installed even if version is pinned in attributes in wrapper:

Recipe: pm2::default

Kitchen:

platforms:

Chef: 12.4.1

Sincerely,

On Tue, Sep 15, 2015 at 10:24 AM, joaogbcravo notifications@github.com wrote:

Hey @naumchenko https://github.com/naumchenko,

We are forcing the re-installation when we define version = "latest" at https://github.com/Mindera/pm2-cookbook/blob/master/attributes/default.rb

If you want to avoid this reinstallation please override that attribute with a specific version like "0.14.7" on your role, environment, cookbook wrapper, or anything else that you are using to call the cookbook.

Let us know if you have any other problem.

Cheers, João

— Reply to this email directly or view it on GitHub https://github.com/Mindera/pm2-cookbook/issues/13#issuecomment-140409122 .

Alex Naumchenko Email: alex@devloft.com Cell: (514) 792-9939

joaogbcravo commented 9 years ago

Hey,

Did you run converge again? The first time that you run kitchen converge it shows

Recipe: pm2::default
             - execute npm install  -global pm2@0.12.15

But in the second time it shows:

Recipe: pm2::default

        (skipped due to not_if)
            (up to date)

With "--log-level debug" we can see:

       Recipe: pm2::default
         * nodejs_npm[pm2] action install[2015-09-15T15:45:56+00:00] INFO: Processing nodejs_npm[pm2] action install (pm2::default line 15)
       [2015-09-15T15:45:56+00:00] DEBUG: Providers for generic nodejs_npm resource enabled on node include: [LWRP provider nodejs_npm from cookbook nodejs]
       [2015-09-15T15:45:56+00:00] DEBUG: Provider for action install on resource nodejs_npm[pm2] is LWRP provider nodejs_npm from cookbook nodejs
       [2015-09-15T15:45:56+00:00] DEBUG: Loading Recipe nodejs::npm via include_recipe
       [2015-09-15T15:45:56+00:00] DEBUG: I am not loading nodejs::npm, because I have already seen it.
       [2015-09-15T15:45:56+00:00] DEBUG: Resources for generic execute resource enabled on node include: [Chef::Resource::Execute]
       [2015-09-15T15:45:56+00:00] DEBUG: Resource for execute is Chef::Resource::Execute

       [2015-09-15T15:45:56+00:00] INFO: Processing execute[install NPM package pm2] action run (/tmp/kitchen/cookbooks/nodejs/providers/npm.rb line 6)
        (skipped due to not_if)
       [2015-09-15T15:45:57+00:00] DEBUG: Skipping execute[install NPM package pm2] due to not_if ruby block
            (up to date)

Are you able to check this?

Cheers

naumchenko commented 9 years ago

On consecutive runs, I am still getting it re-installed, platform centos-6.4, I haven't tested it with any 7.x+, what platform "skip if installed" works for you?

 Recipe: pm2::default
     * nodejs_npm[pm2] action install
         - execute npm install  -global pm2@0.12.15

Please advise,

Cheers,

joaogbcravo commented 9 years ago

Yes, I'm using Centos-6.6, but I guess that shouldn't be the minor version that makes it different.

I'm on gitter. If you want to talk with me in a fast way contact me there (https://gitter.im/joaogbcravo) and we can try resolve this.

naumchenko commented 9 years ago

It keeps re-installing the pm2 package, I suspect helper to check if package already installed is not properly called or something. Cloned your cookbook, on every recur chef run it executes pm2 install.

*[master][~/dev/cookbooks/pm2-cookbook]> kitchen converge rvm:ruby-2.2.0 -----> Starting Kitchen (v1.4.2) -----> Converging ... Preparing files for transfer Preparing dna.json Resolving cookbook dependencies with Berkshelf 3.3.0... Removing non-cookbook files before transfer Preparing solo.rb -----> Chef Omnibus installation detected (install only if missing) Transferring files to Starting Chef Client, version 12.4.1 Compiling Cookbooks... Converging 13 resources Recipe: yum-epel::default

    (up to date)
       * execute[yum clean epel] action nothing (skipped due to action :nothing)
       * execute[yum-makecache-epel] action nothing (skipped due to action :nothing)
       * ruby_block[yum-cache-reload-epel] action nothing (skipped due to action :nothing)
        (up to date)
   Recipe: nodejs::nodejs_from_package
    (up to date)
     * yum_package[nodejs-devel] action install (up to date)
     * yum_package[npm] action install (up to date)
   Recipe: pm2::default

         - execute npm install  -global pm2@0.14.7

   Recipe: pm2_application::default
    (up to date)
     * user[nodeuserwithpm2home] action create (up to date)
    (up to date)
    (up to date)
    (up to date)
     * pm2_application[test] action deploy
    (up to date)
    (up to date)
        (up to date)

         - execute pm2 startup centos -u root

     * pm2_application[test_w_user_w_pm2_home] action deploy
       * directory[/etc/pm2/conf.d] action create (up to date)
    (up to date)
        (up to date)

         - execute pm2 startOrReload /etc/pm2/conf.d/test_w_user_w_pm2_home.json

     * pm2_application[test_w_user_w_pm2_home] action startup

         - execute pm2 startup centos -u nodeuserwithpm2home

    (up to date)
    (up to date)
        (up to date)
     * pm2_application[test_w_user] action start_or_reload

         - execute pm2 startOrReload /etc/pm2/conf.d/test_w_user.json

         - execute pm2 startup centos -u nodeuser

   Running handlers:
   Running handlers complete
   Chef Client finished, 14/33 resources updated in 22.413793799 seconds
   Finished converging <default-centos-66> (0m25.91s).

-----> Kitchen is finished. (0m27.15s) zlib(finalizer): the stream was freed prematurely. *[master][~/dev/cookbooks/pm2-cookbook]>

miguelcnf commented 8 years ago

Hi @naumchenko,

Not sure if you spoke with @joaogbcravo in the meantime but we delegate the pm2 node module installation to the nodejs_npm resource in the nodejs cookbook.

IIRC npm doesn't implement this feature but the nodejs cookbook try to work around it with a resource check and by checking npm list - anyway if you really need this to be fixed I suggest you try and open an issue with the nodejs cookbook.

Miguel

naumchenko commented 8 years ago

@joaogbcravo confirms it works for him, in kitchen. @miguelcnf can you confirm you stumble on this too? helper that checks current version is in pm2 cookbook?

miguelcnf commented 8 years ago

The helper is in the nodejs cookbook.

From what I remember when I wrote this it would skip the installation after the first run but I haven't tested it now.