Created
June 7, 2018 01:17
-
-
Save hmm01i/df493181185b4b1097859f6902c7582c to your computer and use it in GitHub Desktop.
Example gitlab-ci script for ansible automation deployment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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