41 lines
1.2 KiB
YAML
41 lines
1.2 KiB
YAML
---
|
|
- hosts: all
|
|
|
|
# Install python if required
|
|
# https://www.josharcher.uk/code/ansible-python-connection-failure-ubuntu-server-1604/
|
|
gather_facts: False
|
|
pre_tasks:
|
|
- name: install python for Ansible
|
|
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal python-setuptools)
|
|
args:
|
|
executable: /bin/bash
|
|
register: output
|
|
changed_when: output.stdout != ""
|
|
- setup: # gather facts
|
|
|
|
tasks:
|
|
# TODO: this approach sucks because it always deploys from current master, instead of the local files
|
|
- name: clone/update git repo
|
|
git:
|
|
repo: 'https://0xacab.org/radical_coder/pinko.red.git'
|
|
dest: /pinkored
|
|
|
|
- name: Build image using cache source
|
|
docker_image:
|
|
name: communistquotes:latest
|
|
build:
|
|
path: /pinkored/communistquotes/
|
|
pull: yes
|
|
source: build
|
|
force_source: yes
|
|
force_tag: yes
|
|
|
|
- name: add all template files
|
|
template: src=env dest=/pinkored/env
|
|
|
|
- name: create crontab
|
|
cron:
|
|
name: "communist-quotes"
|
|
hour: "*/3"
|
|
minute: "0"
|
|
job: "perl -le 'sleep rand 10800' && docker run --rm --name communistquotes --env-file /pinkored/env communistquotes >> /var/log/communistquotes.log 2>&1"
|