Files
awoooi/infra/ansible/roles/swap/tasks/main.yml
OG T 0139aa79e7 feat(infra): B-1 Ansible Host IaC 骨架完整版
- roles/nginx/templates/188-all-sites.conf.j2: 8 個服務 Jinja2 模板
- roles/docker-compose-service/tasks/main.yml: 通用 Docker Compose role
- roles/swap/tasks/main.yml: swap2.img 管理 role (110 專用)
- roles/pm2-service/tasks/main.yml: PM2 process 狀態確認 role
- .gitea/workflows/ansible-lint.yml: infra/ansible/** 異動自動 lint

Sprint B-1 完成: Git = 唯一真相 (Host IaC 骨架)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-11 02:47:10 +08:00

36 lines
875 B
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
# swap role — 確保 swap 已設定110 專用)
# 預期狀態: swap.img (3.8G) + swap2.img (4G) 共 ~8G
- name: "Swap | 確認 swap2.img 存在"
ansible.builtin.stat:
path: /swap2.img
register: swap2_stat
- name: "Swap | 建立 swap2.img"
ansible.builtin.command:
cmd: "fallocate -l 4G /swap2.img"
creates: /swap2.img
when: not swap2_stat.stat.exists
- name: "Swap | 格式化 swap2.img"
ansible.builtin.command:
cmd: "mkswap /swap2.img"
when: not swap2_stat.stat.exists
- name: "Swap | 設定 swap2.img 權限"
ansible.builtin.file:
path: /swap2.img
mode: "0600"
- name: "Swap | 加入 swap2.img 到 fstab"
ansible.builtin.lineinfile:
path: /etc/fstab
line: "/swap2.img none swap sw 0 0"
state: present
- name: "Swap | 啟用 swap"
ansible.builtin.command:
cmd: "swapon --all"
changed_when: false