Hi,
I think I got the mount working. This is kind of counter-intuitive (or maybe it's intuitive), but here's the mount resource that seems to work for me:
mount '/mnt/shareit' do
action :mount
options 'username=administrator,password=XXXXXX'
fstype 'cifs'
device '//192.168.0.110/C/rpms'
end
My "rationale" was that when I had the username= and the password= earlier, the mount was showing up with "-o defaults", i.e., it was basically ignoring the username= and password=. At the same time, it WAS output "-o", so I figured I try putting the username= and the password= in the "options" mount parameter, and BINGO :)!!
I have do a bit more testing but it looks like now that I have the mount apparently working, I can get a modified version of the chef-splunk install_server recipe that uses the RPMs from a file share.
Thanks,
Jim
On Fri, 7/10/15, o haya ohaya@yahoo.com wrote:
Subject: Re: [chef] Re: Re: Re: Re: Re: Using UNC path was Re: Re: Re: Re: A question about chef-splunk cookbook
To: chef@lists.opscode.com
Cc: ohaya@yahoo.com
Date: Friday, July 10, 2015, 9:10 PM
Hi,
FIrst of all, thanks for the help/suggestions.
Secondly, believe it or not, I HAVE been reading, all of
the stuff you've posted, and then more, plus doing hours of
testing, but not all of this is clear. Possibly my own
inadequacies.
Having said that, I've gone back to basics, with just a
recipe that just does a mount, because I was suspecting that
the mount by itself was failing:
mount '/mnt/shareit' do
action :mount
username 'administrator'
password 'xxxxxxxx'
fstype 'cifs'
device '//192.168.0.110/C/rpms'
end
When I run that recipe, I am getting an error:
[root@centos65 ~]#
chef-client -o 'recipe[chef-splunk::test_test]'
Starting Chef Client, version 12.4.0
[2015-07-10T21:03:49-04:00] WARN: Run List override has been
provided.
[2015-07-10T21:03:49-04:00] WARN: Original Run List:
[2015-07-10T21:03:49-04:00] WARN: Overridden Run List:
[recipe[chef-splunk::test_test]]
resolving cookbooks for run list:
["chef-splunk::test_test"]
Synchronizing Cookbooks:
- chef-vault
- chef-splunk
Compiling Cookbooks...
Converging 1 resources
Recipe: chef-splunk::test_test
- mount[/mnt/shareit] action mount
================================================================================
Error executing action mount
on resource
'mount[/mnt/shareit]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but
received '32'
---- Begin output of mount -t cifs -o defaults
//192.168.0.110/C/rpms /mnt/shareit ----
STDOUT:
STDERR: Password: mount error(13): Permission
denied
Refer to the mount.cifs(8) manual page (e.g.
man mount.cifs)
---- End output of mount -t cifs -o defaults
//192.168.0.110/C/rpms /mnt/shareit ----
Ran mount -t cifs -o defaults
//192.168.0.110/C/rpms /mnt/shareit returned 32
Resource Declaration:
---------------------
# In
/var/chef/cache/cookbooks/chef-splunk/recipes/test_test.rb
21: mount '/mnt/shareit' do
22: action :mount
23: username
'administrator'
24: password 'XXXXXXXX'
25: fstype 'cifs'
26: device
'//192.168.0.110/C/rpms'
27: end
28:
Compiled Resource:
------------------
# Declared in
/var/chef/cache/cookbooks/chef-splunk/recipes/test_test.rb:21:in
`from_file'
mount("/mnt/shareit") do
action :mount
supports {:remount=>false}
retries 0
retry_delay 2
default_guard_interpreter :default
mount_point "/mnt/shareit"
device "//192.168.0.110/C/rpms"
device_type :device
fsck_device "-"
fstype "cifs"
options ["defaults"]
dump 0
pass 2
username "administrator"
password "XXXXXXXX"
declared_type :mount
cookbook_name "chef-splunk"
recipe_name "test_test"
end
Running handlers:
[2015-07-10T21:03:49-04:00] ERROR: Running exception
handlers
Running handlers complete
[2015-07-10T21:03:49-04:00] ERROR: Exception handlers
complete
Chef Client failed. 0 resources updated in 1.379714981
seconds
[2015-07-10T21:03:49-04:00] FATAL: Stacktrace dumped to
/var/chef/cache/chef-stacktrace.out
[2015-07-10T21:03:49-04:00] ERROR: mount[/mnt/shareit]
(chef-splunk::test_test line 21) had an error:
Mixlib::ShellOut::ShellCommandFailed: Expected process to
exit with [0], but received '32'
---- Begin output of mount -t cifs -o defaults
//192.168.0.110/C/rpms /mnt/shareit ----
STDOUT:
STDERR: Password: mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man
mount.cifs)
---- End output of mount -t cifs -o defaults
//192.168.0.110/C/rpms /mnt/shareit ----
Ran mount -t cifs -o defaults //192.168.0.110/C/rpms
/mnt/shareit returned 32
[2015-07-10T21:03:49-04:00] FATAL:
Chef::Exceptions::ChildConvergeError: Chef run process
exited unsuccessfully (exit code 1)
[root@centos65 ~]#
It seems like even though I an including username= and
password=, the actual mount command that it ends up doing:
"mount -t cifs -o defaults //192.168.0.110/C/rpms
/mnt/shareit"
i.e., it is using "-o defaults" rather than passing the
username/password to the mount command?
I suspect that that is why the mount is failing, but I've
tried all kinds of permutations in the recipe, and always
end up with the same thing.
Thanks again,
Jim
On Fri, 7/10/15, Tensibai Zhaoying tensibai@iabis.net
wrote:
Subject: [chef] Re: Re: Re: Re: Re: Using UNC path was Re:
Re: Re: Re: A question about chef-splunk cookbook
To: chef@lists.opscode.com
Date: Friday, July 10, 2015, 6:04 PM
First of all, forget about back
slashes, use forward slashes (unless in Windows script
context like bat cmd and powershell)
Secondly, you should really make an effort reading, I
gave you clues and links.
Last try: have a mount resource (I'm pretty sure everyone
permission is only on share and not on the NTFS
permissions,
you should learn about this too) and give
file://mount_target/package.rpm to your splunk_installer
ressource attribute.
Le 10 juil. 2015 22:52, o haya ohaya@yahoo.com
a
écrit :
Hi,
I don't understand what you're suggesting?
Remember, that I'm talking about if it's possible to
do
this with an already-existing cookbook/recipe, the
chef-splunk cookbook.
Also, BTW, I was looking at that cookbook, and it
looks
like that has a "definitions/splunk_installer.rb" that
has:
define :splunk_installer, :url => nil do
cache_dir = Chef::Config[:file_cache_path]
package_file = splunk_file(params[:url])
cached_package = ::File.join(cache_dir,
package_file)
remote_file cached_package do
source params[:url]
action :create_if_missing
end
.
.
.
etc
.
.
so it seems like that code is already using a
remote_file type resource.
And, according to this:
remote_file Resource
The 'source' is defined as:
"Required. The location of the source file. The
location of the source file may be HTTP (http://), FTP
(ftp://), local (file:///), or UNC
(\\host\share\file.tar.gz)."
i.e., the Chef docs explicitly say that a UNC should
be
all right?
So it seems like it SHOULD take an UNC in the "url"
parameter, but then why do I get an error saying it's not
a
URL when I use a UNC (and yes, I have tried with both the
double-back-slashes as well as the
quadruple-back-slashes)?
Thanks,
Jim
On Fri, 7/10/15, Tensibai Zhaoying tensibai@iabis.net
wrote:
Subject: [chef] Re: Re: Re: Using UNC path was Re:
Re:
Re: Re: A question about chef-splunk cookbook
To: chef@lists.opscode.com
Date: Friday, July 10, 2015, 3:06 PM
That's what I meant
by the session, if an UNC path does not work, use
local
filesystem in the cookbook instead of targeting the
UNC
path.
Pseudo code:
Mount '/mnt/target' do
Source '//server/share'
End
Remote_file
'/usr/local/src/package.rpm'
Source '/mnt/target/package.rpm'
End
Package
'/usr/local/src/package.rpm'
Mount '/mnt/target' do
Action :unmount
End
Writen on phone and by memory,
no guarantee a copy paste will work but I hope it
gives
the
idea.
Le 10 juil. 2015 20:22, o
haya ohaya@yahoo.com
a
écrit :
Hi,
The share was
configured with permissions for "Everyone", so I
can see the share without any credentials.
So, for example, when
I did the mount to /mnt/shareit, I could do "ls
/mnt/shareit" and see the RPM files there.
For the test where I
used the mount, I:
- Did "mount"
- executed "chef-client -o
'recipe[chef-splunk::install_server]'
And I got the error.
Jim
On Fri, 7/10/15, Tensibai Zhaoying tensibai@iabis.net
wrote:
Subject:
[chef] Re: Using UNC path was Re: Re: Re: Re: A
question
about chef-splunk cookbook
To: chef@lists.opscode.com
Date: Friday, July 10, 2015, 1:43 PM
Usually if the
share need
credentials the path is to
mount the share, remote_file with
local path to the mounted share as source and then
unmount.
Is this what you
tried ? On Linux, unlike Windows the share access
rights are
not stored in the user session
Le 10 juil. 2015
18:12, o haya ohaya@yahoo.com
a
écrit :
Hi,
Sorry it's taken
so long to try this, but so far, I
haven't been able to
make it work:
[root@centos65 splunk]#
chef-client -o
'recipe[chef-splunk::install_server]'
Starting Chef
Client, version 12.4.0
[2015-07-10T12:05:52-04:00] WARN: Run
List override has been provided.
[2015-07-10T12:05:52-04:00] WARN: Original Run List:
[2015-07-10T12:05:52-04:00] WARN:
Overridden Run List:
[recipe[chef-splunk::install_server]]
resolving
cookbooks for run list:
["chef-splunk::install_server"]
Synchronizing Cookbooks:
chef-splunk
Compiling Cookbooks...
Converging 2 resources
Recipe: chef-splunk::install_server
remote_file[/var/chef/cache/splunk-6.0.7-241889-linux-2.6-x86_64.rpm]
action
create_if_missing[2015-07-10T12:05:52-04:00] WARN:
remote_file[/var/chef/cache/splunk-6.0.7-241889-linux-2.6-x86_64.rpm]
cannot be downloaded from
file://192.168.0.236/h/INSTALL-FILES-CENTOS6-and-CHEF/SPLUNK/splunk-6.0.7-241889-linux-2.6-x86_64.rpm:
No such file or directory @ rb_sysopen
/h/INSTALL-FILES-CENTOS6-and-CHEF/SPLUNK/splunk-6.0.7-241889-linux-2.6-x86_64.rpm
================================================================================
Error
executing action
create_if_missing
on resource
'remote_file[/var/chef/cache/splunk-6.0.7-241889-linux-2.6-x86_64.rpm]'
================================================================================
Errno::ENOENT
No such file
or directory @
rb_sysopen -
/h/INSTALL-FILES-CENTOS6-and-CHEF/SPLUNK/splunk-6.0.7-241889-linux-2.6-x86_64.rpm
Resource
Declaration:
# In
/var/chef/cache/cookbooks/chef-splunk/definitions/splunk_installer.rb
26:
remote_file cached_package do
27: source params[:url]
28: action
:create_if_missing
29: end
30:
Compiled
Resource:
# Declared
in
/var/chef/cache/cookbooks/chef-splunk/definitions/splunk_installer.rb:26:in
`block in from_file'
remote_file("/var/chef/cache/splunk-6.0.7-241889-linux-2.6-x86_64.rpm")
do
params
{:url=>"file://192.168.0.236/h/INSTALL-FILES-CENTOS6-and-CHEF/SPLUNK/splunk-6.0.7-241889-linux-2.6-x86_64.rpm",
:name=>"splunk"}
provider Chef::Provider::RemoteFile
action :create_if_missing
retries 0
retry_delay 2
default_guard_interpreter :default
path
"/var/chef/cache/splunk-6.0.7-241889-linux-2.6-x86_64.rpm"
backup 5
atomic_update
true
source
["file://192.168.0.236/h/INSTALL-FILES-CENTOS6-and-CHEF/SPLUNK/splunk-6.0.7-241889-linux-2.6-x86_64.rpm"]
use_etag true
use_last_modified true
declared_type :remote_file
cookbook_name
"chef-splunk"
recipe_name
"install_server"
end
Running
handlers:
[2015-07-10T12:05:52-04:00] ERROR: Running exception
handlers
Running handlers complete
[2015-07-10T12:05:52-04:00] ERROR:
Exception handlers complete
Chef
Client failed. 0 resources updated in
1.425198167 seconds
[2015-07-10T12:05:52-04:00] FATAL:
Stacktrace dumped to
/var/chef/cache/chef-stacktrace.out
[2015-07-10T12:05:52-04:00] ERROR:
remote_file[/var/chef/cache/splunk-6.0.7-241889-linux-2.6-x86_64.rpm]
(chef-splunk::install_server line 26)
had an error:
Errno::ENOENT: No such
file or directory @ rb_sysopen -
/h/INSTALL-FILES-CENTOS6-and-CHEF/SPLUNK/splunk-6.0.7-241889-linux-2.6-x86_64.rpm
[2015-07-10T12:05:52-04:00] FATAL:
Chef::Exceptions::ChildConvergeError: Chef run
process
exited unsuccessfully (exit code 1)
[root@centos65 splunk]#
I've
tried it using both directly like
above using
"file://192.168.0.236/h/INSTALL-FILES-CENTOS6-and-CHEF/SPLUNK/splunk-6.0.7-241889-linux-2.6-x86_64.rpm"
in the chef-splunk attributes, and
also tried creating a
mount at
/mnt/shareit (and confirming I can see the RPMs at
the mount) and get the same error.
Is there
something else I need to do with
the
file:// URL?
Thanks,
Jim
On Tue, 7/7/15, Steven Murawski
steven.murawski@gmail.com
wrote:
Subject:
[chef]
Re: Re: Re: A question about chef-splunk cookbook
To: chef@lists.opscode.com
Cc: "o
haya" ohaya@yahoo.com
Date:
Tuesday, July 7, 2015, 6:14 PM
Also, as of 12.4.0,
remote_file can
use UNC paths!
Steve
Steven MurawskiCommunity Software
Development Engineer @
ChefMicrosoft
MVP - PowerShell
http://stevenmurawski.com
On 7/7/2015 5:07:44
PM, o haya ohaya@yahoo.com
wrote:Hi Tensibai,
Thanks. I will give that a try as soon
as
I figure out another problem I
just
started having (with
Chef and CENTOS).
Jim
On Tue,
7/7/15,
Tensibai Zhaoying wrote:
Subject: [chef] Re: A question about
chef-splunk cookbook
To: chef@lists.opscode.com
Date: Tuesday,
July 7, 2015, 5:52 PM
I
don't know for the
slunk cookbook
itself (didn't use it)
but
assuming it
takes advantage of remote_file resource
I'm sure yes as
my sole
contribution to chef was on the
file:// url
code and
I did test for this kind of path for
Unix
and
Windows
T.l.;d.r Should be
yes but may
work with a UNC path
file://server/share/file.rpm too
if the
share is browsable
as anonymous
(everyone
read permission
in
share and
NTFS acl)
Le 7
juil. 2015 22:49,
o haya a
écrit :
Hi,
I'm
starting to
look at using the chef-splunk cookbook:
GitHub - sous-chefs/chef-splunk: Development repository for the chef-splunk cookbook
I'm not
sure if there
is somewhere else more
appropriate for
questions, so
I'm posting here.
Hopefully
that's
ok
(otherwise please point me
to the
correct place?)?
Anyway, the
question I have is whether
this can
support
using
file:// type URLs for
the location
of
the Splunk
server and
Splunk forwarder RPMs?
If possible, we
would
like to setup a
CIFs mount, say at
/mnt/splunk_rpms,
pointing to a
Windows share, and then use
something
like
"file:///mnt/splunk_rpms/the_splunkserver.rpm" in
the
attribute.
Will something
like that work?
Thanks,
Jim