playbookで使えるモジュール一覧
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[ansible]]
*yumの実行 [#ib2ac132]
yum: name={{ item }}
- rsync
- gcc
- ntp
- ntpdate
*ファイルのコピー [#lf418f19]
***例1 [#o47d6d0c]
copy: src=/tmp/test/ dest=/home/hoge/
***例2 [#m3e495eb]
copy: src=~/ansible/playbook/roles/common/files/r...
destのディレクトリがなくても作成される。~
ファイルがある場合は上書きされるので注意。
*ディレクトリの作成 [#z9e7a124]
file: state=directory path=/var/www/test
※recurse=yesをつけることで再帰的にディレクトリを作成する
*リモートでシェルコマンドを実行 [#r3e553b5]
shell: コマンドの内容
例
shell: touch /tmp/test.`date +%Y%m%d`.txt
*ローカルのシェルスクリプトをリモートで実行 [#s9c1e9d4]
script: ~/test.sh
*ファイルの文字置換 [#i2ab4171]
***単一行 [#x58d39af]
- name: selinux disabled
lineinfile: >
backup=yes
dest=/etc/sysconfig/selinux
regexp='^SELINUX=enforcing'
line='SELINUX=disabled'
***複数行 [#f30c1875]
- replace: dest=/tmp/test.txt regexp='^hoge' replace='HO...
- replace: dest=/tmp/test.txt regexp='^fuga' replace='FU...
'- name'は必須ではないようです。上記記述例は公式サイトを...
***元の文字列を置換後の引数として使用する [#z1e84429]
- replace: dest=/etc/vsftpd/user_list regexp='^([a-z])' ...
※pythonの書き方ルールに則ります
[置換前]
# hogehoge
# fugafuga
root
bin
daemon
[置換後]
# hogehoge
# fugafuga
#root
#bin
#daemon
終了行:
[[ansible]]
*yumの実行 [#ib2ac132]
yum: name={{ item }}
- rsync
- gcc
- ntp
- ntpdate
*ファイルのコピー [#lf418f19]
***例1 [#o47d6d0c]
copy: src=/tmp/test/ dest=/home/hoge/
***例2 [#m3e495eb]
copy: src=~/ansible/playbook/roles/common/files/r...
destのディレクトリがなくても作成される。~
ファイルがある場合は上書きされるので注意。
*ディレクトリの作成 [#z9e7a124]
file: state=directory path=/var/www/test
※recurse=yesをつけることで再帰的にディレクトリを作成する
*リモートでシェルコマンドを実行 [#r3e553b5]
shell: コマンドの内容
例
shell: touch /tmp/test.`date +%Y%m%d`.txt
*ローカルのシェルスクリプトをリモートで実行 [#s9c1e9d4]
script: ~/test.sh
*ファイルの文字置換 [#i2ab4171]
***単一行 [#x58d39af]
- name: selinux disabled
lineinfile: >
backup=yes
dest=/etc/sysconfig/selinux
regexp='^SELINUX=enforcing'
line='SELINUX=disabled'
***複数行 [#f30c1875]
- replace: dest=/tmp/test.txt regexp='^hoge' replace='HO...
- replace: dest=/tmp/test.txt regexp='^fuga' replace='FU...
'- name'は必須ではないようです。上記記述例は公式サイトを...
***元の文字列を置換後の引数として使用する [#z1e84429]
- replace: dest=/etc/vsftpd/user_list regexp='^([a-z])' ...
※pythonの書き方ルールに則ります
[置換前]
# hogehoge
# fugafuga
root
bin
daemon
[置換後]
# hogehoge
# fugafuga
#root
#bin
#daemon
ページ名: