Skip to content

Commit 5e643d9

Browse files
author
matthias_schaub
committed
Add ssh config for travis to make it agnostic to which private key is used to deploy.
1 parent 2371c7f commit 5e643d9

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

.travis.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ script:
4141
after_success:
4242
# Deploy to development server using Ansible
4343
# SSH setup to deploy to server after build.
44-
# - apk add openssh-client
45-
# - mkdir -p ~/.ssh
46-
# - chmod 700 ~/.ssh
44+
- apk add openssh-client
4745
- eval "$(ssh-agent -s)" #start the ssh agent
48-
- openssl aes-256-cbc -K $encrypted_c17fa81e6490_key -iv $encrypted_c17fa81e6490_iv -in travis/ssh-private-key.enc -out travis/ssh-private-key -d
49-
- chmod 600 travis/ssh-private-key
50-
- ssh-add travis/ssh-private-key
46+
- mkdir -p $HOME/.ssh
47+
# - chmod 700 $HOME/.ssh
48+
- cp travis/ssh_config $HOME/.ssh/config
49+
- openssl aes-256-cbc -K $encrypted_c17fa81e6490_key -iv $encrypted_c17fa81e6490_iv -in travis/ssh-private-key.enc -out $HOME/.ssh/private-key -d
50+
- chmod 600 $HOME/.ssh/private-key
51+
- ssh-add $HOME/.ssh/private-key
5152
- chmod +x deploy.sh
5253

5354
deploy:

ansible/inventory.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
all:
22
hosts:
3-
dev:
3+
development:
44
ansible_host: 35.190.148.87
55
ansible_user: mapswipe
6-
ansible_ssh_private_key_file: travis/ssh-private-key
6+
# Uncomment following line when not using ~/.ssh/config
7+
# ansible_ssh_private_key_file: $HOME/.ssh/private-key
8+
production:
9+
ansible_host: 35.231.228.82
10+
ansible_user: mapswipe
11+
# Uncomment following line when not using ~/.ssh/config
12+
# ansible_ssh_private_key_file: $HOME/.ssh/private-key

ansible/playbook.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
- name: Deploy MapSwipe Backend
3-
hosts: dev
3+
hosts: development
44

55
tasks:
66
- name: Fetch latest code base from GitHub.
77
git:
88
repo: 'https://github.com/mapswipe/python-mapswipe-workers.git'
9-
dest: /home/mapswipe/python-mapswipe-workers
9+
dest: $HOME/python-mapswipe-workers
1010
version: dev
1111
- name: Rebuild and restart Docker container usind Docker-Compose.
12-
script: /home/mapswipe/python-mapswipe-worker/recreate_container.sh
12+
script: $HOME/python-mapswipe-worker/recreate_container.sh

travis/ssh_config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Host mapswipe-production
2+
User mapswipe
3+
HostName 35.231.228.82
4+
IdentitiesOnly yes
5+
IdentityFile $HOME/.ssh/private-key
6+
Host mapswipe-development
7+
User mapswipe
8+
HostName 35.190.148.87
9+
IdentitiesOnly yes
10+
IdentityFile $HOME/.ssh/private-key

0 commit comments

Comments
 (0)