by shigemk2

当面は技術的なことしか書かない

ansible templete メモ 複数ファイルのコピー

serverfault.com

template - Templates a file out to a remote server. — Ansible Documentation

copy - Copies files to remote locations. — Ansible Documentation

  1. key valueでsrcとdestを書き換えるやつ
 - name:  template everything for fooserv
   template: src={{item.0}} dest={{item.1}}
   with_items:
      - [ 'templates/foo.j2', '/etc/splat/foo.conf' ]
      - [ 'templates/bar.j2', '/etc/splat/bar.conf' ]
   notify: 
      - restart fooserv
  1. そのまんまコピーするやつ
 - name:  template everything for fooserv
   template: src={{item}} dest={{item}}
   with_items:
      - [ 'templates/foo.conf' ]
      - [ 'templates/bar.conf' ]
   notify: 
      - restart fooserv