stop and start an upstart service in a handler

1,800 views
Skip to first unread message

seb....@gmail.com

unread,
Apr 5, 2013, 11:26:54 AM4/5/13
to ansible...@googlegroups.com
With upstart, after you changed an option in /etc/init/<service>.conf, it is not enough to run "restart <service>". You would have to stop and start the service for the change to take effect, as documented in initctl(8) on Ubuntu 12.04.

How would I do so in an ansible handler? The following handler does not do it:

---
- name: Restart gssd
  action: service name=gssd state=stopped
  action: service name=gssd state=started

Thanks for any hints.

Michael DeHaan

unread,
Apr 5, 2013, 11:41:56 AM4/5/13
to ansible...@googlegroups.com
What ansible version are you using?

ansible --version




--
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 ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

seb....@gmail.com

unread,
Apr 5, 2013, 11:46:59 AM4/5/13
to ansible...@googlegroups.com
ansible 1.1 from git tag release1.1

seb....@gmail.com

unread,
Apr 5, 2013, 11:53:44 AM4/5/13
to ansible...@googlegroups.com


By the way, for now I'm using


---
- name: Restart gssd
  action: shell stop gssd; start gssd

but what I would really want is something like this:


---
- name: Restart gssd
  action: service name=gssd state=stoppedstarted


Does that make sense to anyone?

Michael DeHaan

unread,
Apr 5, 2013, 12:34:26 PM4/5/13
to ansible...@googlegroups.com
Could it be that just this one service does not support restart?

I am fine with doing start+stop, but it seems restart *is* a command.






--
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 ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Brian Coca

unread,
Apr 5, 2013, 12:57:01 PM4/5/13
to ansible...@googlegroups.com
restart IS part of upstart
Brian Coca
Stultorum infinitus est numerus
0110000101110010011001010110111000100111011101000010000001111001011011110111010100100000011100110110110101100001011100100111010000100001
Pedo mellon a minno

Brian Coca

unread,
Apr 5, 2013, 12:59:14 PM4/5/13
to ansible...@googlegroups.com
Ah, nvmd, I see the issue.

upstart's restart will restart the service with the original config (won't reread) so if you are updating the config you NEED to issue a separate stop + start to get it restarted with the new config ... dumb upstart!

Ashley Penney

unread,
Apr 5, 2013, 12:59:44 PM4/5/13
to ansible...@googlegroups.com
Based on my reading of this he's saying that restart is fine UNLESS you edit the actual upstart job itself and then restart doesn't reload that off disk and see the changes.  Is that accurate?

Michael DeHaan

unread,
Apr 5, 2013, 2:39:57 PM4/5/13
to ansible...@googlegroups.com
So the upstart config file got templated also?  I concur, dumb upstart!

The SysV code does explicit stop/start somewhat for this reason.

I'm fine with patches to make it do the same.


Sebastian Stark

unread,
Apr 7, 2013, 10:08:41 AM4/7/13
to ansible...@googlegroups.com
Yes.

I think there is no room here to be smart and detect whichever method is needed, so let the user choose.

How about a userestart=yes/no option that defaults to no?
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/8eEyKXIOCUY/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

Sebastian Stark

unread,
Apr 7, 2013, 10:18:36 AM4/7/13
to ansible...@googlegroups.com
Yes. Seems upstart does not meet many people's expectations here.
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/8eEyKXIOCUY/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

Michael DeHaan

unread,
Apr 7, 2013, 11:41:13 AM4/7/13
to ansible...@googlegroups.com
At this point feels like restart_mode as httpd may like "graceful" as well. 

-- Michael
Reply all
Reply to author
Forward
0 new messages