LoginSignup
0
0

More than 1 year has passed since last update.

【自分用メモ】goofysでAWSのS3バケットをAnsibleを使ってマウントする

Posted at

前提

  • 環境
    • AWS
    • RHEL8.6
    • ansible 2.9.27

やったこと

ポリシー

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "s3:GetAccessPoint",
                "s3:PutAccountPublicAccessBlock",
                "s3:GetAccountPublicAccessBlock",
                "s3:ListAllMyBuckets",
                "s3:ListAccessPoints",
                "s3:ListJobs",
                "s3:CreateJob"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::<バケット名>",
                "arn:aws:s3:::<バケット名>/*"
            ],
            "Effect": "Allow"
        }
    ]
}

インスタンスに上記ポリシーが追加されたIAMロールを直接アタッチしました。

Ansible

- name: install packages
  yum:
    name: "{{ packages }}"
  vars:
    packages:
      - fuse
      - golang
  become: true

- name: download bind
  get_url:
    url: https://github.com/kahing/goofys/releases/download/v0.24.0/goofys
    dest: /usr/local/bin/goofys

- name: change permissions on goofys
  file:
    path: /usr/local/bin/goofys
    owner: root
    group: root
    mode: 0755

- name: bucket is mounted
  mount:
    path: "{{ <マウントパス> }}"
    src: "/usr/local/bin/goofys#dev-mkamimura-{{ <バケット名> }}-s3b"
    fstype: fuse
    opts: _netdev,allow_other,--dir-mode=0755,--file-mode=0644,--uid=0,--gid=0
    dump: 0
    passno: 0
    state: mounted

goが使えなかったのでget_urlで持ってきました(golangは不要だったかも)。

Ansible実行後

  • /etc/fstabの設定例
/usr/local/bin/goofys#<バケット名> <マウントパス> fuse _netdev,allow_other,--dir-mode=0755,--file-mode=0644,--uid=0,--gid=0 0 0
  • df -hの実行例
<バケット名>   1.0P     0  1.0P    0% <マウントパス>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0