From 41a97aa43ed021a57da2f0bdabda677ba39e1786 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Mon, 12 Dec 2022 14:33:53 -0800 Subject: infra: remove rss --- jinwei.me/infra/cloudflare.tf | 17 ------------- jinwei.me/infra/variables.tf | 5 ---- rss.jinwei.me/config/roles/rss/tasks/main.yaml | 12 ++++----- .../roles/rss/templates/docker-compose.yaml.j2 | 29 ---------------------- rss.jinwei.me/infra/rds.tf | 2 +- rss.jinwei.me/infra/ssm.tf | 28 ++++++++++----------- rss.jinwei.me/infra/variables.tf | 10 ++++---- 7 files changed, 26 insertions(+), 77 deletions(-) delete mode 100644 rss.jinwei.me/config/roles/rss/templates/docker-compose.yaml.j2 diff --git a/jinwei.me/infra/cloudflare.tf b/jinwei.me/infra/cloudflare.tf index 1b157d8..d0f7b8a 100644 --- a/jinwei.me/infra/cloudflare.tf +++ b/jinwei.me/infra/cloudflare.tf @@ -35,18 +35,6 @@ resource "cloudflare_record" "tunnel_dns" { proxied = true } -# TODO -# since cloudflare terraform provider does not provide an argo tunnel data source -# refactor this as a separate module? -# https://registry.terraform.io/providers/cloudflare/cloudflare/3.29.0 -resource "cloudflare_record" "rss_dns" { - zone_id = data.cloudflare_zones.domain.zones[0].id - name = var.feed_domain - value = "${cloudflare_argo_tunnel.tunnel.id}.cfargotunnel.com" - type = "CNAME" - proxied = true -} - resource "cloudflare_tunnel_config" "tunnel_route" { account_id = var.cloudflare_account_id tunnel_id = cloudflare_argo_tunnel.tunnel.id @@ -57,11 +45,6 @@ resource "cloudflare_tunnel_config" "tunnel_route" { path = "/" service = "http://127.0.0.1:30081" } - ingress_rule { - hostname = "feed.jinwei.me" - path = "/" - service = "http://127.0.0.1:30082" - } ingress_rule { service = "http_status:404" } diff --git a/jinwei.me/infra/variables.tf b/jinwei.me/infra/variables.tf index a3cf8bb..87283cc 100644 --- a/jinwei.me/infra/variables.tf +++ b/jinwei.me/infra/variables.tf @@ -55,11 +55,6 @@ variable "site_domain" { default = "jinwei.me" } -variable "feed_domain" { - type = string - default = "feed.jinwei.me" -} - variable "s3_cdn_name" { type = string default = "static" diff --git a/rss.jinwei.me/config/roles/rss/tasks/main.yaml b/rss.jinwei.me/config/roles/rss/tasks/main.yaml index d70729a..f62c897 100644 --- a/rss.jinwei.me/config/roles/rss/tasks/main.yaml +++ b/rss.jinwei.me/config/roles/rss/tasks/main.yaml @@ -4,25 +4,25 @@ - python3-pymysql update_cache: true -- name: create ttrss database if not exists +- name: create rss 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') }}" + name: "{{ lookup('aws_ssm', '/jinwei-me/mysql/rss_db_name') }}" state: present -- name: create ttrss database user +- name: create rss 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') }}" + name: "{{ lookup('aws_ssm', '/jinwei-me/mysql/rss_db_user') }}" host: "%" - password: "{{ lookup('aws_ssm', '/jinwei-me/mysql/ttrss_db_password') }}" - priv: "{{ lookup('aws_ssm', '/jinwei-me/mysql/ttrss_db_name') }}.*:ALL" + password: "{{ lookup('aws_ssm', '/jinwei-me/mysql/rss_user_password') }}" + priv: "{{ lookup('aws_ssm', '/jinwei-me/mysql/rss_db_name') }}.*:ALL" state: present - name: create rss_home 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 deleted file mode 100644 index b79dbaa..0000000 --- a/rss.jinwei.me/config/roles/rss/templates/docker-compose.yaml.j2 +++ /dev/null @@ -1,29 +0,0 @@ -version: "3" -services: - freshrss: - image: freshrss/freshrss:edge - container_name: freshrss - restart: always - logging: - options: - max-size: 10m - volumes: - # Recommended volume for FreshRSS persistent data such as configuration and SQLite databases - - {{ rss_home }}/data:/var/www/FreshRSS/data - # Optional volume for storing third-party extensions - - {{ rss_home }}/extensions:/var/www/FreshRSS/extensions - ports: - # If you want to open a port 8080 on the local machine: - - 30082:80 - environment: - # A timezone http://php.net/timezones (default is UTC) - TZ: America/Vancouver - - rssbot: - build: - context: . - dockerfile: ./Dockerfile.rssbot - container_name: ttrss_rssbot - restart: always - environment: - - TOKEN={{ lookup('aws_ssm', '/jinwei-me/tgbot/token') }} diff --git a/rss.jinwei.me/infra/rds.tf b/rss.jinwei.me/infra/rds.tf index ad719ea..d1a77a4 100644 --- a/rss.jinwei.me/infra/rds.tf +++ b/rss.jinwei.me/infra/rds.tf @@ -1,4 +1,4 @@ -resource "random_password" "ttrss_password" { +resource "random_password" "rss_password" { length = 16 special = false } diff --git a/rss.jinwei.me/infra/ssm.tf b/rss.jinwei.me/infra/ssm.tf index 62aaba7..59d0f36 100644 --- a/rss.jinwei.me/infra/ssm.tf +++ b/rss.jinwei.me/infra/ssm.tf @@ -1,34 +1,34 @@ -resource "aws_ssm_parameter" "ttrss_site_url" { - name = "/${var.name}/ttrss/url" +resource "aws_ssm_parameter" "rss_site_url" { + name = "/${var.name}/rss/url" type = "String" - value = var.ttrss_site_url + value = var.rss_site_url } -resource "aws_ssm_parameter" "ttrss_db_name" { - name = "/${var.name}/mysql/ttrss_db_name" +resource "aws_ssm_parameter" "rss_db_name" { + name = "/${var.name}/mysql/rss_db_name" type = "String" - value = var.ttrss_db_name + value = var.rss_db_name } -resource "aws_ssm_parameter" "ttrss_db_user" { - name = "/${var.name}/mysql/ttrss_db_user" +resource "aws_ssm_parameter" "rss_db_user" { + name = "/${var.name}/mysql/rss_db_user" type = "String" - value = var.ttrss_db_user + value = var.rss_db_user } -resource "aws_ssm_parameter" "ttrss_db_password" { - name = "/${var.name}/mysql/ttrss_db_password" +resource "aws_ssm_parameter" "rss_db_password" { + name = "/${var.name}/mysql/rss_user_password" type = "SecureString" - value = random_password.ttrss_password.result + value = random_password.rss_password.result } -resource "aws_ssm_parameter" "ttrss_tgbot_token" { +resource "aws_ssm_parameter" "rss_tgbot_token" { name = "/${var.name}/tgbot/token" type = "SecureString" value = var.rss_tgbot_token } -resource "aws_ssm_parameter" "ttrss_tgbot_version" { +resource "aws_ssm_parameter" "rss_tgbot_version" { name = "/${var.name}/tgbot/version" type = "String" value = var.tg_bot_version diff --git a/rss.jinwei.me/infra/variables.tf b/rss.jinwei.me/infra/variables.tf index 01b051b..667b41b 100644 --- a/rss.jinwei.me/infra/variables.tf +++ b/rss.jinwei.me/infra/variables.tf @@ -12,15 +12,15 @@ variable "region" { description = "AWS region" } -variable "ttrss_db_name" { - default = "ttrss" +variable "rss_db_name" { + default = "rss" } -variable "ttrss_db_user" { - default = "ttrss" +variable "rss_db_user" { + default = "rss" } -variable "ttrss_site_url" { +variable "rss_site_url" { default = "https://feed.jinwei.me" } -- cgit v1.2.3