-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
have salt states be in another location than current directory #92
Comments
I think this is similar to #83 . Can you please share your |
yea, essentially what I did was create a symbolic link to services dir in the current kitchen dir
I quickly realized that salt_file_root refers to the root on the minion in vagrant, not on the host application. So I was trying different provisioner options but none of them worked. So now I have the following config inside services dir:
This works but is unfortunately undesired because we want to keep the testing code separate from the production code, ie the salt states. |
Thank you for the configuration. Could you give the directory tree information for your project (run Also, just a quick thought, would setting custom |
Ideally I would not want to have that symbolic link there. This current setup does not work. I need to go right into the services dir and have that as my current working directory. I believe if that PR is merged I can set file_roots to be /tmp/kitchen/srv/salt/services and it would work with that setup. What I would really would like to do is remove that symbolic link and just tell kitchen to copy all files from ../../app/com/site/pivot/salt/salt/saltmaster/default/services to the minion rather than start from the current dir. That way I wouldn't have to touch the minion config. Please lmk how difficult that would be to implement or whether there is another better solution. |
In fact, I think we have a similar need. Mine is to have a file structure like this for my formula.
It let testing code separated from production code. |
Thanks for extensive explanations. I understand the workflow, however I personally think this isn't a way to keep testing code separate from production code. I would view a git repository as part of development, thus the integration as such is done on the repository wise. If you would use a proper distribution method (e.g. SPM), you could have Still, I think a PR for this would be welcome and a nice addition so we can cover more use-cases. |
For me, it's not a distribution problem, it's just a clarity one: to keep "real"/production/runtime code separated from testing one. |
@daks looking by your example, I see you would just like to have a separate |
@ek9 I agree with that, I want to have tests in the same repository as code, but I want to separate them in different directories. |
Looks like there is an undocumented option, Can you test that and let me know if solves this issue? Thanks, |
I tried to use this undocumented option, removing all previous use of pillars/state_top/pillars-from-files. My kitchen.yml looks like
and directory is
When I login to the Kitchen VM, pillar seems ok but not states
I'm not sure if I need to use this option with other ones, I'll try some. [update] seems my original salt/ directory became salt/haproxy one. Moreover I'm not the sure it's the solution to my problem because I don't find my original formula directory. |
Hi @gtmanfred |
@anuriq that does not appear to be related to this issue, can you open a new issue? Thanks, |
My god, that took a while to figure out. Like many of you, I have a repo that looks like this: (lightly edited) ❯ tree .
.
├── docs
│ └── kitchen
│ ├── readme.md
│ └── set-up-kitchen.md
├── Gemfile
├── Gemfile.lock
├── _kitchen
│ └── minion.erb
├── kitchen.yml
├── pillars
│ ├── base
│ │ ├── common
│ │ │ ├── data.sls
│ │ │ └── packages.sls
# <...>
│ └── readme.md
├── readme.md
├── states
│ ├── core
│ │ ├── init.sls
│ │ ├── ubuntu
│ │ │ └── remove_snapd.sls
│ │ └── users.sls
│ └── top.sls
└── tests Basically ONE repo with a After reading through this thread and the docs and the code, I didn't find any combination of flags in the kitchen.yml that would work. I finally found a way to make it work, but it's not pretty. Here is a sanitized version of my kitchen.yml: driver:
# See: https://github.com/test-kitchen/kitchen-docker
name: docker
# <...>
platforms:
# If no version explicitly set, will default to latest
- name: ubuntu
driver_config:
run_command: /lib/systemd/systemd
transport:
name: rsync
# What kitchen will use to converge the state/test instance
provisioner:
name: salt_solo
# Note: periodically, this will need to be updated/refreshed
salt_bootstrap_url: https://github.com/saltstack/salt-bootstrap/releases/download/v2024.11.27/bootstrap-salt.sh
# Wait for ssh before provisioning
install_after_init_environment: true
is_file_root: true
# Actual salt states to test
suites:
# Test core/init.sls
- name: core
provisioner:
salt_env: base
salt_pillar_root: /srv/salt/pillars
# There is something fucky and non-obvious about how the files are copied around.
# The docs are leave both thoroughness and accuracy to be desired!!!
# After a lot of trial/error, I think this is the cheapest hack that uses kitchen purely as a "copy everything in, just call salt"
# tool.
salt_minion_config_template: _kitchen/minion.erb
# -X disables daemon after install which is exactly what we want w/ an ephemeral container
salt_bootstrap_options: -X -p git -p nano stable
verifier:
#<...> Really, the key is that I am NOT trying to configure any of the "helpful" path modification things that mess w/ where stuff gets copied to. The critical bit that makes this all work is my custom # Cut down copy of
# https://github.com/saltstack/kitchen-salt/blob/03a438aadf8c73b8e49820d21f44a468e0632901/lib/kitchen/provisioner/minion.erb
# @markup text
local: true
state_top: top.sls
root_dir: <%= config[:root_path] %>
# Hello from my minion.erb template!
file_roots:
<%= config[:salt_env] %>:
- <%= os_join(config[:root_path], config[:salt_file_root], 'states') %>
pillar_roots:
<%= config[:pillar_env] || config[:salt_env] %>:
- <%= os_join(config[:root_path], config[:salt_pillar_root], 'pillars') %> Essentially this is the same as the default one (minus windows stuff; don't use it) but I am ADDING the I hope this helps someone else. I spent a lot of time on this and I hope to save someone else some time. |
I was not able to figure out a way to have the salt states be in a directory other than the current one where .kitchen.yaml is defined. For instance we have some_path/tests/kitchen_tests, where I would like to keep the yaml file. Then the actual salt state I want to use is in some_path/other_path/services/my_state_dir. It looks like the only way to get kitchen-salt to find the my_state_dir is if you put .kitchen.yaml inside the services dir.
It would be nice to have this functionality if it is not already there.
The text was updated successfully, but these errors were encountered: