blender-studio/playbooks/deploy.yaml

26 lines
825 B
YAML

---
- hosts: http
gather_facts: true
become: true
become_user: "{{ user }}"
roles: [common]
vars:
playbook_type: deploy
lock_file_path: /tmp/deploy-{{project_slug}}.lock
tasks:
- import_tasks: tasks/pull.yaml
- import_tasks: tasks/deploy.yaml
pre_tasks:
- stat: path={{lock_file_path}}
register: lock_file
- fail: msg="Another deploy was already started by {{lock_file.stat.pw_name}} {{((ansible_date_time.epoch|float - lock_file.stat.mtime) / 60)|int}}min ago.\nAdd '-e override_lock=true' to override if the deploy was abandoned."
when: lock_file.stat.exists|bool and override_lock is undefined
- copy: dest={{lock_file_path}} content="{{ansible_user_id}} locked at {{now(fmt='%Y-%m-%d %H:%M:%S')}}"
post_tasks:
- file: path={{lock_file_path}} state=absent