service doesn't exist

Hi,

Target is CentOS 5.8

I'm getting this error:
TASK: [no xfs] *********************
failed: [cl009.test.net] => {"changed": false, "failed": true,
"module": "service", "msg": "failed determining the current service
state => state stays unchanged"}
failed: [cl010.test.net] => {"changed": false, "failed": true,
"module": "service", "msg": "failed determining the current service
state => state stays unchanged"}

  - name: no xfs
    action: service name=xfs state=stopped enabled=no

[root@cd ~]# chkconfig --list | grep xfs
[root@cd ~]#

So the service doesn't exist but thats going to happen in my environment.

sheepchase:tasks jmarcus$ ansible --version
ansible 0.6

Is this me? Is it helpful post this to the list or should I open a bug?

James

I’m sorry, I don’t see your Problem.

You forced the service module to stop a service that doesn’t exist.
The service module hast to determine the service state first, before it can proceed with any actions.
Because of the service that is not existing, it can’t determine it’s current state.

I don’t see anything wrong with that.

What would you expect to happen in this situation?

Regards

Ingo

Hi,
Well I'm trying to make sure services are disabled, if they don't
exist, I would prefer that the playbook wouldn't fail. That way I
don't have to tune a playbook for each datacenter vendors distribution
of CentOS. Does that make sense?

Thanks,
James

So in 0.7 at some point in the next few weeks you will be able to
write a statement and use the result of that statement in an only_if
using a last_result variable.

I think I've mentioned this before.

Until then, you will have to write a custom fact module, like
"site_facts", and call it ahead of the service line in your playbook
in order to detect if the service exists or not.

Having this succeed blindly seems like a bad thing because there could
be typos, but you also have "ignore_errors: True" on a task if you are
feeling confident it will really work if the service is there. I
don't recommend that though.