From ef3e5a1e20a4c84584ce27649c959903d416cd6c Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 12 Sep 2019 23:34:55 +0200 Subject: [PATCH] Change ansible config, move files into templates folder --- ansible.yml | 29 +++++++++++++------ {communistquotes => templates}/Dockerfile | 0 {communistquotes => templates}/main.py | 0 .../marxistquotes.csv | 0 .../requirements.txt | 0 5 files changed, 20 insertions(+), 9 deletions(-) rename {communistquotes => templates}/Dockerfile (100%) rename {communistquotes => templates}/main.py (100%) rename {communistquotes => templates}/marxistquotes.csv (100%) rename {communistquotes => templates}/requirements.txt (100%) diff --git a/ansible.yml b/ansible.yml index 249ebd6..eb1ec33 100644 --- a/ansible.yml +++ b/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" diff --git a/communistquotes/Dockerfile b/templates/Dockerfile similarity index 100% rename from communistquotes/Dockerfile rename to templates/Dockerfile diff --git a/communistquotes/main.py b/templates/main.py similarity index 100% rename from communistquotes/main.py rename to templates/main.py diff --git a/communistquotes/marxistquotes.csv b/templates/marxistquotes.csv similarity index 100% rename from communistquotes/marxistquotes.csv rename to templates/marxistquotes.csv diff --git a/communistquotes/requirements.txt b/templates/requirements.txt similarity index 100% rename from communistquotes/requirements.txt rename to templates/requirements.txt