How do you find a service name?

648 views
Skip to first unread message

Bethany

unread,
Apr 25, 2013, 6:06:04 PM4/25/13
to salt-...@googlegroups.com
I'm trying to manage 2 services via a state file, sshd and a softphone called Linphone (runs a daemon called linphonec). 

I took my sshd code/configuration straight from this tutorial: http://docs.saltstack.com/topics/tutorials/starting_states.html

But no matter what name I try for these 2 services, I always get back this:
  State: - service
    Name:      sshd
    Function:  running
        Result:    False
        Comment:   The named service sshd is not available
        Changes:
-----------------------------
State: - service
    Name:     linphonec
    Function:  running
        Result:    False
        Comment:   The named service linphonec is not available
        Changes:

Is there any way to figure out what "name" SaltStack would recognize for these services? The sshd one especially - that one has to have worked at some point.

I'm running SaltStack 0.12.1 on Ubuntu Server 12.04.

Mrten

unread,
Apr 25, 2013, 6:32:27 PM4/25/13
to salt-...@googlegroups.com
On 26/4/2013 00:06 , Bethany wrote:

> I took my sshd code/configuration straight from this
> tutorial: http://docs.saltstack.com/topics/tutorials/starting_states.html


> Is there any way to figure out what "name" SaltStack would recognize for
> these services? The sshd one especially - that one has to have worked at
> some point.
>
> I'm running SaltStack 0.12.1 on Ubuntu Server 12.04.

check out /etc/init for the services you got defined in upstart, ssh
daemon isn't sshd on ubuntu but ssh.

like this:

openssh-server:
pkg:
- installed

ssh:
service.running:
- require:
- pkg: openssh-server
- enable: true
- reload: true
- watch:
- file: /etc/ssh/sshd_config

/etc/ssh/sshd_config:
file.managed:
- source: salt://all-sshd-config/sshd_config
- mode: 644
- template: jinja
- require:
- pkg: openssh-server

not that file.managed is ideal for managing sshd_config; today i learned
about file.accumulated by stumbling over it in the bugtracker
(https://github.com/saltstack/salt/pull/2521 )

you can also check out /etc/init.d/ for service names, salt uses the
'service' command to start and stop services (on ubuntu anyway).

M.


Nick Davis

unread,
Apr 25, 2013, 6:34:28 PM4/25/13
to salt-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bethany,

If you think of it this way, the salt calls will try to use the system
startup scripts to run your service. So, what is the name of the startup
script? For sshd the startup script is /etc/init/ssh.conf, so the
service name you'd use is "ssh".

I'm not sure about your phone service.

Nick
> --
> You received this message because you are subscribed to the Google
> Groups "Salt-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to salt-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlF5r3QACgkQYoNGId/piAvZjACeMn9BtcNnQwe+X3KP7tP+NmkP
rPgAmwZvntlR8JHDTsxxrhWoGNa8Mrdj
=AvLF
-----END PGP SIGNATURE-----

Denis Generalov

unread,
Apr 25, 2013, 7:05:27 PM4/25/13
to salt-...@googlegroups.com, Bethany
Have you tried to find your services in `sudo salt 'server.name' service.get_all` output?

>
> I'm running SaltStack 0.12.1 on Ubuntu Server 12.04.
>
> --
> You received this message because you are subscribed to the Google Groups "Salt-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>


--
Denis Generalov <gian...@gmail.com>

Bethany

unread,
May 9, 2013, 6:05:29 PM5/9/13
to salt-...@googlegroups.com, Bethany
I have tried the service.get_all, but it seems like that is only for Windows (on Ubuntu it says the command is not available).

Bethany

unread,
May 9, 2013, 6:06:08 PM5/9/13
to salt-...@googlegroups.com
So you're saying I can't separately manage openssh-server and openssh-client services? It's all or nothing for ssh?

Nick Davis

unread,
May 9, 2013, 6:49:20 PM5/9/13
to salt-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

No. You can create as many states as you want in one or more files as
you desire.

openssh-client doesn't create any services. That contains purely client
applications. So, all you normally do is install that package using a
salt "pkg.installed" state.

openssh-server does create system services. This is where you use a salt
"service" state to ensure it is running, enabled, etc.

The distinction I was trying to make is simply that different linux
distributions use different names for the same thing. On Ubuntu, the
sshd service is run by using the /etc/init/ssh.conf script. This has
nothing to do with the ssh client software.

Additionally, for any other software that is run as a system service,
you should reference the startup script name when creating your salt
"service" state to ensure it correctly starts.

I hope that makes it clear.

Nick
>> an email to salt-users+...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Salt-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to salt-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlGMJ/AACgkQYoNGId/piAuVlQCfeuERXCZ95mn5rxdzm4sKdClb
G0EAn25/32ZmmmZ9jJQz2RrLQ4md78X4
=GRlB
-----END PGP SIGNATURE-----

Bethany

unread,
May 9, 2013, 7:04:59 PM5/9/13
to salt-...@googlegroups.com
Yes, I know I can create as many states as I want, that's not the issue. The issue is I can't find service names.
So you're saying on Ubuntu  the 'ssh' service is the server, not the client? That would answer half my question - I guess I was confused by the SaltStack docs that had sshd as the service name.

I've been poking around trying to find startup scripts for various softphones, but even when I think I've found them, the name usually doesn't work. At this point I guess I'd just like to confirm that there's no simple way/function to find service names? You just have to guess based on whatever you think is the startup script?

Nick Davis

unread,
May 9, 2013, 8:45:24 PM5/9/13
to salt-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yes. 'ssh' service is the server on Ubuntu. I know it is confusing.

No. Unfortunately, there is no way to run a script or tool to get a list
of "every" service on the host. The best you can do is to get a list of
all services that are run from the standard init script directories.
Those directories are:

/etc/init/
/etc/init.d/
/etc/rc.d/

To get that list, you can run this command:

$ service --status-all

Note: The reason I put every in quotes above is because there are some
services that install completely into a directory and have to be run by
directly calling a binary in their install directory. Often they are put
in /opt/<program name>/

I hope that helps,
Nick
iEYEARECAAYFAlGMQyQACgkQYoNGId/piAvzrACeI4Ps2dG1jhwoZNYtW7qZxNpU
AxQAnRqzC1Db6jE6r6JeOR6lBIyNF4bM
=Bvu1
-----END PGP SIGNATURE-----

Mrten

unread,
May 10, 2013, 7:47:23 AM5/10/13
to salt-...@googlegroups.com
On 10/5/2013 00:05 , Bethany wrote:
> I have tried the service.get_all, but it seems like that is only for
> Windows (on Ubuntu it says the command is not available).

No.

root@salt-master:/home/salt/conf/# salt mx-1 service.get_all
mx-1:
- acpid
- apparmor
[etc]
- ssh
[etc]


This is on Ubuntu 12.04. Please post your commandline + output (not all
of it) if this is not the same for you.


M.


Erik Johnson

unread,
May 10, 2013, 11:40:26 AM5/10/13
to salt-...@googlegroups.com
On Thu, May 9, 2013 at 5:05 PM, Bethany <tech...@gmail.com> wrote:
I have tried the service.get_all, but it seems like that is only for Windows (on Ubuntu it says the command is not available).




service.get_all should *definitely* work on Ubuntu. If it's saying that it's not available, there might be a bug. Please login to the minion and run the following two commands as root, and post the results:


1) salt-call service.get_all -l debug

2) salt-call --versions-report


--

-Erik

"For me, it is far better to grasp the universe as it really is than to persist in delusion, however satisfying and reassuring."  -- Carl Sagan
Reply all
Reply to author
Forward
0 new messages