salt stack - Python Saltstack: How can I manage a file which is in a git repo? -
i have configuration file, config.py in git repository. has dev-specific configuration settings.
i have same file managed file in salt, has production-specific configurations.
the configuration directive file looks this:
python_config: file.managed: - name: /opt/github/python_config/config.py - source: salt://configs/config.py - makedirs: true
because /opt/github
git repository, whenever try update directory, error: "you local changes python_config/config.py overwritten merge."
here salt directive github repo looks like:
code: git.latest: - name: {{ pillar['git_repo'] }} - rev: {{ pillar['git_rev'] }} - target: {{ pillar['source_path'] }} - force: true - require: - pkg: app-pkgs - file: deploykey - file: publickey - file: ssh_config
this error makes sense - i've checked out repository, made change (via managed file), new changes dev-specific config file cause issues.
how can force salt perform tasks in specific order? (eg, issue git checkout config.py
before proceeding with git pull
?)
alternately, there better/different way should manage prod-vs-dev configuration in salt?
your best bet here use gitfs backend.
docs can found here: http://docs.saltstack.com/topics/tutorials/gitfs.html
this allows use git backend file_roots.
each git branch , tag becomes salt environment, map nicely production , dev configurations.
this remove need git.latest state declaration.
python_config: file.managed: - name: /opt/github/python_config/config.py - source: salt://configs/config.py - makedirs: true
Comments
Post a Comment