
В документации указано, что если вы используете
salt_top_saltenv: base
в главной конфигурации я могу заставить всех миньонов использовать только базовый saltenv для верхнего файла, игнорируя все остальные верхние файлы, это правильно?
Если state_top_saltenv установлен на base, будут применены все состояния из всех сред в базовом файле top, в то время как все остальные файлы top будут проигнорированы.
Я пытаюсь использовать Gitfs в качестве бэкэнда и получаю странные результаты (state.show_top) не соответствует ничему.
У меня следующая конфигурация
- Единый репозиторий git
- 4x референсы, база, разработка, постановка, производство
Я пытаюсь достичь единого refs (базы) для верхнего файла, а затем состояний из каждой среды. Затем я могу продвигать изменения через среды с помощью слияния и попытаться сохранить top.sls как можно более статичным.
##### Salt Master config #####
salt_top_saltenv: base
top_file_merging_strategy: same
gitfs_base: base
gitfs_saltenv:
- base:
- ref: base
- development:
- ref: development
- staging:
- ref: staging
- production:
- ref: production
gitfs_remotes:
# Salt States
- ssh://[email protected]/Salt.git:
- name: salt
- root: states
- mountpoint: salt://
##### How the repo is laid out #####
# Base Branch
README.md
.gitignore
states/top.sls
# Development Branch
README.md
.gitignore
states/Test/init.sls
# Staging Branch
README.md
.gitignore
states/Test/init.sls
# Production Branch
README.md
.gitignore
states/Test/init.sls
##### Top.sls #####
{# The saltenv variable represents the environment the Minion is configured
to #}
{{ saltenv }}:
'*':
# Apply states.test to everything from the matching env
{%- do salt.log.info("Applying Salt states.test from" + saltenv +
"environment" ) %}
- states.Test
##### Example Minion config ######
master: salt-master.mydomain.com
saltenv: development
From the Minion I am able to list the files on the Master correctly as
expected
# Not specifying the saltenv results in the base being used
sudo salt '*' cp.list_master
top.sls
# Specifying the Base saltenv
sudo salt '*' cp.list_master saltenv=base
top.sls
# Specifying the Development saltenv
sudo salt '*' cp.list_master saltenv=development
Test/init.sls
Когда я пытаюсь показать лучшее совпадение, Salt ищет в среде разработки, а не в Base, как я ожидаю.
sudo salt-call state.show_top --log-level=debug
[DEBUG ] Could not find file 'salt://top.sls' in saltenv 'development'
[DEBUG ] No contents found in top file. If this is not expected, verify that the 'file_roots' specified in 'etc/mas
ter' are accessible. The 'file_roots' configuration is: {'production': [], 'development': [], 'staging': [], 'base':
[]}
[ERROR ] The 'development' saltenv has no top file, and the fallback saltenv specified by default_top (base) also h
as no top file
[DEBUG ] Could not find file 'salt://top.sls' in saltenv 'development'
[DEBUG ] No contents found in top file. If this is not expected, verify that the 'file_roots' specified in 'etc/mas
ter' are accessible. The 'file_roots' configuration is: {'production': [], 'development': [], 'staging': [], 'base':
[]}
[ERROR ] The 'development' saltenv has no top file, and the fallback saltenv specified by default_top (base) also h
as no top file
[DEBUG ] Could not find file 'salt://top.sls' in saltenv 'development'
[DEBUG ] No contents found in top file. If this is not expected, verify that the 'file_roots' specified in 'etc/mas
ter' are accessible. The 'file_roots' configuration is: {'production': [], 'development': [], 'staging': [], 'base':
[]}
[ERROR ] The 'development' saltenv has no top file, and the fallback saltenv specified by default_top (base) also has no top file
Так каков наилучший способ добиться единого top.sls в Base и всех остальных состояний в saltenv?
Ваше здоровье.