saltstack / kitchen-salt

SaltStack provisioner for test-kitchen
MIT License
200 stars 112 forks source link

Wrong softlink created by formula-fetch? #197

Open soostdijck opened 6 years ago

soostdijck commented 6 years ago

I've been having trouble with the softlink that is created by the function linkFormulas() inside lib/kitchen/provisioner/formula-fetch.sh. For me it's creating a broken softlink to a dependency, inside my vagrant/kitchen test box.

My kitchen converge output is:

       Install External Dependencies
       Fetching: access
       git clone https://bitbucket.ripe.net/scm/salt/formula-access.git /usr/share/salt-formulas/env/_formulas/access -b master
       Cloning into '/usr/share/salt-formulas/env/_formulas/access'...
       remote: Counting objects: 248, done.
remote: Compressing objects: 100% (243/243), done.
remote: Total 248 (delta 121), reused 0 (delta 0)
Receiving objects: 100% (248/248), 63.04 KiB | 0 bytes/s, done.
Resolving deltas: 100% (121/121), done.
       chown: invalid user: ‘kitchen.kitchen’
       chown: invalid user: ‘kitchen.kitchen’
       Content of /tmp/kitchen//srv/salt :
       total 4
       drwxrwxr-x. 3 vagrant vagrant  47 Jan 22 11:55 .
       drwxrwxr-x. 4 vagrant vagrant  32 Jan 22 11:55 ..
       lrwxrwxrwx. 1 root    root     52 Jan 22 11:55 access -> /usr/share/salt-formulas/env/_formulas/access/access
       drwxrwxr-x. 4 vagrant vagrant 171 Jan 22 11:55 exim
       -rw-rw-r--. 1 vagrant vagrant  26 Jan 22 11:55 top.sls
       [ERROR   ] Specified SLS 'access.userfiles' in environment 'base' is not available on the salt master
       [ERROR   ] Template was specified incorrectly: False
       [CRITICAL] Pillar render error: Specified SLS 'access.userfiles' in environment 'base' is not available on the salt master

The softlink should instead link to access -> /usr/share/salt-formulas/env/_formulas/access and all would be well...

I think the issue is line 76 inside formula-fetch.sh - there is a $name too many. However I'm having a hard time testing this (to make a useful PR). I can't find how to change the salt_solo provisioner so that it pulls the scripts from https://github.com/saltstack/kitchen-salt/tree/master/lib/kitchen/provisioner from some other url.

soostdijck commented 6 years ago

I think part of the problem might lie in the fact that I've put my .kitchen.yml inside the formula subdirectory, so my path looks like ~/git/salt/formula-core/exim/.kitchen.yml. I've got 'is_file_root: true'.

The reason for this layout in my case is that I have one formula-style git repo with multiple formulas in that same repo to keep the amount of repo's to a reasonable amount. So my layout it something like this:

ls -1 ~/git/salt/formula-core/
Gemfile
Gemfile.lock
README.md
exim
iptables
motd
munin-node
nrpe
ntp
selinux
snmp
etc...
gtmanfred commented 6 years ago

is exim your formula root? or is git/salt/formula-core? because that is where all the formulas are located.

You might take a look at using dependencies with paths to the formula directories?

soostdijck commented 6 years ago

The formula root is git/salt/formula-core but because there are many formulas in one git repo I have a .kitchen.yml in each subdirectory (exim, snmp, ntp,etc), so something like git/salt/formula-core/exim/.kitchen.yml.

My intention is to keep the kitchen configs simpler by not having one monolithic one at the top level of my formula (like hot it's normally done in formulas).

epcim commented 6 years ago

note: formula fetch scritpt is bit special way escaped as kitchen do some magic with it when transporting/running it. was a nightmare. imho it is not usable/test-able out of kitchen. I may link the other version for comparison.the link command is missing expected kitchen user as i see in logs.we actually link the pillar files on the formula. I would like to keep the functionality but probably document, generalize the concept and make it conditional if /metadata folter resides on the repo.

soostdijck commented 6 years ago

It would be nice if there was an option to pull these scripts from a custom location. Then users can hack around all they want.

gtmanfred commented 6 years ago

I want to move this away from these scripts, and instead put as many of the dependencies in the sand box as possible (besides spm) so that they are just transferred over.

soostdijck commented 6 years ago

Currently the state is "info needed". What info do you need? :)

gtmanfred commented 6 years ago

updated