LoginSignup
26
29

More than 5 years have passed since last update.

Ansible ~shellモジュール~

Posted at

Ansible Documentationのshellモジュールのメモです。

Ansible Documentation

概要

  • shellモジュールは、シェル(/bin/sh)を実行する

オプション

頻度 パラメータ 必須 デフォルト値 選択肢 説明
chdir no - - コマンドを実行する前にcdコマンドでディレクトリを移動する。
creates no - - 指定したファイル名が既に存在する場合、コマンドを実行しない。
executable no - - 実行するシェルを絶対パスで指定する。
free_form yes - - 実行するコマンドの指定。free_formというオプション名はつけず、コマンドを書き始めれば良い。
removes no - - 指定したファイル名が存在しない場合、コマンドを実行しない。
warn no true - 『no』または『false』を指定した場合、コマンド警告を出さない。

example.yml
# Execute the command in remote shell; stdout goes to the specified
# file on the remote.
- shell: somescript.sh >> somelog.txt

# Change the working directory to somedir/ before executing the command.
- shell: somescript.sh >> somelog.txt chdir=somedir/

# You can also use the 'args' form to provide the options. This command
# will change the working directory to somedir/ and will only run when
# somedir/somelog.txt doesn't exist.
- shell: somescript.sh >> somelog.txt
  args:
    chdir: somedir/
    creates: somelog.txt

参考

26
29
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
26
29