Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSOS-2361: additional group vars for sub environments #447

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ansible/hosts/autoscaling_group_aws_ec2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ compose:
keyed_groups:
- key: tags['environment-name']
prefix: environment-name
- key: tags['environment-name'] + '-' + tags[application + '-environment']
wullub marked this conversation as resolved.
Show resolved Hide resolved
prefix: environment-name
- key: tags['ami']
prefix: ami
- key: tags['server-type']
prefix: server-type
- key: tags['server-type'] + '-' + tags[application + '-environment']
prefix: server-type
- key: tags['os-type'] | lower
prefix: os-type

Expand Down
4 changes: 4 additions & 0 deletions ansible/hosts/instance_aws_ec2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ compose:
keyed_groups:
- key: tags['environment-name']
prefix: environment-name
- key: tags['environment-name'] + '-' + tags[application + '-environment']
prefix: environment-name
- key: tags['ami']
prefix: ami
- key: tags['server-type']
prefix: server-type
- key: tags['server-type'] + '-' + tags[application + '-environment']
prefix: server-type
- key: tags['os-type'] | lower
prefix: os-type
- key: tags['environment-name'] + '_' + tags['delius-environment-name'] + '_all'
Expand Down
14 changes: 14 additions & 0 deletions ansible/roles/ansible-script/files/ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ run_ansible() {
fi
done

echo "# Checking for $application-environment tag using aws cli"
application_environment=$(aws ec2 describe-tags --filters "Name=resource-id,Values=$instance_id" "Name=key,Values=$application-environment" --output=text | head -1 | cut -f5)
if [[ -n $application_environment ]]; then
for ((i=0; i<${#tags[@]}; i++)); do
tag=(${tags[i]})
group=$(echo "${tag[1]}_${tag[4]}_${application_environment}" | tr [:upper:] [:lower:] | sed "s/-/_/g")
if [[ -e $ansible_dir/${ansible_repo}/${ansible_repo_basedir}/group_vars/$group.yml ]]; then
ansible_group_vars="$ansible_group_vars --extra-vars @group_vars/$group.yml"
elif [[ -e $ansible_dir/${ansible_repo}/${ansible_repo_basedir}/group_vars/$group/ansible.yml ]]; then
ansible_group_vars="$ansible_group_vars --extra-vars @group_vars/$group/ansible.yml"
fi
done
fi

# set python version
if [[ $(which python3.9 2> /dev/null) ]]; then
python=$(which python3.9)
Expand Down
Loading