Skip to content

Commit

Permalink
make the control_path pattern change for each build. make codeship-st…
Browse files Browse the repository at this point in the history
…eps.yml syntax simpler
  • Loading branch information
tuxpiper committed Nov 18, 2016
1 parent 0809f6a commit 7480c37
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
8 changes: 6 additions & 2 deletions codeship-steps.yml
Expand Up @@ -14,8 +14,12 @@
- name: "Deploy"
service: deploy
tag: develop
command: "ansible-playbook -vv -i hosts/rackspace_staging platform-api-update.yml -e=\"PLATFORM_CLIENT_VERSION=$CI_COMMIT_ID\""
command: >
ansible-playbook -vv -i hosts/rackspace_staging platform-api-update.yml
-e PLATFORM_CLIENT_VERSION="$CI_COMMIT_ID"
- name: "Deploy Production"
service: deploy
tag: production
command: "ansible-playbook -vv -i hosts/rackspace_prod platform-api-update.yml -e=\"PLATFORM_CLIENT_VERSION=$CI_COMMIT_ID\""
command: >
ansible-playbook -vv -i hosts/rackspace_prod platform-api-update.yml
-e PLATFORM_CLIENT_VERSION="$CI_COMMIT_ID"
2 changes: 1 addition & 1 deletion docker/deploy.Dockerfile
Expand Up @@ -2,7 +2,7 @@
FROM williamyeh/ansible:ubuntu14.04

# ==> Install git
RUN apt-get update && apt-get install git -y
RUN apt-get update && apt-get install git gettext -y

# ==> Set workging directory to /opt
WORKDIR /opt
Expand Down
17 changes: 14 additions & 3 deletions docker/deploy.run.sh
Expand Up @@ -14,14 +14,25 @@ if [ -n "${ANSIBLE_VAULT_PASSWORD}" ]; then
fi

# Append to ansible.cfg
cat >> /opt/ansible.cfg << EOM
envsubst >> /opt/ansible.cfg << EOM
[ssh_connection]
control_path=/dev/shm/ansible-ssh-%%h-%%p-%%r
control_path=/dev/shm/ansible-ssh-${CI_BUILD_ID}-%%h-%%p-%%r
EOM

# ==> Get latest deployment code from github
ansible-galaxy install -r roles.yml

exec $*
# Perform variable substitution on parameters
# i.e. if we get a parameter myvar="$CI_BRANCH" we substitute $CI_BRANCH for
# its actual value in the environment, and get i.e. myvar="master"
args=()
for p in $@; do
args+=(`printf '%s\n' $p | envsubst`)
done

# Execute parameter passed in arguments
echo executing: "${args[@]}"

exec "${args[@]}"

0 comments on commit 7480c37

Please sign in to comment.