about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--base_apps.yml7
-rw-r--r--bootstrap.yml17
-rw-r--r--composer/app/Dockerfile5
-rw-r--r--composer/app/app.py29
-rw-r--r--composer/app/docker-compose.yml8
-rw-r--r--composer/app/requirements.txt2
-rw-r--r--docker.yml14
7 files changed, 75 insertions, 7 deletions
diff --git a/base_apps.yml b/base_apps.yml
index b07f991..041c8af 100644
--- a/base_apps.yml
+++ b/base_apps.yml
@@ -23,6 +23,7 @@
       - hugo
       - rsync
       - python-pip
+      - mc
     - apt:
         upgrade: full
     - pip:
@@ -31,3 +32,9 @@
       - docker
       - docker-compose
 
+    - systemd:
+        enabled: true
+        state: started
+        name: "{{ item }}"
+      with_items:
+      - "syncthing@pawel"
diff --git a/bootstrap.yml b/bootstrap.yml
index 012ce90..6a00e93 100644
--- a/bootstrap.yml
+++ b/bootstrap.yml
@@ -16,14 +16,17 @@
     - base_users
     tasks:
     - name: zsh
-      apt: name=zsh
-    #- name: Allow paswordless sudo
-    #  lineinfile:
-    #    dest: /etc/sudoers
-    #    state: present
-    #    regexp: "^%sudo"
+      apt: 
+        name: zsh
+        update_cache: true
+    - name: Allow paswordless sudo
+      lineinfile:
+        dest: /etc/sudoers
+        state: present
+        insertafter: "^%sudo"
+        line: "ansible_worker\tALL=(ALL:ALL) NOPASSWD: ALL"
+        validate: '/usr/sbin/visudo -cf %s'
     #    line: "%sudo ALL=(ALL) NOPASSWD: ALL"
-    #    validate: '/usr/sbin/visudo -cf %s'
     - file:
         path: /home/pawel/.zshrc
         owner: pawel
diff --git a/composer/app/Dockerfile b/composer/app/Dockerfile
new file mode 100644
index 0000000..8e67d74
--- /dev/null
+++ b/composer/app/Dockerfile
@@ -0,0 +1,5 @@
+FROM python:3.4-alpine
+ADD . /code
+WORKDIR /code
+RUN pip install -r requirements.txt
+CMD ["python", "app.py"]
diff --git a/composer/app/app.py b/composer/app/app.py
new file mode 100644
index 0000000..9bf5d90
--- /dev/null
+++ b/composer/app/app.py
@@ -0,0 +1,29 @@
+import time
+
+import redis
+from flask import Flask
+
+
+app = Flask(__name__)
+cache = redis.Redis(host='redis', port=6379)
+
+
+def get_hit_count():
+    retries = 5
+    while True:
+        try:
+            return cache.incr('hits')
+        except redis.exceptions.ConnectionError as exc:
+            if retries == 0:
+                raise exc
+            retries -= 1
+            time.sleep(0.5)
+
+
+@app.route('/')
+def hello():
+    count = get_hit_count()
+    return 'Hello from this site! I have been seen {} times.\n'.format(count)
+
+if __name__ == "__main__":
+    app.run(host="0.0.0.0", debug=True)
diff --git a/composer/app/docker-compose.yml b/composer/app/docker-compose.yml
new file mode 100644
index 0000000..899cf44
--- /dev/null
+++ b/composer/app/docker-compose.yml
@@ -0,0 +1,8 @@
+version: '3'
+services:
+  web:
+    build: .
+    ports:
+     - "5000:5000"
+  redis:
+    image: "redis:alpine"
diff --git a/composer/app/requirements.txt b/composer/app/requirements.txt
new file mode 100644
index 0000000..1a5dc97
--- /dev/null
+++ b/composer/app/requirements.txt
@@ -0,0 +1,2 @@
+flask
+redis
diff --git a/docker.yml b/docker.yml
new file mode 100644
index 0000000..7ceded3
--- /dev/null
+++ b/docker.yml
@@ -0,0 +1,14 @@
+---
+  - name: Docker apps
+    hosts: tamriel
+    remote_user: ansible_worker
+    tasks:
+    - synchronize:
+        src: composer/
+        dest: composer
+    - docker_service:
+        project_src: composer/app
+        recreate: always
+      register: output
+    - debug:
+        var: output