yumの実行†yum: name={{ item }} - rsync - gcc - ntp - ntpdate ファイルのコピー†例1†copy: src=/tmp/test/ dest=/home/hoge/ 例2†copy: src=~/ansible/playbook/roles/common/files/resolv.conf dest=/etc/ owner=root group=root mode=0644 destのディレクトリがなくても作成される。 ディレクトリの作成†file: state=directory path=/var/www/test ※recurse=yesをつけることで再帰的にディレクトリを作成する リモートでシェルコマンドを実行†shell: コマンドの内容 例 shell: touch /tmp/test.`date +%Y%m%d`.txt ローカルのシェルスクリプトをリモートで実行†script: ~/test.sh ファイルの文字置換†単一行†- name: selinux disabled lineinfile: > backup=yes dest=/etc/sysconfig/selinux regexp='^SELINUX=enforcing' line='SELINUX=disabled' 複数行†- replace: dest=/tmp/test.txt regexp='^hoge' replace='HOGE' - replace: dest=/tmp/test.txt regexp='^fuga' replace='FUGA' '- name'は必須ではないようです。上記記述例は公式サイトを参考にしています。 元の文字列を置換後の引数として使用する†- replace: dest=/etc/vsftpd/user_list regexp='^([a-z])' replace='#\1' ※pythonの書き方ルールに則ります [置換前] # hogehoge # fugafuga root bin daemon [置換後] # hogehoge # fugafuga #root #bin #daemon |