Entry in pillar top.sls with dot in path does not work
Hey folks,
with the version 0.14.0 it does not work to have a dot in a dirname which servers a pillar.
Example: As a top.sls in /srv/pillar
base:
'*'
- data
- dir.with.dot.in.dirname
With a pillar tree structure as follows: /srv/pillar/ /srv/pillar/top.sls /srv/pillar/data/init.sls /srv/pillar/dir.with.dot.in.dirname/init.sls
Issuing $ salt-call pillar.data --local will complain, that dir.with.dot.in.dirname was not found.
Yes, this has never worked to my knowledge, did this used to work?
no, it never worked. Is there a reason this should not work? I mean, isn't that a limitation when you can't structure the pillar tree in the way you like?
dot delimitation is used to determine where sls files are, which means that this introduces a conflict in the sls lookup, there way be a way to to still allow dotted directories, but I have not looked at it for a while
Is there a specific reason you need dots in the filename, @majo83? You can still have dots in other filenames you reference with salt:// in your actual states. This seems like something that would be really complex to implement when it would be easy to just eliminate dots in sls filenames. shrugs
My reason for using dots in a filename is this: I would like to name directories with the names of my servers (/srv/salt/servers/www.example.com) and use some macro-processing to e.g. automatically setup the backup for each of my minions easily. Here it would e.g. for-loop over all the directories in /srv/salt/servers/ and be able to ping the dirname directly. Call it a convention-over-configuration-approach.
My current solution is just to use another character instead of . (in my case: =) and to regex afterwards. Not a beautiful solution, but I can live with it.
OK, I'm glad you found a solution, sorry it wasn't ideal.
Guys, I know you are busy with other saltstack functionality, just want to add my view - if there is a feature prioritization list then I would vote for this one being reasonably high, as saltstack itself is about managing configs for hosts on the network, and having host names represented properly in configs is important for clarity of the configs. I just spent an hour trying to understand what's wrong with my names, and I'm sure many other ppl would bump into the same issue again and again. Disclaimer - I'm new to saltstack, so hope I don't add much nonsense.
@juso So you have host names with dots in them, and want to have your sls names have those same dots in them?
@basepi, yes, exactly. As I said I'm new to saltstack, and thus may not fully understand some things, but for me it would be natural to have FQDN when I'm specifying a config/state for a particular host. May be for group of hosts it's less relevant though would imagine it may also make sense, like web-servers.foo.intra and web-servers.bar.intra. Currently I'm using approach suggested by majo83, but it's not that convenient e.g. when you generate configs automatically and generally from comprehension PoV. But as I don't know the current priority list on your side I can only express some modest wish. Otherwise I found using Saltstack very easy and straightforward. Hope this helps.
The problem with this particular request is that it really can't coexist with the current model -- that is, referencing the directory structure in the same way python modules do it, with dots. So we have to either choose to keep the current, established method, or make everyone change the way they reference their states. So my bet is this probably won't change for awhile, if at all, unless we decide to add a configuration option or something, though that causes more code complexity.
We're definitely open to suggestions, we just don't like breaking all the existing SLS files. =P
@basepi, that's ok, I can live with it. May worth documenting it somehow (or adding some special error message), so noobs like me don't get nuts trying to understand what's wrong with the names. And again - great product, thanx a lot for supporting it!
We're glad you like it! And welcome to the community! =)
I'm needing this for an include and referencing from a python deploy script that I'd like to use the servers FQDN like others here.
Using the relative path reference that was recently added, I'm able to include like so:
includes:
- .configuration
This gets around the full reference (that has dots).
And for my python script I can use the host name in salt by appending .replace('.','-') to any reference using the FQDN (after renaming the sls dirnames of course)
SOLUTION SUGGESTION.
Can we add a feature that if salt fails to find an sls that is referenced with dots in the current way it then falls back to looking for files with dots rather than falling? This won't break anything but makes the look up a little more robust. That way an error saying it can't find the sls means it really can't.
@DaveQB This is a very reasonable suggestion, I like it a lot. I'm re-opening this issue, I think we should add the solution you mentioned.
@basepi Thanks!
I posted this on google groups as my current work around..
My simple work-around was to create a symlink with dots replaced with dash and that way all existing references in salt:// and other scripts outside salt didn't break. Means I have a folder with two references to the same thing but it is working.
Actually the other way around, but doesn't matter which is pointing to which, just as long as both references work.
./ssnt.edu.au -> ./ssnt-edu-au ./billyblue.edu.au -> ./billyblue-edu-au ./apm.edu.au -> ./apm-edu-au ./jni.edu.au -> ./jni-edu-au ./williamblue.edu.au -> ./williamblue-edu-au ./catc.edu.au -> ./catc-edu-au ./ancb.edu.au -> ./ancb-edu-au ./acnt.edu.au -> ./acnt-edu-au
Why not just escape the period so dir.name would be dir.name?
@gtmacdonald Have you tried this? I didn't know that worked, though I've never tried it.
No. I'm asking why they don't put that functionality in. I kind of expected it... On Mar 27, 2014 8:40 AM, "Colton Myers" [email protected] wrote:
@gtmacdonald https://github.com/gtmacdonald Have you tried this? I didn't know that worked, though I've never tried it.
Reply to this email directly or view it on GitHubhttps://github.com/saltstack/salt/issues/4610#issuecomment-38820116 .
Heh, it's a decent solution. The problem will be making sure that YAML and Python don't consume that escape.
I'd be great. Don't forget to escape the escape too. On Mar 27, 2014 9:21 AM, "Colton Myers" [email protected] wrote:
Heh, it's a decent solution. The problem will be making sure that YAML and Python don't consume that escape.
Reply to this email directly or view it on GitHubhttps://github.com/saltstack/salt/issues/4610#issuecomment-38825869 .