Ambientes GitFS Salt com um único top.sls

Ambientes GitFS Salt com um único top.sls

A documentação afirma que se você usar

salt_top_saltenv: base

na configuração master, posso forçar todos os Minions a usar apenas o saltenv base para o arquivo principal, ignorando todos os outros arquivos principais, correto?

Com state_top_saltenv definido como base, todos os estados de todos os ambientes no arquivo principal base serão aplicados, enquanto todos os outros arquivos principais serão ignorados

Estou tentando usar o Gitfs como back-end e estou obtendo alguns resultados estranhos (state.show_top) que não correspondem a nada.

Eu tenho a seguinte configuração

  • Um único repositório git
  • 4x referências, base, desenvolvimento, preparação, produção

Estou tentando obter uma única referência (base) para o arquivo principal e, em seguida, os estados de cada ambiente. Então posso promover mudanças nos ambientes por meio de fusão e tentar manter o top.sls o mais estático possível.

##### 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

Quando tento mostrar a melhor correspondência que o Salt está procurando no ambiente de desenvolvimento em vez do Base, como eu esperava

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

Então, qual é a melhor maneira de obter um único top.sls no Base e todos os outros estados no saltenv?

Saúde.

informação relacionada