Ansible mountモジュールを使ってEFSをマウントするサンプル

環境
Ansible 2.9
AWS EC2

playbookのパラメータについて
*path
マウントポイントのパス

src
pathにマウントするデバイス

fstype
fsの種類

opts
マウントオプション

*state
mounted デバイスをマウントし、fstabを変更する
unmounted fstabを変更せずにデバイスをアンマウントする

使用例

- name: create efs mount point
  file: 
   dest: "/home/ec2-user/data"
   state: directory

- name: mount efs volume
  mount:
   path: "/home/ec2-user/data"
   src: "fs-xxxxx.efs.ap-northeast-1.amazonaws.com:/"
   fstype: "nfs4"
   opts: "xxxx,retrans=2,noresvport,_netdev"
   state: mounted

 

Ansible

Posted by arkgame