fix some common tasks
[awsible] / roles / common / tasks / awsacct.yml
diff --git a/roles/common/tasks/awsacct.yml b/roles/common/tasks/awsacct.yml
new file mode 100644 (file)
index 0000000..fdc9f8f
--- /dev/null
@@ -0,0 +1,9 @@
+---
+- name: Fetch IAM info
+  uri:
+    url: http://169.254.169.254/latest/meta-data/iam/info
+    return_content: yes
+  register: iamInfo
+- name: Extract Account ID
+  set_fact:
+    aws_account: "{{ (iamInfo.content|from_json).InstanceProfileArn | regex_replace('^arn:aws:iam::(\\d+):.*','\\\\1') }}"