salt-ssh trying to write to wrong log file path

Created on 29 Sep 2015  Â·  23Comments  Â·  Source: saltstack/salt

I use salt-ssh with a Saltfile to change the location of most files. I ran a test with the current develop branch and this warning popped up. I can run 2015.8 without problems.

$ salt-ssh vagrant-test test.ping
[WARNING ] Failed to open log file, do you have permission to write to /path/to/salt/var/log/salt/master?

Relevant bits from my Saltfile:

salt-ssh:
  config_dir: ./config
  log_file: ./logs/ssh

Master config sets the root directory to the CWD:

root_dir: ./
Bug Confirmed Core Salt-SSH phase-plan severity-medium status-to-do team-ssh

Most helpful comment

ssh_log_file: /tmp/salt-ssh-log.log option in the Saltfile works for me.

ssh_log_file instead of log_file

All 23 comments

@anlutro, thanks for the report. I think this was fixed recently, but I cannot find the pull request, so I am wondering if a merge forward from 2015.8 will fix this for develop.

ping @basepi

OK. If you ping me when a merge forward happens, I'd be happy to test again.

On Tue, 29 Sep 2015 20:21 Justin Findlay [email protected] wrote:

@anlutro https://github.com/anlutro, thanks for the report. This was
fixed recently, but I cannot find the pull request, so I am wondering if a
merge forward from 2015.8 will fix this for develop.

ping @basepi https://github.com/basepi

—
Reply to this email directly or view it on GitHub
https://github.com/saltstack/salt/issues/27491#issuecomment-144144887.

@anlutro, once #27531 is merged, you should be ready to test again, thanks.

It's merged now. The only fixes not in develop are the fixes from 2015.5 included here: https://github.com/saltstack/salt/pull/27525

They'll go in next merge forward.

The issue persists.

@anlutro, I found the issue: #27063. This may be a duplicate of that.

I don't think it's related - that issue relates to the /var/log/salt directory not being created when a yum package is being installed. Unrelated to salt-ssh and a different log path altogether.

I think the issue here is that salt-ssh shouldn't be trying to log to a master file in the first place. salt-ssh isn't a master and shouldn't be logging there, salt-ssh already has its dedicated log file as defined in the Saltfile.

@anlutro, that makes sense. I'm juggling too many issues right now.

It turns out, if I provide a --log-file=whatever argument to salt-ssh, the log path from my Saltfile is read correctly. Amusingly, the actual argument I pass to --log-file doesn't matter, unless I remove the log_file option from my Saltfile.

I tried debugging further, but the various mixins in parsers.py are not easy on the brain.

That is....super weird. But good to know!

Bumping because this is still an issue in 2016.3 HEAD.

Progress! From 2015.8, some lines in parsers.py have changed from this:

elif value is not None and value != default:

to this:

elif value is not None and getattr(option, "explicit", False):

I don't know the reason for this, I'm guessing they're good, but if I revert this change, the warning disappears and logging works as expected.

-> if option.dest not in self.config:
(Pdb) print(option)
--log-file
(Pdb) print(option.explicit)
*** AttributeError: 'CustomOption' object has no attribute 'explicit'

It looks like optparse never calls take_action, which means the explicit property never gets set.

I found the related PR: https://github.com/saltstack/salt/pull/25785

@htch Do you have any ideas what the best way to fix this would be?

This seems to have had a regression at some point - with 2016.11 I'm getting similar errors.

Failed to create path "/var/log/salt/ssh" - [Errno 13] Permission denied: '/var/log/salt'

Actually seeing the same problem with a git checkout of 2016.3.

Same pb for me (salt-ssh 2016.11.1 (Carbon)):
[WARNING ] Failed to open log file, do you have permission to write to /var/log/salt/ssh?

@anlutro Could you open a new issue referencing this issue, and mark it as a regression. This will allow us to track the issue better, given the large number of codes changes since 2015.5.

@anlutro Never mind, I had stale browser data with it marked closed. I see that you re-opened, which is just as good

ssh_log_file: /tmp/salt-ssh-log.log option in the Saltfile works for me.

ssh_log_file instead of log_file

Confirmed: setting ssh_log_file explicitly does resolve this issue.

+1. Exactly the same here.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

Thank you for updating this issue. It is no longer marked as stale.

Was this page helpful?
0 / 5 - 0 ratings