単一の top.sls を使用した GitFS Salt 環境

単一の top.sls を使用した GitFS Salt 環境

ドキュメントには、

salt_top_saltenv: base

マスター構成では、すべてのミニオンにトップ ファイルのベース saltenv のみを使用し、他のすべてのトップ ファイルを無視するように強制できるとありますが、これは正しいですか?

state_top_saltenv を base に設定すると、ベーストップファイル内のすべての環境のすべての状態が適用され、他のすべてのトップファイルは無視されます。

Gitfs をバックエンドとして使用しようとしていますが、奇妙な結果 (state.show_top) が何も一致しません。

私は以下の構成を持っています

  • 単一のgitリポジトリ
  • 4x ref、ベース、開発、ステージング、プロダクション

私は、トップ ファイルと各環境の状態に対して単一の参照 (ベース) を実現しようとしています。次に、マージによって環境を通じて変更を促進し、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

私が期待していたBaseではなく開発環境でトップマッチを表示しようとすると、Saltは

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

では、Base で単一の top.sls を実現し、saltenv で他のすべての状態を実現する最善の方法は何でしょうか?

乾杯。

関連情報