From 959f205e82efbae0d89d1c34e29fb34b3b15afa6 Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Thu, 9 Mar 2017 13:34:58 -0800 Subject: [PATCH] fix some common tasks --- roles/common/tasks/awsacct.yml | 9 +++++++++ roles/common/tasks/main.yml | 2 +- roles/common/tasks/volumes.yml | 3 +++ roles/common/{files => templates}/aws.config.j2 | 0 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 roles/common/tasks/awsacct.yml rename roles/common/{files => templates}/aws.config.j2 (100%) diff --git a/roles/common/tasks/awsacct.yml b/roles/common/tasks/awsacct.yml new file mode 100644 index 0000000..fdc9f8f --- /dev/null +++ b/roles/common/tasks/awsacct.yml @@ -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') }}" diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index b92b517..1cbf044 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -46,7 +46,7 @@ group: root - name: Install any facts. - with_items: "{{ fact_scripts|default(None) }}" + with_items: "{{ fact_scripts|default([]) }}" copy: dest: /etc/ansible/facts.d/{{ item }}.fact src: "{{ item }}.fact" diff --git a/roles/common/tasks/volumes.yml b/roles/common/tasks/volumes.yml index 8d09506..530d81b 100644 --- a/roles/common/tasks/volumes.yml +++ b/roles/common/tasks/volumes.yml @@ -25,3 +25,6 @@ file: state: link path: /data + src: "{{ data_mount_path }}" + owner: ec2-user + group: ec2-user diff --git a/roles/common/files/aws.config.j2 b/roles/common/templates/aws.config.j2 similarity index 100% rename from roles/common/files/aws.config.j2 rename to roles/common/templates/aws.config.j2 -- 2.45.2