opsxcq.linux_server
Linux 服务器角色
用于安装通用 Debian Linux 设置的角色:
- Docker
- 使用 Prometheus 进行监控(节点导出器 + cAdvisor)
- 内核参数
- 基本工具和软件包
- 从 GitHub 导入 SSH 密钥和 GPG 密钥
示例剧本
以下是一个示例剧本:
- hosts: all
  vars:
    hostname: "template"
    domain: "strm.sh"
    network:
      ip: "192.168.0.9"
      cidr: "/24"
      gateway: "192.168.0.1"
      dns:
      - "8.8.8.8"
      - "1.1.1.1"
      extra_ips:
      - "192.168.0.2"
      - "192.168.0.3"
      - "192.168.0.4"
      extra_raw: |-
        iface tun0 inet static
          address 10.0.0.8/24
    static_hosts: "{{ lookup('file', 'hosts') }}"
    loki:
      url: 'http://loki.strm.sh:3100/loki/api/v1/push'
    github_user: opsxcq
  tasks:
  - debug:
      msg: "在这里添加其他任务"
  roles:
    - ../..
可选变量:
- network.cidr:默认值为- /24。
- static_hosts:如果未定义,将不会更改- /etc/hosts文件。
- loki:定义后将配置系统和容器日志以发送到 Loki。
需求文件
- src: git+https://github.com/opsxcq/ansible-role-linux-server.git
  name: "opsxcq.linux_server"
Tmux 配置
此设置中添加了 Tmux,但有一个不同之处是使用 Ctrl+A,这样你就可以将本地的 Tmux 会话(使用 Ctrl+B)与远程的 Tmux 会话保持连接。
监控
除了 Prometheus 等监控工具,还有一些工具可以帮助你本地监控资源使用情况。
- htop
- iostat -x 1 - 显示实时 IO 数据
- slurm -i ens192 - 显示接口 ens192 的实时网络统计信息
