|
24 | 24 | # The second minio instance on this server. |
25 | 25 | server2: |
26 | 26 | server_addr: ":9092" |
| 27 | + # Cargohold IAM setup |
| 28 | + cargohold_policy_name: "cargohold-assets-policy" |
| 29 | + cargohold_user_name: "cargohold-user" |
27 | 30 | roles: |
28 | 31 | - role: ansible-minio |
29 | 32 | minio_layout: server1 |
|
60 | 63 | run_once: true |
61 | 64 | tags: mc-config |
62 | 65 |
|
| 66 | + # Cargohold IAM Setup |
| 67 | + - name: "Create cargohold policy file" |
| 68 | + copy: |
| 69 | + content: | |
| 70 | + { |
| 71 | + "Version": "2012-10-17", |
| 72 | + "Statement": [ |
| 73 | + { |
| 74 | + "Effect": "Allow", |
| 75 | + "Action": [ |
| 76 | + "s3:GetObject", |
| 77 | + "s3:PutObject", |
| 78 | + "s3:ListBucket" |
| 79 | + ], |
| 80 | + "Resource": [ |
| 81 | + "arn:aws:s3:::assets", |
| 82 | + "arn:aws:s3:::assets/*" |
| 83 | + ] |
| 84 | + } |
| 85 | + ] |
| 86 | + } |
| 87 | + dest: "/tmp/{{ cargohold_policy_name }}.json" |
| 88 | + run_once: true |
| 89 | + tags: cargohold-iam |
| 90 | + |
| 91 | + - name: "Add cargohold policy to MinIO" |
| 92 | + shell: "mc admin policy create local {{ cargohold_policy_name }} /tmp/{{ cargohold_policy_name }}.json" |
| 93 | + run_once: true |
| 94 | + ignore_errors: yes # Policy might already be attached, which is fine |
| 95 | + tags: cargohold-iam |
| 96 | + |
| 97 | + - name: "Generate random password for cargohold user" |
| 98 | + set_fact: |
| 99 | + cargohold_temp_password: "{{ 999999999999999999999 | random | to_uuid }}" |
| 100 | + run_once: true |
| 101 | + tags: cargohold-iam |
| 102 | + |
| 103 | + - name: "Create cargohold IAM user" |
| 104 | + shell: "mc admin user add local {{ cargohold_user_name }} {{ cargohold_temp_password }}" |
| 105 | + run_once: true |
| 106 | + ignore_errors: yes # Will fail if user already exists, which is fine |
| 107 | + tags: cargohold-iam |
| 108 | + |
| 109 | + - name: "Attach policy to cargohold user" |
| 110 | + shell: "mc admin policy attach local {{ cargohold_policy_name }} --user {{ cargohold_user_name }}" |
| 111 | + run_once: true |
| 112 | + ignore_errors: yes # Policy might already be attached |
| 113 | + tags: cargohold-iam |
| 114 | + |
| 115 | + - name: "Create service account for cargohold with specific access key" |
| 116 | + shell: "mc admin user svcacct add --access-key {{ minio_cargohold_access_key }} --secret-key {{ minio_cargohold_secret_key }} local {{ cargohold_user_name }}" |
| 117 | + run_once: true |
| 118 | + register: cargohold_svcacct_result |
| 119 | + ignore_errors: yes # Will fail if key already exists, which is fine |
| 120 | + tags: cargohold-iam |
| 121 | + |
| 122 | + - name: "Verify cargohold service account" |
| 123 | + shell: "mc admin user svcacct ls local {{ cargohold_user_name }}" |
| 124 | + run_once: true |
| 125 | + register: cargohold_svcacct_list |
| 126 | + tags: cargohold-iam |
| 127 | + |
| 128 | + - name: "List cargohold service accounts" |
| 129 | + debug: |
| 130 | + var: cargohold_svcacct_list.stdout |
| 131 | + tags: cargohold-iam |
63 | 132 | - name: "remove unneeded config aliases added by default" |
64 | 133 | shell: "mc config host rm {{ item }}" |
65 | 134 | with_items: |
66 | 135 | - gcs |
67 | 136 | - s3 |
68 | 137 | - play |
| 138 | + ignore_errors: yes |
69 | 139 | tags: mc-config |
70 | 140 |
|
71 | 141 | # This play has to run after minio is installed and buckets are configured |
|
0 commit comments