Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Kovah
Created November 25, 2022 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kovah/e76519e42984d8da7542b2f5f5cf987f to your computer and use it in GitHub Desktop.
Save Kovah/e76519e42984d8da7542b2f5f5cf987f to your computer and use it in GitHub Desktop.
Linkace Ansible 2022-11 - Playbook
---
- hosts: linkace
vars_files:
- vars.yml
tasks:
- name: Initialize the deploy root
deploy_helper: path={{ site_root }}
- name: Create new release directory
file:
path: "{{ deploy_helper.new_release_path }}"
state: directory
- name: Add an unfinished file, to allow cleanup on successful finalize
file:
path: "{{ deploy_helper.new_release_path }}/{{ deploy_helper.unfinished_filename }}"
state: touch
- name: Create a .env file
template:
src: "{{ env_source }}"
dest: "{{ env_destination }}"
- name: Create a docker-compose.yml file
template:
src: "{{ docker_compose_source }}"
dest: "{{ docker_compose_destination }}"
- name: Finalize the deploy, removing the unfinished file and switching the symlink
deploy_helper:
path: "{{ site_root }}"
release: "{{ deploy_helper.new_release }}"
state: finalize
- name: Pull latest version of the image
shell: "docker pull {{ docker_image }}"
- name: Run the docker compose file
shell: "docker-compose up -d"
args:
chdir: "{{ deploy_helper.new_release_path }}"
- name: Add the demo reset cron job
cron:
name: "{{ item.name }}"
minute: "{{ item.schedule.min }}"
hour: "{{ item.schedule.hour }}"
day: "{{ item.schedule.day }}"
month: "{{ item.schedule.month }}"
weekday: "{{ item.schedule.weekday }}"
job: "{{ item.command }}"
with_items: "{{ cronjobs }}"
when: cronjobs is defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment