Skip to content

cookbook does not install requested version if package & repo for a different version already present #201

@jayhendren

Description

@jayhendren

Cookbook version

6.0.0

Chef-client version

14.2.0

Platform Details

RHEL 7

Scenario:

If a system already has a node.js repository and nodejs package installed that are different from the version specified in the node['nodejs']['version'] attribute, then the nodejs cookbook will not update the package to the requested version.

Steps to Reproduce:

recipes/default.rb:

include_recipe 'nodejs'

attributes.rb:

override['nodejs']['version'] = '10.15.3'
override['nodejs']['repo'] = 'https://rpm.nodesource.com/pub_10.x/el/7/$basearch'
┌─[jay@bluejay] - [~/Work/git/cookbooks/cub_nodejs] - [2019-05-17 04:04:21]
└─[0] <git:(master 7a9f10c✱) > kitchen login
X11 forwarding request failed on channel 0
Last login: Fri May 17 16:04:44 2019 from 10.0.2.2
[vagrant@testkitchen-cub-rh7 ~]$ node --version
v6.17.1
[vagrant@testkitchen-cub-rh7 ~]$ which node
/usr/bin/node
[vagrant@testkitchen-cub-rh7 ~]$ cat /etc/yum.repos.d/
node.js.repo  redhat.repo   
[vagrant@testkitchen-cub-rh7 ~]$ cat /etc/yum.repos.d/node.js.repo 
# This file was generated by Chef
# Do NOT modify this file by hand.

[node.js]
name=nodesource.com nodejs repository
baseurl=https://rpm.nodesource.com/pub_6.x/el/7/$basearch
enabled=1
fastestmirror_enabled=0
gpgcheck=1
gpgkey=https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
[vagrant@testkitchen-cub-rh7 ~]$ exit
logout
Connection to 127.0.0.1 closed.
┌─[jay@bluejay] - [~/Work/git/cookbooks/cub_nodejs] - [2019-05-17 04:06:01]
└─[0] <git:(master 7a9f10c✱) > kitchen converge
-----> Starting Kitchen (v1.22.0)
-----> Converging <default-cub-rh7>...
       Preparing files for transfer
       Installing cookbooks for Policyfile /home/jay/Work/git/cookbooks/cub_nodejs/Policyfile.rb using `chef install`
       Installing cookbooks from lock
       Using      ark             4.0.0
       Using      build-essential 8.2.1
       Installing cub_nodejs      0.2.2
       Using      mingw           2.1.0
       Using      nodejs          6.0.0
       Using      seven_zip       3.1.0
       Using      windows         6.0.0
       Preparing dna.json
       Exporting cookbook dependencies from Policyfile /tmp/default-cub-rh7-sandbox-20190517-16042-1hp86sm...
       Exported policy 'cub_nodejs' to /tmp/default-cub-rh7-sandbox-20190517-16042-1hp86sm
       
       To converge this system with the exported policy, run:
         cd /tmp/default-cub-rh7-sandbox-20190517-16042-1hp86sm
         chef-client -z
       Removing non-cookbook files before transfer
       Preparing data_bags
       Preparing validation.pem
       Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)
       Transferring files to <default-cub-rh7>
       Starting Chef Client, version 14.2.0
       Using policy 'cub_nodejs' at revision '968566b5560677e29e9642bdfb2ae071197de697e26645bed2ac7436f8eedfea'
       resolving cookbooks for run list: ["cub_nodejs::default@0.2.2 (cf42f71)"]
       Synchronizing Cookbooks:
         - build-essential (8.2.1)
         - ark (4.0.0)
         - mingw (2.1.0)
         - nodejs (6.0.0)
         - seven_zip (3.1.0)
         - windows (6.0.0)
         - cub_nodejs (0.2.2)
       Installing Cookbook Gems:
       Compiling Cookbooks...
       Converging 3 resources
       Recipe: nodejs::repo
         * yum_repository[node.js] action create
           * template[/etc/yum.repos.d/node.js.repo] action create
             - update content in file /etc/yum.repos.d/node.js.repo from 1682d2 to 68337c
             --- /etc/yum.repos.d/node.js.repo	2019-05-17 17:02:51.555989589 -0600
             +++ /etc/yum.repos.d/.chef-node20190517-6951-158ifma.js.repo	2019-05-17 17:06:40.829953132 -0600
             @@ -3,7 +3,7 @@
       
       [node.js]
       name=nodesource.com nodejs repository
             -baseurl=https://rpm.nodesource.com/pub_6.x/el/7/$basearch
             +baseurl=https://rpm.nodesource.com/pub_10.x/el/7/$basearch
       enabled=1
       fastestmirror_enabled=0
       gpgcheck=1
             - restore selinux security context
           * execute[yum clean metadata node.js] action run
             - execute yum clean metadata --disablerepo=* --enablerepo=node.js
           * execute[yum-makecache-node.js] action run
             - execute yum -q -y makecache --disablerepo=* --enablerepo=node.js
           * ruby_block[package-cache-reload-node.js] action create
             - execute the ruby block package-cache-reload-node.js
           * execute[yum clean metadata node.js] action nothing (skipped due to action :nothing)
           * execute[yum-makecache-node.js] action nothing (skipped due to action :nothing)
           * ruby_block[package-cache-reload-node.js] action nothing (skipped due to action :nothing)
         
       Recipe: nodejs::nodejs_from_package
         * yum_package[nodejs] action install (up to date)
         * yum_package[nodejs-devel] action install (up to date)
       
       Running handlers:
       Running handlers complete
       Chef Client finished, 5/10 resources updated in 08 seconds
       Downloading files from <default-cub-rh7>
       Finished converging <default-cub-rh7> (0m13.70s).
-----> Kitchen is finished. (0m13.94s)
┌─[jay@bluejay] - [~/Work/git/cookbooks/cub_nodejs] - [2019-05-17 04:07:57]
└─[0] <git:(master 7a9f10c✱) > kitchen login
X11 forwarding request failed on channel 0
Last login: Fri May 17 16:06:37 2019 from 10.0.2.2
[vagrant@testkitchen-cub-rh7 ~]$ which node
/usr/bin/node
[vagrant@testkitchen-cub-rh7 ~]$ node --version
v6.17.1
[vagrant@testkitchen-cub-rh7 ~]$ cat /etc/yum.repos.d/node.js.repo 
# This file was generated by Chef
# Do NOT modify this file by hand.

[node.js]
name=nodesource.com nodejs repository
baseurl=https://rpm.nodesource.com/pub_10.x/el/7/$basearch
enabled=1
fastestmirror_enabled=0
gpgcheck=1
gpgkey=https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
[vagrant@testkitchen-cub-rh7 ~]$ exit
logout
Connection to 127.0.0.1 closed.

Expected Result:

nodejs cookbook upgrades node to the specified package version.

Actual Result:

nodejs cookbook does not upgrade node.

Metadata

Metadata

Assignees

Labels

Priority: MediumWill bring visible benefit to the project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions