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
Related
I'm trying to run a bash script which should go in a specific directory.
The Problem is that the Script wont go in the newest Folder.
The Folder looks like:
root#raspberry ~/jdownloader/logs # ls -lha
total 104K
drwxr-xr-x 9 root root 4.0K Nov 30 11:52 .
drwxr-xr-x 14 root root 4.0K Nov 30 11:52 ..
drwxr-xr-x 2 root root 4.0K Nov 30 11:18 1479843940152_Tue, Nov 22, 2016 20.45 +0100
drwxr-xr-x 2 root root 4.0K Nov 30 11:21 1480501204839_Wed, Nov 30, 2016 11.20 +0100
drwxr-xr-x 2 root root 4.0K Nov 30 11:22 1480501242752_Wed, Nov 30, 2016 11.20 +0100
drwxr-xr-x 2 root root 4.0K Nov 30 11:30 1480501308071_Wed, Nov 30, 2016 11.21 +0100
drwxr-xr-x 2 root root 4.0K Nov 30 11:56 1480503116574_Wed, Nov 30, 2016 11.51 +0100
drwxr-xr-x 3 root root 12K Nov 23 11:25 extracting
drwxr-xr-x 2 root root 64K Nov 30 11:22 updatehistory
The Important Snippet from my Script is:
#!/bin/bash
declare dir=/var/log/scriptlog/jdstate
declare dir2=~/jdownloader/logs
NewFolder=`ls -rt1 ~/jdownloader/logs -I extracting -I updatehistory | tail -1 > /var/log/scriptlog/jdstate/newfolder.log`
OutputNewFolder=`head $dir/newfolder.log -n 1`
cd\ "\"$dir2/$OutputeNewFolder\""
When I try to run the script it shows me the error that it can't find the directory.
But when I copy/paste it, it will go to the Directory.
Any idea how it is possible to go to the directory?
For every one how is searching for an Answer:
this is my latest code snippet wich worked gladly for me
#!/bin/bash
declare dir=/var/log/scriptlog/jdstate
declare dir2=~/jdownloader/logs
NewFolder=`ls -rt1 ~/jdownloader/logs -I extracting -I updatehistory | tail -1 > /var/log/scriptlog/jdstate/newfolder.log`
OutputNewFolder=`head $dir/newfolder.log -n 1`
cd "$dir2/$OutputNewFolder"
I´m sure the can be improvements for the newest folder but htis works just finde for me
I am using Fedora(actually Pidora since I am trying to set up hadoop on a cluster of raspberrypi). I installed oopenjdk on all of the nodes using ansible. However, when I tried to set up the JAVA_HOME environment variable, I got really confused looking at the folder of /usr/lib/jvm:
[root#datafireball1 jvm]# ls
java-1.7.0-openjdk-1.7.0.60-2.4.7.0.fc20.arm jre jre-1.7.0 jre-1.7.0-openjdk jre-1.7.0-openjdk-1.7.0.60-2.4.7.0.fc20.arm jre-openjdk
[root#datafireball1 jvm]# ls -alth
total 80K
drwxr-xr-x 3 root root 4.0K Jun 7 21:07 .
lrwxrwxrwx 1 root root 35 Jun 7 21:07 jre-1.7.0-openjdk -> /etc/alternatives/jre_1.7.0_openjdk
lrwxrwxrwx 1 root root 27 Jun 7 21:07 jre-1.7.0 -> /etc/alternatives/jre_1.7.0
lrwxrwxrwx 1 root root 29 Jun 7 21:07 jre-openjdk -> /etc/alternatives/jre_openjdk
lrwxrwxrwx 1 root root 21 Jun 7 21:07 jre -> /etc/alternatives/jre
lrwxrwxrwx 1 root root 48 Jun 7 21:07 jre-1.7.0-openjdk-1.7.0.60-2.4.7.0.fc20.arm -> java-1.7.0-openjdk-1.7.0.60-2.4.7.0.fc20.arm/jre
drwxr-xr-x 4 root root 4.0K Jun 7 21:06 java-1.7.0-openjdk-1.7.0.60-2.4.7.0.fc20.arm
Why there are so many folders for Java and which folder should I use as the Java home?
[root#datafireball1 bin]# which java
/usr/bin/java
[root#datafireball1 bin]# ls -alSh /usr/bin/ | grep java
lrwxrwxrwx 1 root root 22 Jun 7 21:07 java -> /etc/alternatives/java
Thanks!
You can add in your .bashrc file:
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
and it will dynamically change when you update your packages.
Best solution tested with Fedora 26 :
echo "JAVA_HOME=/etc/alternatives/jre" >> ~/.profile
source ~/.profile
echo $JAVA_HOME
Use the following command to find out exact path to which java executable under UNIX / Linux:
$ which java (suppose returns /usr/java/jdk1.5.0_07/bin/java)
And then set path as export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java
I need to write rotation of files shell script. I have following format data in a target directory(/backup/store_id/dates_folders)
Like :
cd /backup/
drwxr-xr-x 5 root root 4096 Mar 25 12:30 44
drwxr-xr-x 3 root root 4096 Mar 25 12:30 45
drwxr-xr-x 4 root root 4096 Mar 25 12:30 48
drwxr-xr-x 3 root root 4096 Mar 25 12:30 49
cd /backup/44/
drwxr-xr-x 2 root root 4096 Mar 25 12:30 22032014
drwxr-xr-x 2 root root 4096 Mar 25 12:30 23032014
drwxr-xr-x 2 root root 4096 Mar 25 12:30 24032014
drwxr-xr-x 2 root root 4096 Mar 25 12:30 25032014
now 44 (store_id) contain four dates folders. I want each store_id( like 44 folder) contain only three recent dates folder like 23,24,25 & 22 should be deleted. Please help me how to write in shell script. Please give me some hint
This should work:
cd /backup && ls -d */ | while read storeId; do rm -r `ls -r $storeId | tail -3`; done
I assume here that directory names are more important than their timestamps...
If that is not the case, you should use ls -tr instead of ls -r, to let ls command sort on timestamps...
I have clone a git directory as user bob on a remote machine (after having forwarded the local key). When I clone the repo, the repo appears fine and everything shows up including a .git folder.
Now, I want to copy this folder over to another location which happens to be a link to a folder. When I do a cp -r /tmp/tmp.kk3a8xemvr/* /home/staging/myapp, everything gets copied, but not .git folder. When I explicitly call out the .git folder in the cp command, it gets copied. I also noticed the the .gitignore did not get copied either.
Another strange behavior is when I go to /home/staging/myapp, and I do a rm -rf ./*, the .git folder does not get deleted unless I call it out specifically.
How come simple unix commands behave differently for the .git directory? There is nothing special about its permissions. Could it be that the period in front of the file causes some problems?
drwxr-xr-x 8 staging staging 4096 Oct 12 03:42 .git/
My OS is Ubuntu 12.04 LTS.
Linux myapp 3.2.0-54-virtual #82-Ubuntu SMP Tue Sep 10 20:31:18 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
EDIT
Provide more information for Jonathan: I have update the foldernames to match with the commands below:
# cd /tmp/tmp.kk3a8xemvr <- source, everything is good here.
root#myapp1:/tmp/tmp.kk3a8xemvr; ls -la
total 48
drwx------ 9 bob bob 4096 Oct 13 03:08 .
drwxrwxrwt 7 root root 4096 Oct 13 14:55 ..
drwxrwxr-x 3 bob bob 4096 Oct 13 03:08 ansible
drwxrwxr-x 4 bob bob 4096 Oct 13 03:08 backend
drwxrwxr-x 3 bob bob 4096 Oct 13 03:08 clientdb
drwxrwxr-x 15 bob bob 4096 Oct 13 03:08 dapi
drwxrwxr-x 3 bob bob 4096 Oct 13 03:08 docs
drwxrwxr-x 3 bob bob 4096 Oct 13 03:08 fabfile
drwxrwxr-x 8 bob bob 4096 Oct 13 03:08 .git
-rw-rw-r-- 1 bob bob 44 Oct 13 03:08 .gitignore
-rw-rw-r-- 1 bob bob 68 Oct 13 03:08 README.md
-rw-rw-r-- 1 bob bob 450 Oct 13 03:08 requirements.txt
# cd /home/staging; ls
lrwxrwxrwx 1 staging staging 62 Oct 13 03:06 myapp -> /srv/www/staging.myapp.com/public_html/myapp/
# command I use:
sudo cp -r /tmp/tmp.kk3a8xemvr/* /home/staging/myapp
# cd /home/staging/myapp; ls -la; # <- this is the intended destination;
# .git and .gitignore are missing after applying the cp command.
drwxr-xr-x 9 staging staging 4096 Oct 13 14:59 .
drwxr-xr-x 3 staging staging 4096 Oct 13 03:06 ..
drwxr-xr-x 3 staging staging 4096 Oct 13 03:08 ansible
drwxr-xr-x 4 staging staging 4096 Oct 13 03:08 backend
drwxrwxr-x 2 staging staging 4096 Oct 13 14:59 clientdb
drwxr-xr-x 15 staging staging 4096 Oct 13 03:09 dapi
drwxr-xr-x 3 staging staging 4096 Oct 13 03:08 docs
drwxr-xr-x 3 staging staging 4096 Oct 13 03:08 fabfile
-rw-r--r-- 1 staging staging 68 Oct 13 03:08 README.md
-rw-r--r-- 1 staging staging 450 Oct 13 03:08 requirements.txt
If you do:
sudo cp -r /tmp/tmp.kk3a8xemvr/* /home/staging/myapp
the shell expands the * into 'all file or directory names that do not start with .' (thus omitting .git, etc).
If you do:
sudo cp -r /tmp/tmp.kk3a8xemvr /home/staging/myapp
you will get a subdirectory tmp.kk3a8xemvr created in /home/staging/myapp, which is not what you want, I think.
However, if you do:
sudo cp -r /tmp/tmp.kk3a8xemvr/. /home/staging/myapp
you should find you get everything copied where you want it.
Does SCP have a problem setting file permissions or have I misconfiguration my server?
Use case:
There is a file on a server that I want to edit called "importantFile.txt". The file has owner and group of "master":
ls -l importantFile.txt:
-rw-rw-r-- 1 master master 7 Mar 18 08:11 importantFile.txt
I am called "slave" but luckily, I am in group "master" so I can edit the file as I see fit. However, I'm a lazy slave and can't be bothered to edit the file on the server, I'd prefer to edit the file on my local machine and SCP it to the server:
echo "bored slave info" > importantFile.txt
scp importantFile.txt slave#theServerAddress:/pathToFile/importantFile.txt
If I do this, the contents of the file on the server are uploaded fine and the timestamp of the file is updated but the permissions of the file don't change, the file is still owned by "master". This is a problem because if "slave" uploaded bad content, no one would know it was "slave" who caused the problem, "master" would look guilty.
Perhaps I have to set a umask? if so where? I tried .bash_profile without success and haven't found anything on Google about umask in /etc/ssh/sshd_config.
That's nothing special about scp - try logging on to the server as slave, and editing the file using your favourite text editor... You'll find the same behaviour occurs... Writing to a file does not make you the owner of the file.
Example:
as root
#cd /tmp
#mkdir fubar
#chgrp vboxusers fubar
#cd fubar/
#touch testfile
#chgrp vboxusers testfile
#chmod g+w . testfile
#ls -al
total 16
drwxrwxr-x 2 root vboxusers 4096 2009-03-19 10:30 .
drwxrwxrwt 15 root root 12288 2009-03-19 10:29 ..
-rw-rw-r-- 1 root vboxusers 0 2009-03-19 10:30 testfile
#echo foo > testfile
#ls -al
total 20
drwxrwxr-x 2 root vboxusers 4096 2009-03-19 10:30 .
drwxrwxrwt 15 root root 12288 2009-03-19 10:29 ..
-rw-rw-r-- 1 root vboxusers 4 2009-03-19 10:30 testfile
as user (in vboxusers group)
>cd /tmp/fubar
>ls -al
total 20
drwxrwxr-x 2 root vboxusers 4096 2009-03-19 10:30 .
drwxrwxrwt 15 root root 12288 2009-03-19 10:29 ..
-rw-rw-r-- 1 root vboxusers 4 2009-03-19 10:30 testfile
>echo bar >> testfile
>ls -al
total 20
drwxrwxr-x 2 root vboxusers 4096 2009-03-19 10:30 .
drwxrwxrwt 15 root root 12288 2009-03-19 10:29 ..
-rw-rw-r-- 1 root vboxusers 8 2009-03-19 10:31 testfile
>vim testfile
>ls -al
total 20
drwxrwxr-x 2 root vboxusers 4096 2009-03-19 10:31 .
drwxrwxrwt 15 root root 12288 2009-03-19 10:31 ..
-rw-rw-r-- 1 root vboxusers 12 2009-03-19 10:31 testfile
>cat testfile
foo
bar
baz
You have to delete the file to overwrite it. Wether you are able to do that depends on the directory's permissions and ownership. Hijacking ownership of an already existing file is not possible. The write permission you have is only applied on the contents of the file.
It seems you can configure how Emacs deals with this through the backup-by-copying-when-mismatch variable (see the Emacs Manual or type C-h-v backup-by-copying-when-mismatch in Emacs).
I actually filed a bug report about this, because I thought it was a bug in Tramp.
I had misunderstood the way files work, modifying file contents do not change ownership or group.
Why the confusion? EMACS - Whenever I was editing a file I was using Emacs and Emacs does change the owner and group to the current user. It does this because it makes a backup file at save time by moving the "filename" to "filename~" and creating a new file called "filename" - because it's a new file, it has the current users file permissions. I guess this is 1up to VI fans?