No resource or method named powershell for Chef::Recipe - powershell

When I run the powershell script on chef -solo on local System ,it give below error message. I have already added powershell in cookbook,
NoMethodError:-------------
No resource or method named `powershell' for `Chef::Recipe "M3"'
Cookbook Trace:
---------------
C:\chef\cookbooks\Balasahebb\recipes\M3.rb:44:in `from_file'
Relevant File Content:
----------------------
C:\chef\cookbooks\Balasahebb\recipes\M3.rb:
37: #Write the output status of the commands to C:\auto\runstatus in the forma
t status:success or status:failed
38:
39: template "c:\\auto\\zib.conf" do
40: source "csb_automaticmssql_configuration.erb"
41: #variables({:hostname => "#{HOSTNAME}"})
42: end
43:
44>> powershell "create configuration directory and copy conf" do
45: code <<-EOH
46: Backloc=(Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Zman
da\ZIB).BackupSetLocation
47: mkdir "#{Backloc}\#{BACKUPSET}"
48: CP 'c:\\auto\\zib.conf' "#{Backloc}\\#{BACKUPSET}\\zib.conf"
49:
50: EOH
51: action :run
52: end
53:
Running handlers:
[2015-07-15T13:50:01+05:30] ERROR: Running exception handlers
Running handlers complete
[2015-07-15T13:50:01+05:30] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 20.512517 seconds
[2015-07-15T13:50:01+05:30] FATAL: Stack trace dumped to C:/chef/cache/chef-stack
trace.out
[2015-07-15T13:50:01+05:30] FATAL: No Method Error: No resource or method named `p
power shell' for `Chef::Recipe "M3"`enter code here`'

You should add depends 'powershell' to your metadata.rb file, if you want that resource available. This is assuming you are using the powershell community cookbook, and not just looking for the powershell_script resource that comes with Chef.

Related

documenting error Jazzy "0% documentation coverage with 0 undocumented symbols"

