Ansible
- Ansible(1)Ansibleの概要
- Ansible(2)ファイル関連モジュール
- Ansible(3)システム管理モジュール
- Ansible(4)コマンド実行モジュール
- Ansible(5)パッケージ管理関連モジュール
command
コマンドを実行する。
| 変数 | デフォルト | 内容 | 備考 |
|---|---|---|---|
| 必須 | 実行するコマンド | ||
| chdir | 実行する前に移動するディレクトリ |
Example
- name: return motd to registered var command: cat /etc/motd register: mymotd
debug
コマンド実行内容を表示する。
| 変数 | デフォルト | 内容 | 備考 |
|---|---|---|---|
| var | 表示する変数 |
Example
- debug:
var: result
verbosity: 2
expect
コマンドを実行しプロンプトに応答する。
| 変数 | デフォルト | 内容 | 備考 |
|---|---|---|---|
| command | 必須 | 実行するコマンド | |
| chdir | 実行する前に移動するディレクトリ | ||
| responses | プロンプトへの応答 | 正規表現にて規定する |
Example
- name: Case insensitive password string match
expect:
command: passwd username
responses:
(?i)password: "MySekretPa$$word"
# you don't want to show passwords in your logs
no_log: true
make
Makeファイルを実行する
| 変数 | デフォルト | 内容 | 備考 |
|---|---|---|---|
| chdir | 必須 | 実行する前に移動するディレクトリ | |
| target | ターゲット | install, all |
Example
# Run `install` target as root
- make:
chdir: /home/ubuntu/cool-project
target: install
become: yes
service
サービスの管理を行う。
| 変数 | デフォルト | 内容 | 備考 |
|---|---|---|---|
| name | 必須 | サービス名 | |
| state | 実行内容 | reloaded, restarted, started, stopped | |
| enabled | ブート時に起動するかどうか |
Example
- name: Enable service httpd, and not touch the state
service:
name: httpd
enabled: yes
shell
コマンドを実行する。
ワイルドカードを指定する場合はcommandモジュールではなくshellコマンドを使用する。
| 変数 | デフォルト | 内容 | 備考 |
|---|---|---|---|
| 必須 | 実行するコマンド | ||
| chdir | 実行する前に移動するディレクトリ |