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

Update RVM to use custom resources #414

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

damacus
Copy link
Member

@damacus damacus commented Jan 26, 2022

Description

  • Rename test cookbook to test
  • Testing Updates
    • Remove test users databag
  • Remove Foodcritic config
    • Foodcritic has been replace by Cookstyle
  • Require Chef 15.3 for unified_mode and Chef 18 support
  • Move the vagrant recipe to the test cookbook
    • This recipe this is only for testing
  • Move all recipes to resource
    • This allows us to use unifed_mode for install gems in the correct order

Signed-off-by: Dan Webb [email protected]

Check List

  • A summary of changes made is included in the CHANGELOG under ## Unreleased
  • New functionality includes testing.
  • New functionality has been documented in the README if applicable.

@damacus damacus requested a review from a team as a code owner January 26, 2022 11:32
@damacus damacus self-assigned this Jan 26, 2022
@xorima xorima marked this pull request as draft January 26, 2022 12:39
resources/ruby.rb Outdated Show resolved Hide resolved
@@ -0,0 +1,20 @@
unified_mode true

include_recipe 'rvm::system_install'
Copy link

@Skipants Skipants Feb 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason I get an undefined method here when specifying the rvm_ruby resource. It doesn't make a lot of sense why and I'm still trying to figure it out:

       ================================================================================
       Recipe Compile Error in /tmp/kitchen/cache/cookbooks/rvm/resources/system.rb
       ================================================================================

       NoMethodError
       -------------
       undefined method `include_recipe' for #<Class:0x0000000002e5e690>

       Cookbook Trace: (most recent call first)
       ----------------------------------------
         /tmp/kitchen/cache/cookbooks/rvm/resources/system.rb:3:in `class_from_file'

       Relevant File Content:
       ----------------------
       /tmp/kitchen/cache/cookbooks/rvm/resources/system.rb:

         1:  unified_mode true
         2:
         3>> include_recipe 'rvm::system_install'
         4:
         5:  perform_install_rubies = node['rvm']['install_rubies'] == true ||
         6:                           node['rvm']['install_rubies'] == 'true'
         7:
         8:  if perform_install_rubies
         9:    install_rubies  rubies: node['rvm']['rubies'],
        10:                    default_ruby: node['rvm']['default_ruby'],
        11:                    global_gems: node['rvm']['global_gems'],
        12:                    gems: node['rvm']['gems']

       System Info:
       ------------
       chef_version=17.9.52
       platform=centos
       platform_version=7.9.2009
       ruby=ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [x86_64-linux]
       program_name=/opt/chef/bin/chef-client
       executable=/opt/chef/bin/chef-client


       Running handlers:
       [2022-02-18T17:13:10+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2022-02-18T17:13:10+00:00] ERROR: Exception handlers complete
       Infra Phase failed. 0 resources updated in 10 seconds
       [2022-02-18T17:13:10+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2022-02-18T17:13:10+00:00] FATAL: ---------------------------------------------------------------------------------------
       [2022-02-18T17:13:10+00:00] FATAL: PLEASE PROVIDE THE CONTENTS OF THE stacktrace.out FILE (above) IF YOU FILE A BUG REPORT
       [2022-02-18T17:13:10+00:00] FATAL: ---------------------------------------------------------------------------------------
       [2022-02-18T17:13:10+00:00] FATAL: NoMethodError: undefined method `include_recipe' for #<Class:0x0000000002e5e690>
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Converge failed on instance <default-centos-7>.  Please see .kitchen/logs/default-centos-7.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

This is in a test kitchen run on vagrant with chef_version 17 as you see there and it also happens on version 15

Copy link

@Skipants Skipants Feb 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's because this needs to be a resource method instead of include_recipe and it also needs to be inside a resource. eg:

action :install do
  rvm_system_install
  ...
end

Is this file needed at all? It seems like it's covered by rvm_system_install.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this is totally a mess right now. And that one is probably the most busted. I never really want to include_recipes in custom resources. Ideally

@damacus damacus dismissed a stale review via 6a4db49 January 30, 2023 22:28
- Pull in files from ruby_rbenv
- Add docs stubs for new resoruces
- Update README

Signed-off-by: Dan Webb <[email protected]>
@damacus damacus force-pushed the convert-to-custom-resources branch from 6a4db49 to 150ca87 Compare April 26, 2023 09:43
xorima
xorima previously approved these changes Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants