diff options
author | clarkzjw <[email protected]> | 2022-12-12 00:03:53 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2022-12-12 01:01:06 -0800 |
commit | fe8cd972b5b72b8983c3f7fd6e7153c78ed278ea (patch) | |
tree | dbefb0b7dc8178ea1fb979303d73230f67b0f02e /rss.jinwei.me/config | |
parent | 02288734f6ca91c4a39df80435c0151f1a2dfa86 (diff) | |
download | jinwei.me-fe8cd972b5b72b8983c3f7fd6e7153c78ed278ea.tar.gz |
infra: add ttrss ssm resources
Diffstat (limited to 'rss.jinwei.me/config')
-rw-r--r-- | rss.jinwei.me/config/ansible.cfg | 14 | ||||
-rw-r--r-- | rss.jinwei.me/config/inventory/aws_ec2.yaml | 7 | ||||
-rw-r--r-- | rss.jinwei.me/config/requirements.yaml | 10 | ||||
-rw-r--r-- | rss.jinwei.me/config/role.yaml | 3 | ||||
-rw-r--r-- | rss.jinwei.me/config/roles/rss/defaults/main.yaml | 1 | ||||
-rw-r--r-- | rss.jinwei.me/config/roles/rss/tasks/main.yaml | 17 | ||||
-rw-r--r-- | rss.jinwei.me/config/roles/rss/templates/Dockerfile.rssbot.j2 | 12 | ||||
-rw-r--r-- | rss.jinwei.me/config/roles/rss/templates/docker-compose.yaml.j2 | 32 | ||||
-rw-r--r-- | rss.jinwei.me/config/site.yaml | 3 |
9 files changed, 99 insertions, 0 deletions
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 @@ | |||
1 | [defaults] | ||
2 | host_key_checking = False | ||
3 | transport = ssh | ||
4 | remote_user = admin | ||
5 | roles_path = roles | ||
6 | inventory = inventory | ||
7 | force_color = True | ||
8 | interpreter_python = auto_silent | ||
9 | |||
10 | [connection] | ||
11 | pipelining = True | ||
12 | |||
13 | [privilege_escalation] | ||
14 | 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 @@ | |||
1 | plugin: aws_ec2 | ||
2 | regions: | ||
3 | - us-west-2 | ||
4 | hostnames: | ||
5 | - tag:Name | ||
6 | compose: | ||
7 | 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 @@ | |||
1 | --- | ||
2 | collections: | ||
3 | - name: amazon.aws | ||
4 | version: 3.2.0 | ||
5 | - name: community.general | ||
6 | version: 4.7.0 | ||
7 | - name: ansible.posix | ||
8 | version: 1.3.0 | ||
9 | - name: community.docker | ||
10 | 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 @@ | |||
1 | - hosts: "{{ target }}" | ||
2 | roles: | ||
3 | - 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 @@ | |||
1 | - name: render Dockerfile.rssbot | ||
2 | template: | ||
3 | src: Dockerfile.rssbot.j2 | ||
4 | dest: "{{ rss_home }}/Dockerfile.rssbot" | ||
5 | mode: 0644 | ||
6 | |||
7 | - name: render docker-compose | ||
8 | template: | ||
9 | src: docker-compose.yaml.j2 | ||
10 | dest: "{{ rss_home }}/docker-compose.yaml" | ||
11 | mode: 0644 | ||
12 | |||
13 | - name: Start rss toolchain using docker-compose | ||
14 | community.docker.docker_compose: | ||
15 | project_name: rss | ||
16 | project_src: "{{ rss_home }}" | ||
17 | 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 @@ | |||
1 | FROM alpine:3.17 | ||
2 | |||
3 | ENV VERSION={{ lookup('aws_ssm', '/jinwei-me/tgbot/version') }} | ||
4 | ENV TOKEN "" | ||
5 | |||
6 | WORKDIR /app | ||
7 | |||
8 | ADD https://github.com/iovxw/rssbot/releases/download/${VERSION}/rssbot-en-x86_64-unknown-linux-musl /app/rssbot | ||
9 | |||
10 | RUN chmod +x /app/rssbot | ||
11 | |||
12 | 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 @@ | |||
1 | version: "3" | ||
2 | services: | ||
3 | ttrss: | ||
4 | image: wangqiru/ttrss:nightly-2022-08-09 | ||
5 | container_name: ttrss | ||
6 | environment: | ||
7 | - SELF_URL_PATH={{ lookup('aws_ssm', '/jinwei-me/ttrss/url') }} | ||
8 | - DB_HOST={{ lookup('aws_ssm', '/jinwei-me/mysql/host') }} | ||
9 | - DB_PORT={{ lookup('aws_ssm', '/jinwei-me/mysql/port') }} | ||
10 | - DB_NAME={{ lookup('aws_ssm', '/jinwei-me/mysql/ttrss_db_name') }} | ||
11 | - DB_USER={{ lookup('aws_ssm', '/jinwei-me/mysql/ttrss_db_user') }} | ||
12 | - DB_PASS={{ lookup('aws_ssm', '/jinwei-me/mysql/ttrss_db_password') }} | ||
13 | - PUID=1000 | ||
14 | - PGID=1000 | ||
15 | volumes: | ||
16 | - {{ rss_home }}/feed-icons:/var/www/feed-icons/ | ||
17 | stdin_open: true | ||
18 | tty: true | ||
19 | restart: always | ||
20 | |||
21 | mercury: | ||
22 | image: wangqiru/mercury-parser-api:latest | ||
23 | container_name: ttrss_mercury | ||
24 | restart: always | ||
25 | |||
26 | rssbot: | ||
27 | build: | ||
28 | dockerfile: ./Dockerfile.rssbot | ||
29 | container_name: ttrss_rssbot | ||
30 | restart: always | ||
31 | environment: | ||
32 | - 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 @@ | |||
1 | - hosts: jinwei-me | ||
2 | roles: | ||
3 | - role: rss | ||