Sign inSign up

vnvsa/deployer

By vnvsa

Updated 4 days ago

Allow you to run Ansible on machines to configure them for your project

Image
Integration & delivery
Developer tools
2

7.3K

vnvsa/deployer repository overview

Deployer Container

Docker container allowing you to run Ansible on machines to configure them for your project. It can also be used to run Ansistrano to deploy your project somewhere.

This container targets deployment from GitLab CI but you can also use it by using docker's CLI. You will need to do the following in the container to make it work:

The following softwares are installed:

  • Ansible 5.8.x for configuration management
  • gpg and sops for YAML secrets decryption
  • openssh for ssh connection and key forwarding

Use the container

  • start the ssh agent to make ssh agent key forwarding possible
  • put your ssh key inside the container to be able to access the target machines
  • setup your things according to your project (eg. decrypt secrets using sops, etc.)
  • run ansible/ansistrano

Here is an example of GitLab CI configuration. This configuration should be considered more as an inspiration than a guideline and example of best practice:

stages:
  - deploy

variables:
  ANSIBLE_HOST_KEY_CHECKING: 'False'

deploy:production:
  stage: deploy
  image: vnvsa/deployer:latest
  resource_group: production
  when: manual
  variables:
    ANSIBLE_HOST_KEY_CHECKING: 'False'
    target: production
  environment:
    name: production
    url: https://<your hostname>
    deployment_tier: production
  before_script:
    - eval $(ssh-agent -s)
    - echo "$DEPLOYMENT_PRODUCTION_KEY" | base64 -d | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
    - ssh-keyscan <your hostname>
    - make -C ansistrano install # install roles/collections required by Ansible (in "ansistrano" folder)
  allow_failure: false
  script:
    - export USER="$GITLAB_USER_LOGIN via gitlab"
    - make -C ansistrano deploy # Run deploy playbook (in "ansistrano" folder)
  rules:
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
      when: never
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_DEPLOY_FREEZE == null'
      when: manual
      allow_failure: false
    - if: '$CI_COMMIT_TAG && $CI_DEPLOY_FREEZE == null'
      when: manual
      allow_failure: false

Tag summary

Content type

Image

Digest

sha256:ee08a2ed3

Size

230.3 MB

Last updated

4 days ago

docker pull vnvsa/deployer