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

Libraries' code is not accessible in recipe #47

Open
Rahuloptum opened this issue Oct 31, 2019 · 16 comments
Open

Libraries' code is not accessible in recipe #47

Rahuloptum opened this issue Oct 31, 2019 · 16 comments
Labels

Comments

@Rahuloptum
Copy link

Rahuloptum commented Oct 31, 2019

Hi,
I am from Optum global solutions and working as an IT professionals. I am middleware infrastructure engineer and currently working on websphere installation/configuration automation. I am trying to use websphere cookbook which is present in chef supermarket and git hub. Unfortunately I am getting below error while creating the websphere cluster, Could you please suggest here ?

Chef: https://supermarket.chef.io/cookbooks/websphere
Git hub: https://github.com/Sainsburys/chef-websphere

Code snippet :

Default.rb

websphere_cluster 'websphere cluster' do
  cluster_name 'k1_tst_dev'
  cluster_type 'APPLICATION_SERVER'
  action:create
end

Note: Websphere is already installed.

Error:

Running handlers:
[2019-10-14T04:32:12-05:00] ERROR: Running exception handlers
Running handlers complete
[2019-10-14T04:32:12-05:00] ERROR: Exception handlers complete
Chef Client failed. 1 resources updated in 04 seconds
[2019-10-14T04:32:12-05:00] FATAL: Stacktrace dumped to /home/wsuser/.chef/local-mode-cache/cache/chef-stacktrace.out
[2019-10-14T04:32:12-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-10-14T04:32:12-05:00] FATAL: NameError: websphere_cluster[websphere cluster] (chef_iac_platform_was_base::default line 56) had an error: NameError: undefined local variable or method `cluster_name' for #<#<Class:0x0000000004f39e78>:0x0000000004260cd8>
@chrisminton
Copy link
Contributor

Hi @Rahuloptum. Could you let us know the Chef version you are using and the version of the cookbook also?

@Rahuloptum
Copy link
Author

Thanks Chris, please find the requested details.
Chef version: 14.12.9 and the cookbook version : 1.0.2 .

@chrisminton
Copy link
Contributor

OK thanks. Could you also add the stacktrace?

@chrisminton
Copy link
Contributor

Actually @Rahuloptum, it is likely that the Supermarket release is still not Chef 14-compliant. We are actively developing the scoped_cluser_members branch which is compliant - this will released as master as soon as some changes are made for SystemD updates. To test this, you could switch to this branch in your Berksfile:

cookbook 'websphere', git: '[email protected]:Sainsburys/chef-websphere.git', branch: 'scoped_cluser_members'

@Rahuloptum
Copy link
Author

@chrisminton I am executing this cookbook in local mode. If I run the default recipe of websphere cookbook then also getting same error. Don't know why same cookbook recipe can't read the libraries resources.

@chrisminton
Copy link
Contributor

It will be due to this: https://docs.chef.io/deprecations_namespace_collisions.html. So the 1.0.2 version of this cookbook does not correctly handle these issues using Chef 14.

@Rahuloptum
Copy link
Author

Rahuloptum commented Nov 4, 2019

Thanks @chrisminton it has fixed that error,but getting another error regarding wsadmin_exec().

Code:

# creates an empty cluster
    action :create do
      unless cluster_exists?(#{new_resource.cluster_name})
        cmd = "AdminClusterManagement.createClusterWithoutMember('#{new_resource.cluster_name}')"
        wsadmin_exec(("wasadmin createClusterWithoutMember #{new_resource.cluster_name}",cmd)
        save_config
      end
    end

Error:

Running handlers:
[2019-11-04T06:09:56-06:00] ERROR: Running exception handlers
Running handlers complete
[2019-11-04T06:09:56-06:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 02 seconds
[2019-11-04T06:09:56-06:00] FATAL: Stacktrace dumped to /home/wsuser/.chef/local-mode-cache/cache/chef-stacktrace.out
[2019-11-04T06:09:56-06:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-11-04T06:09:56-06:00] FATAL: SyntaxError: /home/wsuser/.chef/local-mode-cache/cache/cookbooks/websphere/libraries/websphere_cluster.rb:35: syntax error, unexpected tIDENTIFIER, expecting ')'
        wsadmin_exec(("wasadmin createClusterWith...
        ^~~~~~~~~~~~
/home/wsuser/.chef/local-mode-cache/cache/cookbooks/websphere/libraries/websphere_cluster.rb:35: syntax error, unexpected ',', expecting ')'
... #{new_resource.cluster_name}",cmd)
...                              ^
/home/wsuser/.chef/local-mode-cache/cache/cookbooks/websphere/libraries/websphere_cluster.rb:36: syntax error, unexpected tIDENTIFIER, expecting ')'
        save_config
        ^~~~~~~~~~~
/home/wsuser/.chef/local-mode-cache/cache/cookbooks/websphere/libraries/websphere_cluster.rb:60: syntax error, unexpected keyword_end, expecting end-of-input

Cookbook Trace:

/home/wsuser/.chef/local-mode-cache/cache/cookbooks/websphere/libraries/websphere_app_server.rb:2:in require_relative' /home/wsuser/.chef/local-mode-cache/cache/cookbooks/websphere/libraries/websphere_app_server.rb:2:in <top (required)>'

@chrisminton
Copy link
Contributor

Hmm, @Rahuloptum do you still have 1.0.2 specified in your metadata.rb? If so, change the pinning to 1.2.0

@Rahuloptum
Copy link
Author

@chrisminton Yes I changed it, but didn't help.

if I pass message alone in " " then also getting the same error.

In websphere_cluster.rb

wsadmin_exec("wasadmin createClusterWithoutMember" , cmd )

@chrisminton
Copy link
Contributor

hmm, try changing it to:

wsadmin_exec("createClusterWithoutMember: #{new_resource.cluster_name} ", cmd)

@chrisminton
Copy link
Contributor

chrisminton commented Nov 4, 2019

It still appears that you are on an older version of the cookbook there. The latest on that branch has

libraries/websphere_cluster.rb:35:

        wsadmin_exec("createClusterWithoutMember #{new_resource.cluster_name}", cmd)

note the absence of the wsadmin_exec(("wasadmin

@Rahuloptum
Copy link
Author

I downloaded the latest now and running it. Still getting the same error.

Berksfile:

source 'https://supermarket.chef.io'

cookbook 'chef-websphere', git: 'https://github.com/Sainsburys/chef-websphere.git', branch: 'scoped_cluster_members'
metadata
#cookbook 'websphere-test', path: 'test/fixtures/cookbooks/websphere-test'
#cookbook 'ibm-installmgr', git: 'https://github.com/Sainsburys/ibm-installmgr'

@chrisminton
Copy link
Contributor

@Rahuloptum it would be this

cookbook 'chef-websphere', git: 'https://github.com/Sainsburys/chef-websphere.git', branch: 'scoped_cluser_members'

@Rahuloptum
Copy link
Author

Rahuloptum commented Nov 5, 2019

@chrisminton I believe I am using the correct cookbook under branch "scoped_cluser_members" .

Running handlers:

[2019-11-05T05:50:26-06:00] ERROR: Running exception handlers
Running handlers complete
[2019-11-05T05:50:26-06:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 02 seconds
[2019-11-05T05:50:26-06:00] FATAL: Stacktrace dumped to /home/wsuser/.chef/local-mode-cache/cache/chef-stacktrace.out
[2019-11-05T05:50:26-06:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-11-05T05:50:26-06:00] FATAL: SyntaxError: /home/wsuser/.chef/local-mode-cache/cache/cookbooks/websphere/libraries/websphere_cluster.rb:35: syntax error, unexpected tIDENTIFIER, expecting ')'
        wsadmin_exec("wasadmin createClusterWitho...
        ^~~~~~~~~~~~
/home/wsuser/.chef/local-mode-cache/cache/cookbooks/websphere/libraries/websphere_cluster.rb:60: syntax error, unexpected keyword_end, expecting end-of-input

@chrisminton
Copy link
Contributor

chrisminton commented Nov 5, 2019

Hi @Rahuloptum - it doesn't appear to be, as the branch has

wsadmin_exec("createClusterWitho...

rather than

wsadmin_exec("wasadmin createClusterWitho...

as you have in your error

Can you post a gist of your metadata, recipe etc.? Perhaps we can understand what is happening with more context.

@Rahuloptum
Copy link
Author

Thank you so much @chrisminton :) It's working. I am able to create cluster now.

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

No branches or pull requests

2 participants