LoginSignup
47
41

More than 5 years have passed since last update.

Ansible ~serviceモジュール~

Posted at

Ansible Documentationのserviceモジュールの内容のメモです。

Ansible Documentation

概要

  • serviceモジュールは、serviceコマンドを実行する

オプション

頻度 パラメータ 必須 デフォルト値 選択肢 説明
arguments(args?) no - - 引数の指定。
enabled no - yes
no
マシン起動時に自動起動させるか。
name yes - - サービスの名前。
pattern no - - ?
runlevel no default - ランレベルの指定。
sleep no - - サービスを再起動する場合に指定秒数スリープさせる。
state no - started
stopped
restarted
reloaded
started: サービスを開始する
stopped: サービスを停止する
restarted: サービスを再起動する
reloaded: サービスを再読み込みする

example.yml
# Example action to start service httpd, if not running
- service: name=httpd state=started

# Example action to stop service httpd, if running
- service: name=httpd state=stopped

# Example action to restart service httpd, in all cases
- service: name=httpd state=restarted

# Example action to reload service httpd, in all cases
- service: name=httpd state=reloaded

# Example action to enable service httpd, and not touch the running state
- service: name=httpd enabled=yes

# Example action to start service foo, based on running process /usr/bin/foo
- service: name=foo pattern=/usr/bin/foo state=started

# Example action to restart network service for interface eth0
- service: name=network state=restarted args=eth0

参考

47
41
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
47
41