Conditionally execute command

Hi,

i have a following problem. I am building OpenStack which uses tool openstack-config for setting value in configuration files.

To get value:

openstack-config --get /etc/keystone/keystone.conf sql connection

To set value:

openstack-config --set /etc/keystone/keystone.conf sql connection {{ VALUE }}

So now I want to check if previous value matches the value I provide. If they do match, than it should report OK, otherwise CHANGED. Current solution is to register shell result of GET command and conditionally execute SET command, but I don’t like that very much because I have to do that 50-100 times; therefore code would be quite unreadable.

Does ansible provide easy mechanism to merge these two tasks or is copying ansible shell module and extending it the only solution?

PS: sorry for bad title

I would use the shell module to register to check the first value.

Then key off the saved_value.stdout or saved_value.rc on the conditional of the second.

It may make sense to have an openstack_config module, but I suspect many folks might just template the config files directly. Depends where they are stored.