Salt-Stack init process after package is installed

Installing AIDE needs to follow by a init proces.

aide:
pkg:
- installed

Now the following commands need to run only once:
/usr/sbin/aide --config=/etc/aide.conf --init
mv -f /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz

How to manage this in a state file?

Answer

I usually do something like this:

run aide once after installation:
  cmd.run:
    - name: usr/sbin/aide --config=/etc/aide.conf --init mv -f /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
    - unless: test -e /var/lib/aide/aide.db.gz
    - require: aide

Untested, obviously, but you get the idea. The cmd.run state will only run if the command passed to the unless option returns a non-zero exit status.

cmd.run state documemtation

Attribution
Source : Link , Question Author : BdK , Answer Author : natxo asenjo

Leave a Comment