ansibleでscpする|逆にリモートファイルをコピーする
ansibleでstructure as codeのために開発に着手しだしたのでメモ
まず、公式サイトをメモっておく
http://docs.ansible.com/ansible/
リモートサーバのファイルをリモートにコピーする
ポイントは remote_src=True
これにしとくとsrc=のパスでリモートサーバを探しに行く
defaultはFalseだから、これやらないとlocalのパスを検索にいくよ
yaml形式なのでスペースに注意
- hosts: test become: yes become_method: sudo vars: user_name: vagrant src_file: /home/vagrant/tmp.csv tasks: - user: name={{ user_name }} - name: copy httpd file copy: src={{ src_file }} remote_src=True dest=/home/{{ user_name }}/tmp2.csv
逆にSCPにしたいならremote_srcをなくせばいいわけです
ansibleってモジュール覚えきれねー
shellモジュールでゴリ押ししたくなるよね、、、、