Change ansible config, move files into templates folder
This commit is contained in:
parent
97b7a6e491
commit
ef3e5a1e20
5 changed files with 20 additions and 9 deletions
29
ansible.yml
29
ansible.yml
|
@ -14,28 +14,39 @@
|
|||
- 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: create folder for build files
|
||||
file: path=/tmp/communistquotes state=directory
|
||||
|
||||
- name: copy build files
|
||||
copy: src=templates/{{item.filename}} dest=/tmp/communistquotes/{{item.filename}}
|
||||
with_items:
|
||||
- { filename: 'Dockerfile' }
|
||||
- { filename: 'main.py' }
|
||||
- { filename: 'marxistquotes.csv' }
|
||||
- { filename: 'requirements.txt' }
|
||||
|
||||
- name: Build image using cache source
|
||||
docker_image:
|
||||
name: communistquotes:latest
|
||||
build:
|
||||
path: /pinkored/communistquotes/
|
||||
path: /tmp/communistquotes
|
||||
pull: yes
|
||||
source: build
|
||||
force_source: yes
|
||||
force_tag: yes
|
||||
|
||||
- name: add all template files
|
||||
template: src=env dest=/pinkored/env
|
||||
- name: delete build files
|
||||
file: path=/tmp/communistquotes state=absent
|
||||
|
||||
- name: create config folder
|
||||
file: path=/etc/communistquotes state=directory mode=700
|
||||
|
||||
- name: add env file
|
||||
copy: src=env dest=/etc/communistquotes/env mode=600
|
||||
|
||||
- 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"
|
||||
job: "perl -le 'sleep rand 10800' && docker run --rm --name communistquotes --env-file /etc/communistquotes/env communistquotes >> /var/log/communistquotes.log 2>&1"
|
||||
|
|
Loading…
Reference in a new issue