While using ceph-ansible purge-cluster.yml script I ran into this problem.  
If you run a task like:

  - name: stop ceph mdss with systemd
    service:
      name: ceph-mds@{{ ansible_hostname }}
      state: stopped
      enabled: no
    when: ansible_service_mgr == 'systemd'
when the service was never installed to begin with, the error is:

    TASK [stop ceph mdss with systemd] 
*********************************************
    fatal: [ip-172-31-27-179]: FAILED! => {"changed": false, "failed": true, 
"msg":  
     "Could not find the requested service ceph-mds@ip-172-31-27-179: cannot 
disable" }
I thought that Ansible playbooks should ideally be idempotent, so that if you
run them 2 times in a row, it's the same as if you ran them just once.  
The service module here is being asked to stop the ceph-mds@foo systemd 
service, 
but if that service does not exist, then by definition it is not running 
(right?),
so then the idempotent (right) thing to do is to return success, yes?  
If so, is there a bug in the ansible service module?  
Or is it expected that the playbook will test to see if the service is defined 
before it tries to stop it?  

If the latter, this seems a bit awkward.   Software removal
is a common activities in system management and it would be nice to make this 
as easy as possible
to specify.  Typically you have to shut down a service before you remove the 
software
that provides it, so it's inconvenient to have to test for the software 
package's installation before you
shut down the service.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/50178053-0756-400a-a607-78b95d9600e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to