salt icon indicating copy to clipboard operation
salt copied to clipboard

Environments and git branches confusion, I've tried everything!

Open evenyougreg opened this issue 7 years ago • 4 comments

Description of Issue/Question

Seems like I've tried everything:(

I have 2 branches in GitHub called "master" and "testing", but I am only focusing on testing atm.

I have 2 masters that need to be fully sealed off from each other, each representing a different environment, Prod and Testing.

I want to be able to run a state.apply without having to specifying the environment.

I've got a simple executable state that installs on a Windows server and works every time, but only if I specifically call it out:

salt t-win2012r2 state.apply encase

Although this works, it is putting the files into base cache on the server, not testing like I would expect.

The main issues are showing up when I have the executable state in my top file and I run a highstate, the top file doesn't see it, even though everything appears to be connected from GitHub to my master.

I've tried every combination of saltenv this and saltenv that in my master config file, and nothing seems to work.

Setup

Master Config

saltenv: testing

fileserver_backend:
  - gitfs
  - roots

file_roots:
  base:
    - /srv/salt
  testing:
    - /srv/salt

state_top_saltenv: testing

gitfs_provider: pygit2
gitfs_root: salt

gitfs_pubkey: '/root/.ssh/id_rsa.pub'
gitfs_privkey: '/root/.ssh/id_rsa'

#gitfs_base: testing

gitfs_remotes:
  - [email protected]:LaughHammers/spase-top.git:
    - pubkey: /root/.ssh/id_rsa.pub
    - privkey: /root/.ssh/id_rsa
    - base: testing

  - [email protected]:LaughHammers/spase-linux.git:
    - pubkey: /root/.ssh/id_rsa.pub
    - privkey: /root/.ssh/id_rsa
    - base: testing

  - [email protected]:LaughHammers/spase-windows.git:
    - pubkey: /root/.ssh/id_rsa.pub
    - privkey: /root/.ssh/id_rsa
    - base: testing

Files from fileserver.file_list

- binaries/encasesetup.exe
- encase/init.sls
- encase/startservice.sls
- testing-linux.sls
- testing-windows.sls
- top.sls

Top file in GitHub called top.sls in testing branch

testing:
  'os:Windows':
    - match: grain
    - encase

Executable state file in testing branch called encase/init.sls

C:\Windows\System32\encasesetup.exe:
  file.managed:
    - source: salt://binaries/encasesetup.exe
    
  cmd.run:
    - name: 'C:\Windows\System32\encasesetup.exe'
    - cwd: 'C:\Windows\System32'
    - shell: 'Windows'
    - require:
      - file: C:\Windows\System32\encasesetup.exe

Steps to Reproduce Issue

[DEBUG   ] Could not find file 'salt://top.sls' in saltenv 'testing'
[DEBUG   ] No contents loaded for saltenv 'testing'
[DEBUG   ] No contents found in top file. If this is not expected, verify that the 'file_roots' specified in 'etc/master' are accessible. The 'file_roots' configuration is: {'testing': [], 'master': [], 'base': []}
t-web1:
----------
          ID: states
    Function: no.None
      Result: False
     Comment: No Top file or master_tops data matches found.
     Changes:

Summary for t-web1
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:   0.000 ms

Versions Report

Salt Version: Salt: 2018.3.3

Dependency Versions: cffi: Not Installed cherrypy: Not Installed dateutil: 2.6.1 docker-py: Not Installed gitdb: 2.0.3 gitpython: 2.1.8 ioflo: Not Installed Jinja2: 2.10 libgit2: 0.26.0 libnacl: Not Installed M2Crypto: Not Installed Mako: 1.0.7 msgpack-pure: Not Installed msgpack-python: 0.5.6 mysql-python: Not Installed pycparser: Not Installed pycrypto: 2.6.1 pycryptodome: Not Installed pygit2: 0.26.2 Python: 2.7.15rc1 (default, Nov 12 2018, 14:31:15) python-gnupg: 0.4.1 PyYAML: 3.12 PyZMQ: 16.0.2 RAET: Not Installed smmap: 2.0.3 timelib: Not Installed Tornado: 4.5.3 ZMQ: 4.2.5

System Versions: dist: Ubuntu 18.04 bionic locale: UTF-8 machine: x86_64 release: 4.15.0-43-generic system: Linux version: Ubuntu 18.04 bionic

evenyougreg avatar Jan 25 '19 17:01 evenyougreg

Sorry in advance for crappy formatting, I'm new to GitHubs markdown.

evenyougreg avatar Jan 25 '19 19:01 evenyougreg

"Although this works, it is putting the files into base cache on the server, not testing like I would expect."

thats what this option is doing:

- base: testing

You are telling gitfs to treat testing as the base branch.

If you want your testing branch to become the testing environment this is done automatically. From the docs "Branches and tags become Salt fileserver environments."

Ch3LL avatar Jan 28 '19 16:01 Ch3LL

If I don't have something like - base: testing then I only have access to the master branch files. I don't want to see them at all on my test master.

I took away - base: testing and saltenv: testing and now it only sees and deals with my master branch files.

Cache file now has a master folder with the master branch top file and base folder with all the master branch files.

Thank you for your help on this btw!

evenyougreg avatar Jan 28 '19 17:01 evenyougreg

"Although this works, it is putting the files into base cache on the server, not testing like I would expect."

thats what this option is doing:

- base: testing

You are telling gitfs to treat testing as the base branch.

If you want your testing branch to become the testing environment this is done automatically. From the docs "Branches and tags become Salt fileserver environments."

I am still having issues despite your provided info.

Thanks

evenyougreg avatar Jan 29 '19 17:01 evenyougreg