Skip to content

Instantly share code, notes, and snippets.

@stefanotroia
Created November 5, 2019 17:13
Show Gist options
  • Save stefanotroia/430ce69f18bbd31ebf5061f92186f0fd to your computer and use it in GitHub Desktop.
Save stefanotroia/430ce69f18bbd31ebf5061f92186f0fd to your computer and use it in GitHub Desktop.
Deploy in gitlab ci job with ansible
deploy:
image:
name: stefanotroia/ansible:latest
stage: deploy
script:
- printf "[ci_group]\n $SSH_SERVER ansible_ssh_user=$SSH_USER \n" > /etc/ansible/hosts
- cp $SSH_KEY key.pem && chmod 600 key.pem
- eval `keychain --eval` > /dev/null 2>&1
- ssh-add key.pem
- ansible-playbook $CI_PROJECT_DIR/ansible-scripts/deploy.yml
only:
- development
- staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment