0

I want to deploy the tool etckeeper via SaltStack.

Installating the RPM/DPKG is easy.

Next step is to call etckeeper init after the installation.

My current idea is this pseudo-code:

execute etckeeper init if /etc/.git does not exist

I read the docs for file.exists, but this does not help me.

How to solve this with SaltStack?

3
+100

You can use the "creates" argument to cmd.run, which tells saltstack to avoid running a command if a files already exists:

etckeeper_init:
  cmd.run:
    - name: etckeeper init
    - creates: /etc/.git
  • Wow, that's cool. I did not know this before. Thank you! – guettli Mar 9 '18 at 15:06
0

I found this solution. Other solutions are welcome!

etckeeper:
  pkg.installed

{%- if not salt['file.directory_exists' ]('/etc/.git') %}
init_etckeeper:
  cmd.run:
    - name: etckeeper init

initial_commit_etckeeper:
  cmd.run:
    - name: etckeeper commit -m "initial commit"
{%- endif %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.