So I'm trying to run Jazzy to document my code but I'm not getting very far.
This is what happens when i run Jazzy on my Xcode project written in swift(and some functions in # objc). Do i need to prepare the project in any way? I can't find anything about this, but it's my first time using Xcode and jazzy.
Can anyone tell me why it's not able to run properly am i doing something wrong while running the command?
jazzy
Running xcodebuild
Checking xcodebuild -showBuildSettings
Assuming New Build System is used.
Parsing AppDelegate.swift (1/4)
Parsing Card.swift (2/4)
Parsing SceneDelegate.swift (3/4)
Parsing ViewController.swift (4/4)
0% documentation coverage with 0 undocumented symbols
skipped 4 private, fileprivate, or internal symbols (use `--min-acl` to specify a different minimum ACL)
building site
building search index
jam out ♪♫ to your fresh new docs in `docs`
I tried doing jazzy --min-acl but this happens:
jazzy --min-acl
Traceback (most recent call last):
15: from /usr/local/bin/jazzy:23:in `<main>'
14: from /usr/local/bin/jazzy:23:in `load'
13: from /Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/bin/jazzy:15:in `<top (required)>'
12: from /Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/lib/jazzy/config.rb:442:in `parse!'
11: from /Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/lib/jazzy/config.rb:485:in `parse_command_line'
10: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/optparse.rb:1678:in `parse!'
9: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/optparse.rb:1656:in `permute!'
8: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/optparse.rb:1562:in `order!'
7: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/optparse.rb:1568:in `parse_in_order'
6: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/optparse.rb:1568:in `catch'
5: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/optparse.rb:1582:in `block in parse_in_order'
4: from /Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/lib/jazzy/config.rb:54:in `block in attach_to_option_parser'
3: from /Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/lib/jazzy/config.rb:35:in `set'
2: from /Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/lib/jazzy/config.rb:35:in `instance_exec'
1: from /Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/lib/jazzy/config.rb:342:in `block in <class:Config>'
/Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/lib/jazzy/source_declaration/access_control_level.rb:64:in `from_human_string': cannot initialize AccessControlLevel with '' (RuntimeError)
For the sake of people searching on google, when jazzy reports skipped items and generates 0% of documentation, invoke jazzy in the following way:
jazzy --min-acl <internal|fileprivate|private>
Swift is internal unless you specify the access otherwise.
Here is a link to the github readme discussing this topic: https://github.com/realm/jazzy#controlling-what-is-documented

Error executing action `create` on resource 'cookbook_file

Getting an error while executing action 'create' on a resource. I am running the recipe in --local-mode not sure if that is the problem.
I am just trying to run it locally first instead of running it on a node.
Pasting my file and my output in here :
[2019-04-09T19:25:51+00:00] WARN: Node rheaj has an empty run list.
Converging 4 resources
Recipe: #recipe_files::/home/rheaj/chef/cookbooks/oc_jumpbox/recipes/default.rb
* cookbook_file[/etc/motd] action create[2019-04-09T19:25:51+00:00] INFO: Processing cookbook_file[/etc/motd] action create (#recipe_files::/home/rheaj/chef/cookbooks/oc_jumpbox/recipes/default.rb line 9)
================================================================================
Error executing action `create` on resource 'cookbook_file[/etc/motd]'
================================================================================
Chef::Exceptions::CookbookNotFound
----------------------------------
Cookbook #recipe_files not found. If you're loading #recipe_files from another cookbook, make sure you configure the dependency in your metadata
Resource Declaration:
---------------------
# In /home/rheaj/chef/cookbooks/oc_jumpbox/recipes/default.rb
9: cookbook_file '/etc/motd' do
10: group 'root'
11: user 'root'
12: mode '0644'
13: source 'motd'
14: end
15:
Default location for your cookbook_files is in files/default. The error you get is that your cookbook file is not there. Can you create that file files/default/motd and re run your chef-client.

Chef MongoDB Replication with sc-mongodb

I am new to chef and I'm using sc-mongodb, and I can't get this to work. Is there a better way of doing replication for MongoDB with chef?
I was able to get the default recipe working
include_recipe "sc-mongodb::default"
But when I tried to do replication for mongo, I started getting some weird errors.
include_recipe "sc-mongodb::replicaset"
Error:
================================================================================
Recipe Compile Error in /tmp/kitchen/cache/cookbooks/c_mongo/recipes/default.rb
================================================================================
Net::HTTPServerException
------------------------
400 "Bad Request"
Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:236:in `block in from_file'
/tmp/kitchen/cache/cookbooks/sc-mongodb/recipes/replicaset.rb:36:in `from_file'
/tmp/kitchen/cache/cookbooks/c_mongo/recipes/default.rb:54:in `from_file'
Relevant File Content:
----------------------
/tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:
229: notifies :run, 'ruby_block[config_sharding]', :immediately if new_resource.is_mongos && new_resource.auto_configure_sharding
230: # we don't care about a running mongodb service in these cases, all we need is stopping it
231: ignore_failure true if new_resource.name == 'mongodb'
232: end
233:
234: # replicaset
235: if new_resource.is_replicaset && new_resource.auto_configure_replicaset
236>> rs_nodes = search(
237: :node,
238: "mongodb_cluster_name:#{new_resource.cluster_name} AND "\
239: 'mongodb_is_replicaset:true AND '\
240: "mongodb_config_mongod_replication_replSetName:#{new_resource.replicaset_name} AND "\
241: "chef_environment:#{node.chef_environment}"
242: )
243:
244: ruby_block 'config_replicaset' do
245: block do
System Info:
------------
chef_version=13.8.5
platform=centos
platform_version=7.4.1708
ruby=ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]
program_name=chef-client worker: ppid=28997;start=00:31:33;
executable=/opt/chef/bin/chef-client
Running handlers:
[2018-03-27T00:31:35+00:00] ERROR: Running exception handlers
Running handlers complete
[2018-03-27T00:31:35+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 01 seconds
[2018-03-27T00:31:35+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2018-03-27T00:31:35+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-03-27T00:31:35+00:00] ERROR: 400 "Bad Request"
[2018-03-27T00:31:35+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
I have tried so many ways to resolve this problem, looking at the issues from the github repository. From the errors, it looks like the attributes aren't getting set, so people are setting them manually. :
# attempt1------------
#node.default['mongodb']['config']['replSet'] = true
#node.default[:mongodb][:cluster_name] = "repl-name"
#include_recipe "sc-mongodb::replicaset"
# attempt2----------
#node.normal['mongodb']['install_method'] = 'mongodb-org'
#node.normal['mongodb']['config']['bind_ip'] = '0.0.0.0'
#node.normal['mongodb']['dbconfig_file'] = '/etc/mongod.conf'
#node.normal['mongodb']['config']['replSet'] = true
#node.normal['mongodb']['is_replicaset'] = true
#node.normal['mongodb']['cluster_name'] = 'scribe'
#node.normal['mongodb']['replSet'] = 'scribe'
#node.normal['mongodb']['is_shard'] = false
#include_recipe "sc-mongodb::replicaset"
#attempt3------------
#node.default[:mongodb][:cluster_name] = "cluster_name"
#include_recipe "sc-mongodb::replicaset"
#attempt4------------
#if node['mongodb']['config']['replSet'].nil?
# node.default['mongodb']['config']['replSet'] = "repl-name"
#end
#include_recipe "sc-mongodb::replicaset"
#attempt5-------------
#https://github.com/sous-chefs/mongodb/issues/167
#node.default['mongodb']['config']['mongod']['replication']['replSetName'] = "rs-name"
#include_recipe "sc-mongodb::replicaset"
This one gives me a different error:
#attempt6-----------
node.default['mongodb']['config']['mongod']['replication']['replSetName']= 'rs_default'
node.default['mongodb']['cluster_name'] = 'cluster'
node.default['mongodb']['auto_configure']['replicaset'] = true
include_recipe "sc-mongodb::replicaset"
Stacktrace:
================================================================================
Error executing action `run` on resource 'ruby_block[config_replicaset]'
================================================================================
NoMethodError
-------------
undefined method `[]' for nil:NilClass
Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/sc-mongodb/libraries/mongodb.rb:74:in `configure_replicaset'
/tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:246:in `block (3 levels) in from_file'
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb
244: ruby_block 'config_replicaset' do
245: block do
246: MongoDB.configure_replicaset(node, replicaset_name, rs_nodes) unless new_resource.replicaset.nil?
247: end
248: action :nothing
249: end
250:
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:244:in `block in from_file'
ruby_block("config_replicaset") do
params {:mongodb_type=>"mongod", :action=>[:enable, :start], :logpath=>"/var/log/mongodb/mongod.log", :configservers=>[], :replicaset=>true, :notifies=>[], :not_if=>[], :name=>"mongod"}
action [:nothing]
retries 0
retry_delay 2
default_guard_interpreter :default
block_name "config_replicaset"
declared_type :ruby_block
cookbook_name "sc-mongodb"
recipe_name "replicaset"
block #<Proc:0x00000003ebdec8#/tmp/kitchen/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:245>
end
Platform:
---------
x86_64-linux
I've had a lot of trouble with this cookbook, you're not alone.
From what I've gathered, you need to run this cookbook multiple times and/or in different configurations depending on what you are trying to achieve or what state your node is in. For example, I believe the auto_configure attribute should only be set for the last node in the set after the others have been cheffed with that set to false. Similarly for their user recipe, mongodb only allows admin coll operations on the primary and so you should ensure this recipe is executed on the designated primary node.
Unfortunately the documentation is not clear and for someone like me new to Chef and Ruby, the src and errors are tricky to interpret. I am still in the process of figuring out this cookbook and can report back if I have something concrete to give you, have you been able to get this working since your post? Sorry I can't be of much more help, you will have to try configurations out with test-kitchen VMs.

AEM server not getting started from start script AEM6.3

I have an AEM 6.3 server on Linux(RedHat). It is being getting started from command line without any issues with below command-
java -jar aem-author-4502.jar
But I am not able to start the server from start script and getting below error-
# ./start.bat
./start.bat: line 1: #echo: command not found
./start.bat: line 2: ::: command not found
./start.bat: line 3: $'::\r': command not found
./start.bat: line 4: ::: command not found
./start.bat: line 5: ::: command not found
./start.bat: line 5: $'e.g.,\r': command not found
./start.bat: line 6: $'::\r': command not found
./start.bat: line 7: ::: command not found
: No such file or directoryt.bat
./start.bat: line 8: $'::\r': command not found
./start.bat: line 9: $'setlocal\r': command not found
./start.bat: line 10: $'\r': command not found
./start.bat: line 11: ::*: command not found
./start.bat: line 17: syntax error near unexpected token `('
'/start.bat: line 17: `::* runmode(s)
Also, I am not able to set the AEM as service (linux)..
What could be the reason for this?
One thing that I observed is I don't have cq.pid file in my crx-quickstart/conf folder..
start.bat is a Batch file, one you would run on a Windows OS.
What you need to run is a similar shell script that you should find just next to the one you're trying to execute. It should be present in the <cq_installation_directory>/bin directory.
As per the official documentation, Simply running ./start should do the trick on Linux.

http 403 forbidden on deployment

We are facing http 403 forbidden when we are trying to create a file in the VM. We are using the following chef code to do the job.
X_FILES = %w{x-log4j.properties x-override.properties x-core.properties x.conf}
x_FILES.each do |file|
template "/etc/b2b/x/#{file}" do
mode 0644
source "#{file}.erb"
owner 'root'
action :create
notifies :restart, "service[a2a-x]"
only_if { File.exist?("/etc/a2a/x") }
helpers MongoUtil
helpers xUtil
end
end
We have multiple VMs and the error is not consistent. On restart of deployment job, the process is going fine.
The error log is as follows
[2015-10-01T01:40:03+05:30] INFO: Processing template[/etc/b2b/x/x-log4j.properties] action create (b2b::install_configure_x line 89)
[2015-10-01T01:40:04+05:30] INFO: HTTP Request Returned 403 Forbidden:
================================================================================
Error executing action `create` on resource 'template[/etc/b2b/x/x-log4j.properties]'
================================================================================
Net::HTTPServerException
------------------------
403 "Forbidden"
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/b2b/recipes/install_configure_x.rb
89: template "/etc/b2b/x/#{file}" do
90: mode 0644
91: source "#{file}.erb"
92: owner 'root'
93: action :create
94: notifies :restart, "service[b2b-x]"
95: only_if { File.exist?("/etc/b2b/x") }
96: helpers MongoUtil
97: helpers TenantIdUtil
98: end
99: end
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/b2b/recipes/install_configure_x.rb:89:in `block in from_file'
template("/etc/b2b/x/x-log4j.properties") do
provider Chef::Provider::Template
action [:create]
retries 0
retry_delay 2
guard_interpreter :default
path "/etc/b2b/x/x-log4j.properties"
backup 5
atomic_update true
source "x-log4j.properties.erb"
helper_modules [MongoUtil, TenantIdUtil]
cookbook_name "b2b"
recipe_name "install_configure_x"
mode 420
owner "root"
only_if { #code block }
end
Any help in this regard is greatly appreciated. thanks in advance.
In case someone else comes across this, as I did, this is most likely due to the authentication token timing out due to a very long chef run.
Here's a page that details solutions to that problem:
https://discourse.chef.io/t/seeing-a-weird-403-error-while-running-recipe/6149/2