From 16145f12002624f098be35b4108d38d9d23146df Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Mon, 12 Dec 2022 10:58:43 -0800 Subject: config: start rss stack using docker-compose --- rss.jinwei.me/config/requirements.yaml | 2 ++ rss.jinwei.me/config/roles/rss/tasks/main.yaml | 32 ++++++++++++++++++++++ .../roles/rss/templates/docker-compose.yaml.j2 | 1 + 3 files changed, 35 insertions(+) diff --git a/rss.jinwei.me/config/requirements.yaml b/rss.jinwei.me/config/requirements.yaml index 5229cc7..bb232f3 100644 --- a/rss.jinwei.me/config/requirements.yaml +++ b/rss.jinwei.me/config/requirements.yaml @@ -8,3 +8,5 @@ collections: version: 1.3.0 - name: community.docker version: 3.2.1 + - name: community.mysql + version: 3.5.1 diff --git a/rss.jinwei.me/config/roles/rss/tasks/main.yaml b/rss.jinwei.me/config/roles/rss/tasks/main.yaml index 16091cb..070c48e 100644 --- a/rss.jinwei.me/config/roles/rss/tasks/main.yaml +++ b/rss.jinwei.me/config/roles/rss/tasks/main.yaml @@ -1,3 +1,35 @@ +- name: install packages + apt: + name: + - python3-pymysql + update_cache: true + +- name: create ttrss database if not exists + community.mysql.mysql_db: + login_host: "{{ lookup('aws_ssm', '/jinwei-me/mysql/host') }}" + login_port: "{{ lookup('aws_ssm', '/jinwei-me/mysql/port') }}" + login_user: "{{ lookup('aws_ssm', '/jinwei-me/mysql/username') }}" + login_password: "{{ lookup('aws_ssm', '/jinwei-me/mysql/password') }}" + name: "{{ lookup('aws_ssm', '/jinwei-me/mysql/ttrss_db_name') }}" + state: present + +- name: create ttrss database user + community.mysql.mysql_user: + login_host: "{{ lookup('aws_ssm', '/jinwei-me/mysql/host') }}" + login_port: "{{ lookup('aws_ssm', '/jinwei-me/mysql/port') }}" + login_user: "{{ lookup('aws_ssm', '/jinwei-me/mysql/username') }}" + login_password: "{{ lookup('aws_ssm', '/jinwei-me/mysql/password') }}" + name: "{{ lookup('aws_ssm', '/jinwei-me/mysql/ttrss_db_user') }}" + host: "*" + password: "{{ lookup('aws_ssm', '/jinwei-me/mysql/ttrss_db_password') }}" + priv: "{{ lookup('aws_ssm', '/jinwei-me/mysql/ttrss_db_name') }}.*:ALL" + state: present + +- name: create rss_home + file: + path: "{{ rss_home }}" + state: directory + - name: render Dockerfile.rssbot template: src: Dockerfile.rssbot.j2 diff --git a/rss.jinwei.me/config/roles/rss/templates/docker-compose.yaml.j2 b/rss.jinwei.me/config/roles/rss/templates/docker-compose.yaml.j2 index fd556dc..99da1a9 100644 --- a/rss.jinwei.me/config/roles/rss/templates/docker-compose.yaml.j2 +++ b/rss.jinwei.me/config/roles/rss/templates/docker-compose.yaml.j2 @@ -25,6 +25,7 @@ services: rssbot: build: + context: . dockerfile: ./Dockerfile.rssbot container_name: ttrss_rssbot restart: always -- cgit v1.2.3