Currently all options to salt are taken from the command line, however it would be far more efficient and practical to optionally take all of these from a client_acl enabled user's RC file in YAML format. It should be available for root too. Perhaps this file could be stored in $HOME/.salt/saltrc falling back to $HOME/.saltrc when the former is not present.
This $HOME/.salt/ directory could also hold future files and data for the named user. Some ideas for extra options which could be taken from the command line and in the RC file include:
formatting:
- pager: LESS='FSRX' less
- fd: single
Now we know the user requests that output from salt should be displayed through less, so they don't have to scroll up when reading. An added bonus here would be sending output from targets to multiple FD's so that less can then switch cleanly between the FD's with :n and :1, :2, :3, etc...
formatting:
- pager: LESS='FSRX' less
- fd: multiple
logging:
- file.directory: ~/.salt/log
- format: %h-%m-%M-%Y.log
or
logging:
- file.managed: ~/.salt/log
- format: %h-%m-%M-%Y.log
It would be tempting to take INI format using configparser (Python2)/ConfigParser (Python3), but I would advocate against that since Salt is coupled with YAML.
Ahh, yes, this would be a nice feature, and easy to add. I have approved this for the future.
For reference when we get here, this can be added to the config.py file in the client config section
Can we mark this with the Feature tag?
Done.
It looks like salt is doing this now. Unfortunately, I don't have a ~/.salt and it keeps creating a directory there, then placing the master log inside containing a traceback about how it can't read .salt because it's a directory. new bug? wrong issue? my fault??
I think we fixed this. Previously, there was a naming conflict. Salt would look for (and sometimes create) a ~/.salt/ directory, but somewhere else would look for a file ~/.salt. I renamed the latter to ~/.saltrc. Pretty sure that fix made it into 2014.1.4, maybe even 2014.1.3.
I am going to close this, because I think you're right, this is now supported.
@basepi is this fixed in git? I see it's 'my fault' due to perms, but not a great fall-through:
(...)
[DEBUG ] The user 'schannel' is not allowed to write to '/var/log/salt/master'. The log file will be stored in '~/.salt/'master'.log'
[DEBUG ] Reading configuration from /etc/salt/master
[DEBUG ] Reading configuration from /Users/schannel/.salt
[ERROR ] An un-handled exception was caught by salt's global exception handler:
IOError: [Errno 21] Is a directory: '/Users/schannel/.salt'
(traceback...)
er, sorry:
$ salt --versions-report
Salt: 2014.1.4
Python: 2.7.5 (default, Mar 9 2014, 22:15:05)
Jinja2: 2.7.2
M2Crypto: 0.22
msgpack-python: 0.4.2
msgpack-pure: Not Installed
pycrypto: 2.6.1
PyYAML: 3.11
PyZMQ: 14.3.0
ZMQ: 4.0.4
@seanchannel 95% sure this was fixed here https://github.com/saltstack/salt/commit/6ab1bca7 and was cherry-picked to be included in the 2014.1.5 release.
Do we have any usage docs on this?
Do we have any usage docs on this?
No - I just stumbled over this line in the logs
[DEBUG ] Missing configuration file: ~/.saltrc
and started searching for it to see how this can make my configuration live easier - no docs yet.
I also find it confusing that it's milestone approved but that progress thingy is only halfway done, although it is released alread since 2014.1.whenever ...
To the best of my recollection much of the .saltrc work was done in a sprint by @justincarmony.
Hrm, the work I did was with Saltfiles & salt-ssh: http://docs.saltstack.com/en/latest/topics/ssh/#define-cli-options-with-saltfile
@jfindlay Could we get this re-opened since it doesn't seem implemented, or if it is, it's not documented in any way that I can find.
I just saw [DEBUG ] Missing configuration file: ~/.saltrc in my debug output on 2016.11.4
@pgporada I'm not sure why that would be a problem?
Ah, I don't think the debug comment is a problem. I failed to articulate, "What can I put in this ~/.saltrc?"
I added the following to ~/.saltrc
output: json
And now I get the following on the cli
[boucha@elsapo ~]$ sudo salt \* test.ping
{
"dasalt": true
}
{
"cent6test": "Minion did not return. [Not connected]"
}
It appears that the ~/.saltrc has to be valid yaml. Is this just for key/value pairs that you would normally use on the command line? I'm not sure how to put in options like --summary
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.
Most helpful comment
I added the following to
~/.saltrcAnd now I get the following on the cli
It appears that the
~/.saltrchas to be valid yaml. Is this just for key/value pairs that you would normally use on the command line? I'm not sure how to put in options like--summary