2016-09-08 7 views
6

、サービスモジュール:リモートホスト上の「サービス」モジュールを使用すると、どのinitシステムが実行されているかをどのように知ることができますか? <a href="http://docs.ansible.com/ansible/service_module.html" rel="noreferrer">the Ansible documentation</a>から

コントロールサービス。サポートされている初期化システムには、BSD init、OpenRC、SysV、Solaris SMF、systemd、upstartなどがあります。

特定のマシンでは、どのようなinitシステムを使用しているのかをどのように知ることができますか?例えば、システムにはinitとsystemdがあります。

答えて

3

のは、モジュールのcodeに見てみましょう:

def main():内部:次に

# Find service management tools 
service.get_service_tools() 

class LinuxService(Service):へとdef get_service_tools(self):

# Locate a tool to enable/disable a service 
    if check_systemd(): 
     # service is managed by systemd 
     ... 
    elif location.get('initctl', False) and os.path.exists("/etc/init/%s.conf" % self.name): 
     # service is managed by upstart 
     ... 
    elif location.get('rc-service', False): 
     # service is managed by OpenRC 
     ... 
    elif self.svc_initscript: 
     # service is managed by with SysV init scripts 
     ... 

に私はいくつかのコードをカットしましたが、このスニペットがすべきあなたの質問に答えてください:多くの人がいる場合、どのシステムを選択する可能性が高いですか。

にsystemdこれはansibleバージョン間で矛盾している

+0

私はそれは良い考えではないと思う。私のUbuntu 14サーバーでは、systemdがインストールされていますが、initには使用されていません。その結果、AnsibleはUpstart(システムで宣言されたサービスマネージャー)の代わりにSystemdを使用しようとします。 –

8

ホスト上のinitシステムは、Anordin fact ansible_service_mgrとして入手できます。

+0

...など、成り上がりそして、検索するための最初のものです。私はUbuntuの信頼できるシステムを持っています。ここでは、Anecess 2.2.1が "upstart"、Ansible 2.4が "service"と報告しています。 – bschlueter

関連する問題