From fe8cd972b5b72b8983c3f7fd6e7153c78ed278ea Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Mon, 12 Dec 2022 00:03:53 -0800 Subject: infra: add ttrss ssm resources --- rss.jinwei.me/config/ansible.cfg | 14 ++++++++++ rss.jinwei.me/config/inventory/aws_ec2.yaml | 7 +++++ rss.jinwei.me/config/requirements.yaml | 10 +++++++ rss.jinwei.me/config/role.yaml | 3 ++ rss.jinwei.me/config/roles/rss/defaults/main.yaml | 1 + rss.jinwei.me/config/roles/rss/tasks/main.yaml | 17 ++++++++++++ .../roles/rss/templates/Dockerfile.rssbot.j2 | 12 ++++++++ .../roles/rss/templates/docker-compose.yaml.j2 | 32 ++++++++++++++++++++++ rss.jinwei.me/config/site.yaml | 3 ++ 9 files changed, 99 insertions(+) create mode 100644 rss.jinwei.me/config/ansible.cfg create mode 100644 rss.jinwei.me/config/inventory/aws_ec2.yaml create mode 100644 rss.jinwei.me/config/requirements.yaml create mode 100644 rss.jinwei.me/config/role.yaml create mode 100644 rss.jinwei.me/config/roles/rss/defaults/main.yaml create mode 100644 rss.jinwei.me/config/roles/rss/tasks/main.yaml create mode 100644 rss.jinwei.me/config/roles/rss/templates/Dockerfile.rssbot.j2 create mode 100644 rss.jinwei.me/config/roles/rss/templates/docker-compose.yaml.j2 create mode 100644 rss.jinwei.me/config/site.yaml (limited to 'rss.jinwei.me/config') diff --git a/rss.jinwei.me/config/ansible.cfg b/rss.jinwei.me/config/ansible.cfg new file mode 100644 index 0000000..9345045 --- /dev/null +++ b/rss.jinwei.me/config/ansible.cfg @@ -0,0 +1,14 @@ +[defaults] +host_key_checking = False +transport = ssh +remote_user = admin +roles_path = roles +inventory = inventory +force_color = True +interpreter_python = auto_silent + +[connection] +pipelining = True + +[privilege_escalation] +become = True diff --git a/rss.jinwei.me/config/inventory/aws_ec2.yaml b/rss.jinwei.me/config/inventory/aws_ec2.yaml new file mode 100644 index 0000000..100d95b --- /dev/null +++ b/rss.jinwei.me/config/inventory/aws_ec2.yaml @@ -0,0 +1,7 @@ +plugin: aws_ec2 +regions: + - us-west-2 +hostnames: + - tag:Name +compose: + ansible_host: public_ip_address diff --git a/rss.jinwei.me/config/requirements.yaml b/rss.jinwei.me/config/requirements.yaml new file mode 100644 index 0000000..5229cc7 --- /dev/null +++ b/rss.jinwei.me/config/requirements.yaml @@ -0,0 +1,10 @@ +--- +collections: + - name: amazon.aws + version: 3.2.0 + - name: community.general + version: 4.7.0 + - name: ansible.posix + version: 1.3.0 + - name: community.docker + version: 3.2.1 diff --git a/rss.jinwei.me/config/role.yaml b/rss.jinwei.me/config/role.yaml new file mode 100644 index 0000000..ab3fca5 --- /dev/null +++ b/rss.jinwei.me/config/role.yaml @@ -0,0 +1,3 @@ +- hosts: "{{ target }}" + roles: + - role: "{{ role }}" diff --git a/rss.jinwei.me/config/roles/rss/defaults/main.yaml b/rss.jinwei.me/config/roles/rss/defaults/main.yaml new file mode 100644 index 0000000..28f1f39 --- /dev/null +++ b/rss.jinwei.me/config/roles/rss/defaults/main.yaml @@ -0,0 +1 @@ +rss_home: /opt/rss diff --git a/rss.jinwei.me/config/roles/rss/tasks/main.yaml b/rss.jinwei.me/config/roles/rss/tasks/main.yaml new file mode 100644 index 0000000..16091cb --- /dev/null +++ b/rss.jinwei.me/config/roles/rss/tasks/main.yaml @@ -0,0 +1,17 @@ +- name: render Dockerfile.rssbot + template: + src: Dockerfile.rssbot.j2 + dest: "{{ rss_home }}/Dockerfile.rssbot" + mode: 0644 + +- name: render docker-compose + template: + src: docker-compose.yaml.j2 + dest: "{{ rss_home }}/docker-compose.yaml" + mode: 0644 + +- name: Start rss toolchain using docker-compose + community.docker.docker_compose: + project_name: rss + project_src: "{{ rss_home }}" + register: output diff --git a/rss.jinwei.me/config/roles/rss/templates/Dockerfile.rssbot.j2 b/rss.jinwei.me/config/roles/rss/templates/Dockerfile.rssbot.j2 new file mode 100644 index 0000000..f7eab63 --- /dev/null +++ b/rss.jinwei.me/config/roles/rss/templates/Dockerfile.rssbot.j2 @@ -0,0 +1,12 @@ +FROM alpine:3.17 + +ENV VERSION={{ lookup('aws_ssm', '/jinwei-me/tgbot/version') }} +ENV TOKEN "" + +WORKDIR /app + +ADD https://github.com/iovxw/rssbot/releases/download/${VERSION}/rssbot-en-x86_64-unknown-linux-musl /app/rssbot + +RUN chmod +x /app/rssbot + +CMD ["sh", "-c", "./rssbot ${TOKEN}"] 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 new file mode 100644 index 0000000..fd556dc --- /dev/null +++ b/rss.jinwei.me/config/roles/rss/templates/docker-compose.yaml.j2 @@ -0,0 +1,32 @@ +version: "3" +services: + ttrss: + image: wangqiru/ttrss:nightly-2022-08-09 + container_name: ttrss + environment: + - SELF_URL_PATH={{ lookup('aws_ssm', '/jinwei-me/ttrss/url') }} + - DB_HOST={{ lookup('aws_ssm', '/jinwei-me/mysql/host') }} + - DB_PORT={{ lookup('aws_ssm', '/jinwei-me/mysql/port') }} + - DB_NAME={{ lookup('aws_ssm', '/jinwei-me/mysql/ttrss_db_name') }} + - DB_USER={{ lookup('aws_ssm', '/jinwei-me/mysql/ttrss_db_user') }} + - DB_PASS={{ lookup('aws_ssm', '/jinwei-me/mysql/ttrss_db_password') }} + - PUID=1000 + - PGID=1000 + volumes: + - {{ rss_home }}/feed-icons:/var/www/feed-icons/ + stdin_open: true + tty: true + restart: always + + mercury: + image: wangqiru/mercury-parser-api:latest + container_name: ttrss_mercury + restart: always + + rssbot: + build: + dockerfile: ./Dockerfile.rssbot + container_name: ttrss_rssbot + restart: always + environment: + - TOKEN={{ lookup('aws_ssm', '/jinwei-me/tgbot/token') }} diff --git a/rss.jinwei.me/config/site.yaml b/rss.jinwei.me/config/site.yaml new file mode 100644 index 0000000..56e2355 --- /dev/null +++ b/rss.jinwei.me/config/site.yaml @@ -0,0 +1,3 @@ +- hosts: jinwei-me + roles: + - role: rss -- cgit v1.2.3