nl2go.vpn_gateway

Travis (.org) 分支 Ansible Galaxy GitHub 标签(最新日期) Ansible Galaxy 下载量

Ansible 角色:VPN 网关

这是一个管理基于 IPsec / strongSwan 的两个对等方之间 VPN 隧道设置的 Ansible 角色,并提供与网关相关的路由配置。

角色变量

可用的变量如下所示,并附有默认值(参见 defaults/main.yml):

vpn_gateway_configs:
  - name: default
    psk: secret

配置集必须通过 vpn_gateway_configs 变量定义。配置集的 name 是必需的,用于身份识别。预共享密钥可以通过 psk 指定。

vpn_gateway_configs:
  - name: default
    state: absent

可以通过 state: absent 移除特定的网关配置。

vpn_gateway_configs:
  - name: default
    psk: secret
    params:
      lifetime: 8h

一般连接参数如 lifetime 可在 params 部分设置(有关完整参数描述,请参见 ipsec.conf)。

vpn_gateway_configs:
  - name: default
    psk: secret
    local:
      public: 1.1.1.1
      networks:
        - 172.4.0.0/21
    remote:
      public: 1.2.3.4
      networks:
        - 172.240.0.0/21
        - 10.2.0.0/16

配置集中包含 localremote 对等方的配置部分。

vpn_gateway_default_config_params:
  type: tunnel
  keyingtries: 0
  ikelifetime: 1h
  lifetime: 8h
  dpddelay: 300s
  dpdtimeout: 120
  dpdaction: clear
  authby: secret
  auto: start
  esp: aes256-sha256-modp3072
  ike: aes256-sha256-modp3072
  keyexchange: ikev2
  leftfirewall: 'yes'
  compress: 'no'
  rekey: 'no'
  fragmentation: 'yes'
  forceencaps: 'yes'

vpn_gateway_configs 中的 params 可扩展/覆盖上述默认连接参数。

vpn_gateway_config_dir: "/etc/ipsec.d/{{ role_name }}"

定义自定义 IPsec 配置目录以实现隔离目的。

标签

可以使用标签来限制角色执行于特定的任务模块。可用的标签如下:

  • vpn_gateway: 涵盖整个角色生命周期。
  • vpn_gateway_validate, validate: 验证给定的配置。
  • vpn_gateway_install, install: 安装所需的包。
  • vpn_gateway_config, config: 配置所需的包。

依赖

无。

示例剧本

- hosts: all
  roles:
     - nl2go.vpn_gateway

开发

使用 docker-molecule 按照说明运行 Molecule 或者在本地安装 Molecule(不推荐,可能会出现版本冲突)。

提供 Hetzner Cloud 令牌:

export HCLOUD_TOKEN=123abc456efg

使用以下命令运行测试:

molecule test --all

维护者

许可证

详情请参见 LICENSE.md 文件。

作者信息

该角色由 Newsletter2Go GmbH 于2020年创建。

关于项目

Manages a VPN tunnel setup between two peers based on IPsec/strongSwanand provides gateway related routing configuration.

安装
ansible-galaxy install nl2go.vpn_gateway
许可证
mit
下载
5.1k