Getting error while running curl command via chef - shell

While running curl command using chef getting error. Block which I am trying to execute:
bash 'create_aemadmin' do
code <<-EOF
curl -u admin:admin -FcreateUser=aemadmin -FauthorizableId=aemadmin -Frep:password=#{node['aem_vm_cookbook']['aem_api_auth']['password']} -Fprofile/familyName=aemadmin http://#{node['aem_vm_cookbook']['host_name']}:8080/libs/granite/security/post/authorizables
EOF
not_if { File.exist?('/home/aemadmin/dce/aemadminusercreate') }
end
Error which i am getting for this:
/bin/chef-client:162:in `<main>'
[2020-09-09T01:48:24-05:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: bash[create_aemadmin] (aem_vm_cookbook::default line 455) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '2'
---- Begin output of "bash" "/tmp/chef-script20200909-12267-2dd1ke" ----
STDOUT:
STDERR: curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
---- End output of "bash" "/tmp/chef-script20200909-12267-2dd1ke" ----
Ran "bash" "/tmp/chef-script20200909-12267-2dd1ke" returned 2
Using this block i am trying to create a user i can see curl is getting values for variable which i am using but it is not able to execute.

Due space issue i was facing this. Now i resolved it

Related

im getting error code 127 while creating jenkins pipeline here is the script

pg_dump -h 10.12.0.4 -U pet--rsmb--prod-l1--usr -w -c -f 2022-08-10t1228z-data.sql
/var/lib/jenkins/workspace/BACKUP-RSMB--POSTGRESQL#tmp/durable-510acc0f/script.sh: 1: /var/lib/jenkins/workspace/BACKUP-RSMB--POSTGRESQL#tmp/durable-510acc0f/script.sh: pg_dump: not found
Your error clearly indicates that the Shell executor cannot find pg_dump command. Either you have not set pg_dump properly in the Jenkins server or you have not added pg_dump to the executable $PATH.

Failed to send h2c command

I'm executing the following command: sudo insmode hello.c, but it's not working as expected:
ERROR: could not insert module hello.ko: Operation not permitted
When I run the command: dmesg | tail -1 is reported:
rtw_8822ce 0000:02:00.0: failed to send h2c command
How to fix this error? Thanks

Run a shell script using kubectl exec - OCI runtime exec failed: exec failed: container_linux.go:346

I am trying a run a shell script via kubectl exec.
Eg- kubectl exec -n abc podxyz -- /root/test/./generate.sh
The script runs in the podxyz container but returns the below error, breaking the rest of the flow.
"command terminated with exit code 126"]
"OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused \"no such file or directory\": unknown"]}
I have tried to use -- /bin/sh and bash after the -- , but that did not help.
Note - the above command is executed as part of another script.

Shell Script failing on alpine linux while working in mac terminal

The following line fails when run in a alpine docker container:
toDelete=( $(curl --silent $url/_cat/indices\?format=json | jq -r '.[].index | select(startswith('\".kibana\"'))') )
The following error message appears:
run.sh: line 1: syntax error: unexpected "("
When I run the command in the terminal on my mac, everything works properly. The brackets are added so that the result (variable toDelete) is interpreted as array and can be looped through with a for loop like so:
for index in "${toDelete[#]}"; do
curl -X DELETE $url/$index
done
Any help in how to solve this problem is appreciated!
Marking down the answer.
The issue was with the interpreter.
worked after making the below change.
["/bin/ash", "run.sh"]
the passed one was
["/bin/sh", "run.sh"]

Linux running a command inline to CURL command

I'm trying to run the file sh /usr/local/sbin/script.sh and assigning the stderr as parameter to $msg.
curl -k -X POST https://192.168.0.25/sims/index.php -d "option=com_user&task=sendSMSalert&msg=$(/usr/local/sbin/script.sh 2>&1)"
The above script works fine on Ubuntu but when running the same script on freenas 11, I'm getting the error:
Illegal variable name.
I then tried replacing $(/usr/local/sbin/script.sh 2>&1) with (/usr/local/sbin/script.sh), but instead of output of /usr/local/sbin/script.sh command, It's just assigning the string "/usr/local/sbin" to that parameter.
Please help me.

Resources