[Deepsea-users] Get rid of onlyif, is there a better solution?
Volker Theile
vtheile at suse.com
Thu Apr 27 07:47:19 MDT 2017
Hello all,
i'm currently improving the openATTIC orchestration in DeepSea,
especially the stage 5 state. There are a lot of onlyif requisites, e.g.
openattic nop:
test.nop
{% if 'openattic' not in salt['pillar.get']('roles') %}
stop openattic-systemd:
service.dead:
- name: openattic-systemd
- enable: False
- onlyif:
- "which oaconfig >/dev/null 2>&1"
remove openattic database:
cmd.run:
- names:
- "su - postgres -c 'dropdb openattic'"
- "su - postgres -c 'dropuser openattic'"
- onlyif:
- "which oaconfig >/dev/null 2>&1"
...
I also found this in ganesha and other states:
https://github.com/votdev/DeepSea/blob/wip-openattic/srv/salt/ceph/rescind/openattic/default.sls
https://github.com/SUSE/DeepSea/blob/master/srv/salt/ceph/rescind/ganesha/default.sls#L16
https://github.com/SUSE/DeepSea/blob/master/srv/salt/ceph/rescind/igw/lrbd/default.sls
All of the above examples can be broken down to something like: Do this
if package xyz is installed.
So i'm asking myself if there is not a better solution. I have something
in mind:
{% 'openattic' in grains['pkg'] %}
stop openattic-systemd:
service.dead:
- name: openattic-systemd
- enable: False
remove openattic database:
cmd.run:
- names:
- "su - postgres -c 'dropdb openattic'"
- "su - postgres -c 'dropuser openattic'"
{% endif %}
The grain 'pkg' must be populated via a custom grain module. Is this a
good idea? Are there any other solution that are better?
I know there are discussions about something like below which looks also
promising and much better than testing whether an executable or
something else exists:
stop openattic-systemd:
service.dead:
- name: openattic-systemd
- enable: False
- onlyif:
- pkg.is_installed:
- name: openattic
Sadly this seems not to be possible with Salt at the moment.
Please tell me your thoughts or give me a hint how to solve this
behaviour more elegant.
Regards
Volker
--
Volker Theile
Software Engineer | openATTIC
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
Phone: +49 173 5876879
E-Mail: vtheile at suse.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.suse.com/pipermail/deepsea-users/attachments/20170427/4e717a2a/attachment.sig>
More information about the Deepsea-users
mailing list