From 1d6f18c7206a8a3e409ea50e89113015f4660200 Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Fri, 21 Apr 2017 15:12:46 -0700 Subject: [PATCH] split msca data volume into role --- management-d0dev.yml | 1 + roles/common/tasks/main.yml | 20 ++----------------- .../awsible.sh => templates/awsible.sh.j2} | 14 +++++++------ roles/msca-data-volume/tasks/main.yml | 16 +++++++++++++++ .../tasks/volumes.yml | 0 vpcaccess-d0dev.yml | 1 + 6 files changed, 28 insertions(+), 24 deletions(-) rename roles/common/{files/awsible.sh => templates/awsible.sh.j2} (62%) create mode 100644 roles/msca-data-volume/tasks/main.yml rename roles/{common => msca-data-volume}/tasks/volumes.yml (100%) diff --git a/management-d0dev.yml b/management-d0dev.yml index c73399a..4f15980 100644 --- a/management-d0dev.yml +++ b/management-d0dev.yml @@ -3,5 +3,6 @@ become: true roles: - common + - msca-data-volume - msca - management diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 12c6ff1..bbed536 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -1,20 +1,4 @@ --- -- name: bootstrap /data - stat: - path: /data - register: datadir -- include: volumes.yml - when: not datadir.stat.exists - -- name: Create local asset directory - when: ASSET_PATH is defined - file: - state: directory - path: "{{ ASSET_PATH }}" - mode: "0755" - owner: root - group: root - - name: Uninstall outdated python packages with_items: - aws-cli @@ -103,9 +87,9 @@ command: /usr/sbin/update-motd - name: profile stuff - copy: + template: dest: /etc/profile.d/awsible.sh - src: awsible.sh + src: awsible.sh.j2 mode: "0644" owner: root group: root diff --git a/roles/common/files/awsible.sh b/roles/common/templates/awsible.sh.j2 similarity index 62% rename from roles/common/files/awsible.sh rename to roles/common/templates/awsible.sh.j2 index e123c82..754e828 100644 --- a/roles/common/files/awsible.sh +++ b/roles/common/templates/awsible.sh.j2 @@ -1,4 +1,5 @@ # configure environment with AWS info +{% raw %} export INSTANCE_ID=`curl -sf http://169.254.169.254/latest/meta-data/instance-id` if ! export PUBLIC_HOSTNAME=`curl -sf http://169.254.169.254/latest/meta-data/public-hostname` then @@ -13,10 +14,11 @@ export EC2_AZ=`curl -sf http://169.254.169.254/latest/meta-data/placement/availa TMP="${#EC2_AZ}" export EC2_REGION="${EC2_AZ:0:$TMP-1}" unset TMP -# export CLOUD_ACCOUNT=awsAcctName... -# export CLOUD_MODULE=mytags['tags']['module']|default('(no module)') -# export CLOUD_STACK=stack|None -# export CLOUD_PHASE=mytags['tags']['phase']|default('None') - -# export CLOUD_AUTO_SCALE_GROUP= +{% endraw %} +# hard-code here for systems without userdata +export CLOUD_ACCOUNT={{ ACCT_NAME }} +export CLOUD_MODULE={{ my_tags['tags']['module']|default('(no module)') }} +export CLOUD_STACK={{ my_tags['tags']['stack']|default() }} +export CLOUD_PHASE={{ my_tags['tags']['phase']|default('None') }} +export CLOUD_AUTO_SCALE_GROUP={{ my_tags['tags']['aws:autoscaling:groupName']|default() }} # export CLOUD_LAUNCH_CONFIG=module-stack-country-phase-version diff --git a/roles/msca-data-volume/tasks/main.yml b/roles/msca-data-volume/tasks/main.yml new file mode 100644 index 0000000..3250416 --- /dev/null +++ b/roles/msca-data-volume/tasks/main.yml @@ -0,0 +1,16 @@ +--- +- name: bootstrap /data + stat: + path: /data + register: datadir +- include: volumes.yml + when: not datadir.stat.exists + +- name: Create local asset directory + when: ASSET_PATH is defined + file: + state: directory + path: "{{ ASSET_PATH }}" + mode: "0755" + owner: root + group: root diff --git a/roles/common/tasks/volumes.yml b/roles/msca-data-volume/tasks/volumes.yml similarity index 100% rename from roles/common/tasks/volumes.yml rename to roles/msca-data-volume/tasks/volumes.yml diff --git a/vpcaccess-d0dev.yml b/vpcaccess-d0dev.yml index c8cb694..1f4bb96 100644 --- a/vpcaccess-d0dev.yml +++ b/vpcaccess-d0dev.yml @@ -3,6 +3,7 @@ become: true roles: - common + - msca-data-volume - msca - vpcaccess - role: msca-openvpn -- 2.45.2