salt icon indicating copy to clipboard operation
salt copied to clipboard

freebsdservice does not respect/use rcNG

Open m87carlson opened this issue 13 years ago • 9 comments

FreeBSD has a few rc configuration possibilities, one is to populate /etc/rc.conf or /etc/rc.conf.local, and the other is to use the rcNG , and use service named files in /etc/rc.conf.d/

for example, to enable salt_master on FreeBSD using rcNG, you can create:

/etc/rc.conf.d/salt_master

with the contents: salt_master_enable="YES"

If I enable salt_master on a FreeBSD system, this command does not see that salt_master is enabled:

salt-1# cat /etc/rc.conf.d/salt_master 
salt_master_enable="YES"
salt-1# /usr/local/etc/rc.d/salt_master rcvar
# salt_master
#
salt_master_enable="YES"
#   (default: "")

salt# salt 'salt*' service.get_enabled
salt.bayphoto.com:
    - bgfsck
    - cleanvar
    - cron
    - devd
    - dmesg
    - gptboot
    - hostid
    - hostid_save
    - ip6addrctl
    - mixer
    - motd
    - newsyslog
    - ntpd
    - sendmail
    - sshd
    - syslogd
    - virecover
salt-1# 

Options specific to that service can also be in that file, postgresql for example:

cat /etc/rc.conf.d/postgresql 
postgresql_enable=YES
postgresql_data="/data/db/postgresql"

Unfortunately, /usr/sbin/service does not respect rcNG either, BUT, salt has /etc/rc.conf hard-coded.

I think they both need to be updated (service in FreeBSD and Salt)

m87carlson avatar Feb 28 '13 00:02 m87carlson

@m87carlson , what version of salt do you use?

giantlock avatar Feb 28 '13 12:02 giantlock

0.13.1, installed from the freebsd ports tree.

m87carlson avatar Feb 28 '13 16:02 m87carlson

You almost right except hardcoded /etc/rc.conf. I can't find where is this hardcoded. I think it must to be fixed in FreeBSD sourses. I even made a PR (bin/173454), but I'm not complitely sure that it clear and absolutely right.

giantlock avatar Feb 28 '13 17:02 giantlock

Ahh, cool. I too submitted a PR yesterday (bin/176488)

I see config="/etc/rc.conf" set, for example, in enable() function: https://github.com/saltstack/salt/blob/develop/salt/modules/freebsdservice.py#L83

I could be mis-interpreting how that works, but it looks like it would need to be refactored to not just append to /etc/rc.conf but create /etc/rc.conf.d/service

m87carlson avatar Feb 28 '13 17:02 m87carlson

It's default value of config parameter. Try something like that:

sudo salt-call service.enable named config=/tmp/rc.conf.test

and look at /tmp/rc.conf.test I made this parameter especialy for enabling/disabling services through other then /etc/rc.conf. I use /etc/rc.conf.local only for enabling/disabling services.

giantlock avatar Feb 28 '13 17:02 giantlock

Did you guys find a solution for this?

UtahDave avatar Feb 28 '13 23:02 UtahDave

@UtahDave, Not yet. I'm trying to satisfy @m87carlson that this is freebsd issue.

giantlock avatar Feb 28 '13 23:02 giantlock

Defining which config file works to a degree, but then service.get_enabled does not show named as an enabled service if I use:

# salt-call service.enable named config=/etc/rc.conf.d/named
[INFO    ] Loaded configuration file: /usr/local/etc/salt/minion
local:
    True
# cat /etc/rc.conf.d/named
named_enable="YES"
# salt-call service.get_enabled
[INFO    ] Loaded configuration file: /usr/local/etc/salt/minion
[INFO    ] Executing command '/usr/sbin/service -e' in directory '/root'
local:
    - bgfsck
    - cleanvar
    - cron
    - devd
    - dmesg
    - gptboot
    - hostid
    - hostid_save
    - ip6addrctl
    - mixer
    - motd
    - newsyslog
    - ntpd
    - samba
    - sendmail
    - sshd
    - syslogd
    - virecover

service(8) needs to be fixed on FreeBSD first, I agree with that, and if there is a way for me to tell salt to use /etc/rc.conf.d/servicename instead of /etc/rc.conf in the minion config, then that would work out.

m87carlson avatar Feb 28 '13 23:02 m87carlson

@m87carlson, Ok, I'm leaning towards agree. I'll fix this issue.

giantlock avatar Mar 01 '13 13:03 giantlock