I am trying to copy and execute the bash script from my puppet master to my puppet agent.
I have create a folder mymodule in /etc/puppet/modules/
[root#ip********* mymodule]# ls -l
total 0
drwxr-xr-x. 2 root root 30 Aug 26 15:58 files
drwxr-xr-x. 2 root root 20 Aug 26 16:57 manifests
[root#ip-*********** manifests]# ls -l
total 4
-rw-r--r--. 1 root root 372 Aug 26 16:57 init.pp
[root#ip-************* files]# ls -l
total 4
-rw-r--r--. 1 root root 151 Aug 26 15:13 my_bash_script.sh
[root#ip-********** files]# cat my_bash_script.sh
#!/bin/sh
mv /usr/bin/node /usr/bin/bnode
ln -s /usr/local/bin/node /usr/bin/node
mv /usr/bin/npm /usr/bin/bnpm
ln -s /usr/local/bin/npm /usr/bin/npm
[root#ip-********* manifests]# cat init.pp
class mymodule::mymodule{
file {'/home/ec2-user/my_bash_script.sh':
source => 'puppet:///modules/mymodule/files/my_bash_scrip.sh',
mode => '755',
}
exec {'/home/ec2-user/my_bash_script.sh':
refreshonly => 'true',
require => File["/home/ec2-user/my_bash_script.sh"],
subscribe => File["/home/ec2-user/my_bash_script.sh"],
}
}
and in my /etc/puppet/manifest/site.pp i am calling the class created in module.
[root#ip-*********** manifests]# cat site.pp
import 'mymodule'
node 'node1' {
include "mymodule"
}
when i run from agent 'puppet agent -t'
i am getting the below error:
[root#ip-************8 /]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class mymodule for ip-**********8 on node ip-**********8
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
The init manifest (init.pp) of your class is expected to be defined as just the class name, like this:
class mymodule {
and not this:
class mymodule::mymodule {
so your inclusion of:
include "mymodule"
matches the class name.
Also, your file resource has a syntax error and a typo. It should look like:
file {'/home/ec2-user/my_bash_script.sh':
source => 'puppet:///modules/mymodule/my_bash_script.sh',
mode => '755',
}
Check my answer to your previous question here: Executing bash script from puppet fails for more information about the source attribute and the Puppet URI.
Related
OS: Linux(running inside docker)
node version: 10.22.1
I have the executeJs file below:
#!/usr/bin/env node
var path = require('path');
var apJsFile = path.resolve(__dirname, '../app.js'); //app.js is working correctly
require(appJsFile);
When I try to execute it ./executeJs it throws the error: : No such file or directory
I checked if the node was installed, by running the node -v command and it returned 10.22.1
I checked where was the node installed by running the which node and it returned /usr/bin/node
I checked the path variable by running echo $PATH and it returned /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
I don't understand why shebangs is not working #!/usr/bin/env node.
I will appreciate any help in solving this issue.
# cat /node/scraper/bin/scraper
#!/usr/bin/env node
var path = require('path');
console.log(path);
var scraperJsFile = path.resolve(__dirname, '../scraper.js');
console.log(scraperJsFile);
require(scraperJsFile);
# which node
/usr/bin/node
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# ./node/scraper/bin/scraper
/bin/sh: 72: ./node/scraper/bin/scraper: not found
# /usr/bin/env
JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
HOSTNAME=84ad4665cc48
HOME=/root
OLDPWD=/node/scraper/bin
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
PWD=/usr/bin
# cd /node/scraper/bin
# ls -la
total 20
drwxr-xr-x 2 root root 4096 Jul 13 14:46 .
drwxr-xr-x 8 root root 4096 Jul 8 16:03 ..
-rwxr-xr-x 1 root root 183 Jul 13 14:46 scraper
-rw-r--r-- 1 root root 187 Jul 13 12:52 scraper.bak
-rwxr-xr-x 1 root root 156 Mar 16 17:34 scraper.bat
# ./scraper
/bin/sh: 81: ./scraper: not found
The problem with why the shebangs for the node was not being recognized inside Linux Docker container was the content formatted in windows style for the executeJs file. This came due to the mounted volume of the docker container with the host system. Since my host system is Windows it had formatted executeJs in windows formatting style. I changed the formatted text style to Linux and everything is working correctly.
I opened the file with the vi editor and pasted the content and was able to run the executeJs file.
I would like to create/ensure a directory exists and recursively copy many files to it using native Puppet methods if possible. The file modes are same for all files but differ from the directory.
I am using Puppet6 version 6.10.0 on CentOS 6.10
This code will create/ensure my directory exists and copy all the files to it but sets the access rights and ownership exactly the same.
file { "/opt/dir1":
ensure => "directory",
owner => "user1",
group => "root",
mode => "0700",
recurse => true,
source => "puppet:///modules/mymodule/dir1",
}
What I get:
ls -la /opt/dir1"
drwx------ 2 user1 root 4096 Sep 23 20:31 .
drwxr-xr-x 7 user1 root 4096 Oct 6 15:20 ..
-rwx------ 1 user1 root 72 Oct 5 17:15 file1
What I want:
ls -la /opt/dir1"
drwx------ 2 user1 root 4096 Sep 23 20:31 .
drwxr-xr-x 7 user1 root 4096 Oct 6 15:20 ..
-rw-r--r-- 1 user1 root 72 Oct 5 17:15 file1
If you are able to manage the permissions and mode in the source you can use this parameter source_permissions => use. Note, depending on your version you may get a deprecated warning:
Warning: The `source_permissions` parameter is deprecated. Explicitly set `owner`, `group`, and `mode`.
file { "/opt/dir1":
ensure => "directory",
owner => "user1",
group => "root",
source_permissions => "use",
recurse => true,
source => "puppet:///modules/mymodule/dir1",
}
This would allow you do manage the mode in the source but still override the owner and group. you could also drop the owner and group params above and manage them in the source as well. However I'm not sure how this works if you have windows clients and a linux puppet master, or a missmatch in users/groups on the master vs agent
The Puppet file resource can't set different modes for the apex directory and its files when using recurse. https://puppet.com/docs/puppet/5.5/types/file.html#file-attribute-mode
Would you be able to use an archive resource instead? With an archive resource, you can specify a tar file as the source, and the permissions will be set following those in the tar file.
I'm using Fedora 25.
I have a binary that needs multiple libraries. The binary can't find libRblas.so:
$ ldd XPore-Engine | less | grep not
libvtkRenderingAnnotation.so.1 => /usr/lib64/vtk/libvtkRenderingAnnotation.so.1 (0x00007fac12563000)
libRblas.so => not found
libRblas.so => not found
libRblas.so => not found
The library path is properly configured with a .conf file:
$ cat /etc/ld.so.conf.d/R-x86_64.conf
/usr/lib64/R/lib
$ ll /usr/lib64/R/lib
lrwxrwxrwx. 1 root root 11 dic 16 20:46 libopenblas.so.0 -> libRblas.so
lrwxrwxrwx. 1 root root 27 oct 31 21:16 libRblas.so -> /usr/lib64/libopenblas.so.0
-rwxr-xr-x. 1 root root 1989312 oct 31 21:16 libRlapack.so
-rwxr-xr-x. 1 root root 178856 oct 31 21:16 libRrefblas.so
-rwxr-xr-x. 1 root root 2911536 oct 31 21:16 libR.so
And I load the configuration with ldconfig:
$ ldconfig -v | grep libRblas
libopenblas.so.0 -> libRblas.so
However, after executing ldd again it returns the same output saying that libRblas.so wasn't found.
How can I fix this?
I've found a workaround provided by Tom in the Read Hat Bugzilla bug-tracking system at https://bugzilla.redhat.com/show_bug.cgi?id=1404662.
Yeah, so it looks like while R is perfectly happy using libRblas.so as a > symlink to libopenblas.so.0, externally, nothing else is.
The speedup from using openblas is significant, so the fix is to build a copy of openblas that has the libRblas.so filename and soname, and use that instead of the symlink. I have a new build of openblas going which adds this, then I'll do a new round of R builds that depend on it.
As a temporary workaround, you can run (as root):
rm -f /usr/lib64/R/lib/libRblas.so
mv /usr/lib64/R/lib/libRrefblas.so /usr/lib64/R/lib/libRblas.so
That will restore the unoptimized libRblas.so that R provides.
Oh, and run /sbin/ldconfig (as root) after moving libRrefblas.so so that the ldcache is updated.
When I try to do a manual source install of some software on NixOS 15.09, I get (sh -x is to get an exec log):
[nix-shell:/tmp/nix-shell-es/EventStore-oss-v3.5.0-src]$ sh -x scripts/build-js1/build-js1-linux.sh werror=no
...
+ CXXFLAGS=-fPIC
+ make x64.release werror=no
PYTHONPATH="/tmp/nix-shell-es/EventStore-oss-v3.5.0-src/scripts/build-js1/v8/tools/generate_shim_headers:" \
GYP_GENERATORS=make \
build/gyp/gyp --generator-output="out" build/all.gyp \
-Ibuild/standalone.gypi --depth=. \
-Dv8_target_arch=x64 \
-Dv8_optimized_debug=0 \
-S.x64.release -Dv8_enable_backtrace=1 -Dwerror='' -Darm_fpu=default -Darm_float_abi=default
/bin/sh: build/gyp/gyp: /bin/bash: bad interpreter: No such file or directory
Makefile:389: recipe for target 'out/Makefile.x64.release' failed
make: *** [out/Makefile.x64.release] Error 126
And indeed there is no bash program in /bin/
[nix-shell:/tmp/nix-shell-es/EventStore-oss-v3.5.0-src]$ ls -la /bin/
total 12
drwxr-xr-x 2 root root 4096 Feb 24 12:25 .
drwxr-xr-x 18 root root 4096 Feb 24 12:16 ..
lrwxrwxrwx 1 root root 63 Feb 24 12:25 sh -> /nix/store/l80ddf18bbig2icv6cmgjfws9a2vm3jj-bash-4.3-p42/bin/sh
However when I inspect the script I dont see any mention of it so it must be some subprogram looking for it.
As an aside, I imagine that's probably why the script wisely starts with #!/usr/bin/env bash and not the direct location of bash.
Anyone knows a blessed way to deal with this ?
one has to run patchShebangs ./scripts/build-js1/build-js1-linux.sh on files coming from source when they are not in the store and we want to execute them.
I created a module named as bharath as below..
$ pwd
>> /etc/puppetlabs/puppet/modules
$ ls -lrth
>> total 8.0K
>> drwxr-xr-x 6 root root 4.0K Apr 18 08:01 motd
>> drwxr-xr-x 6 root root 4.0K Apr 18 13:09 bharath
$ cd bharath/
$ ls -lrt
>> total 16
>> drwxr-xr-x 2 root root 4096 Apr 18 12:59 templates
>> drwxr-xr-x 2 root root 4096 Apr 18 13:10 files
>> drwxr-xr-x 2 root root 4096 Apr 18 13:15 manifests
>> drwxr-xr-x 2 root root 4096 Apr 18 13:16 tests h
$ cat manifests/init.pp files/india1 tests/init.pp
class india {
file { '/root/india1':
ensure => 'file',
source => 'puppet:///modules/bharath/india1',
}
}
india is grat country --> files/india1 content
include india --> tests/init.pp content
But still i am getting error as below..eventhough i added class india in stie.pp node classification directive as well.
$ cd tests
$ puppet apply --noop init.pp
>> Error: Could not find class india for uppetmaster.bharathkumarraju.com on node uppetmaster.bharathkumarraju.com
>> Error: Could not find class india for uppetmaster.bharathkumarraju.com on node puppetmaster.bharathkumarraju.com
When using puppet apply you need to set your modulepath on the command line.
$ puppet apply --modulepath /path/to/modules --noop init.pp
As #FelixFrank stated, you should reformat your question to make it more clear what you are asking, as well as better read the files you are cat'ing.
Hope this helps