SaltStack: Do “etckeeper init” if /etc/.git is not there

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?

Answer

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

Attribution
Source : Link , Question Author : guettli , Answer Author : Antoine Albertelli

Leave a Comment