Skip to content

Instantly share code, notes, and snippets.

@hmm01i
Created June 7, 2018 01:17
Show Gist options
  • Save hmm01i/df493181185b4b1097859f6902c7582c to your computer and use it in GitHub Desktop.
Save hmm01i/df493181185b4b1097859f6902c7582c to your computer and use it in GitHub Desktop.
Example gitlab-ci script for ansible automation deployment
---
image: 'williamyeh/ansible:centos7'
variables:
ANSIBLE_ROLES_PATH: './roles/'
ANSIBLE_VAULT_PASSWORD_FILE: '/root/.ssh/vault.sh'
ANSIBLE_TIMEOUT: 60 # some systems are very slow to establish ssh connection
before_script:
- "ansible --version" # for verbosity
- "yum -y install git" # not git in these containers
- "eval `ssh-agent -s`"
- "sshpass -e -P: ssh-add /root/.ssh/ansible_rsa" # allows us to use ssh keys with password
# - "ansible-galaxy install -r requirements.yml -v --force" # download the requirements
# no test stage. non-prod branch is test
stages:
- deploy
# doing a deploy with --check
deploy_check:
stage: deploy
tags:
- docker
script:
- "ansible-playbook playbook.yml --diff --check"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment