Skip to content

Instantly share code, notes, and snippets.

@gbirke
Last active September 10, 2020 17:54
Show Gist options
  • Save gbirke/91a1325d0abeaacfa6b3f703e24d95d1 to your computer and use it in GitHub Desktop.
Save gbirke/91a1325d0abeaacfa6b3f703e24d95d1 to your computer and use it in GitHub Desktop.
Notes from my experimentation with Drone CI
---
kind: pipeline
type: docker
name: default
steps:
- name: deploy
image: wikimediade/fundraising-ansible-deploy
pull: never # Until we publish the image
user: ansible
environment:
SSH_PRIVATE_KEY:
from_secret: ssh_key
commands:
- mkdir /ansible/.ssh
- echo "$SSH_PRIVATE_KEY" > /ansible/.ssh/id_rsa
chmod 700 /ansible/.ssh
- chmod 600 /ansible/.ssh/id_rsa
- ssh -o StrictHostKeyChecking=no [email protected] # Workaround for failing host key check in Ansible
- ansible-playbook -i /ansible/inventory/servers.ini -v -l fundraising_frontend_test -e prebuilt_source="$DRONE_WORKSPACE" -u deploy /ansible/deployments/content.yml

Notes from my experimentation with Drone CI

Goal

Automate builds with Drone CI in three repositories, "bootstrapping" from scratch:

  • Build a small Docker image that contains Ansible
  • Package atomic deployment playbooks into Docker image from previous step
  • Deploy the fundraising i18n repository content, using the image from previous step

Done in last B&C

  • Create .drone.yml to build dockerized Ansible
  • Change Ansible playbook for deployments to accept source folder instead of doing checkout, Drone is doing the checkout
  • Create Docker image with deployment playbooks
  • Start working on the Drone pipeline for content

Done this B&C

  • Update Dockerfile to build dockerized Ansible
  • Rebase the branch for the Ansible playbook for deployment
  • Create Docker image with deployment playbooks (😭😭😭 AGAIN 😭😭😭)
  • Document all the things!

TODO

  • Finish .drone.yml to build deploy content repository with Ansible. Most pressing question: SSH key management
  • Test server setup on local machine with ngrok
  • different pipelines/parameters for test and prod instead of hardwired test
  • add triggers for the branches
  • set up permanent server
  • Build & publish ansible Docker images using plugin/docker instead of building them with local docker socket.
  • Investigate if the host docker socket can be defined as a host volume and mounted into an image (for running docker commands, e.g. in a Makefile during a deploymnet).

Learnings

Notes

Repositories

Docker images

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment