hybridadmin.strongswan
StrongSwan 角色
经过测试的操作系统:
- Ubuntu 18.04 和 20.04
- CentOS 7 和 8
- Debian 9 和 10
此角色使用 swanctl.conf 风格的语法(自 5.7.0 起引用部分)。
变量
一般
strongswan_swanctl_settings
:[必需]:设置所有 swanctl.conf 的配置
StrongSwan(服务器|客户端)设置:
strongswan_swanctl_config_dir
:[可选,默认值:/etc/strongswan/swanctl
]:包含 StrongSwan swanctl.conf 的目录strongswan_swanctl_config_file
:[可选,默认值:{{ strongswan_swanctl_config_dir }}/swanctl.conf
]:StrongSwan swanctl 配置文件的名称strongswan_letsencrypt_enable
:[可选,默认值:true
]:使用 Let's Encrypt 准备 StrongSwan 服务器证书strongswan_firewalld_enable
:[可选,默认值:true
]:为 StrongSwan 服务器设置所有必要的防火墙规则strongswan_client
:[可选,默认值:false
]:在客户端安装和配置 StrongSwanstrongswan_download_cert
:[可选,默认值:false
]:从服务器主机下载 StrongSwan 证书。应与strongswan_letsencrypt_enable
=true
一起使用strongswan_upload_cert
:[可选,默认值:false
]:将 StrongSwan 证书上传到客户端。应与strongswan_letsencrypt_enable
=true
一起使用
依赖项
- geerlingguy.certbot
变量
StrongSwan 服务器的主机变量:
# 仅在首次生成证书时启用以下变量
certbot_create_if_missing: yes
certbot_certs:
- email: [email protected]
domains:
- "{{ inventory_hostname }}"
certbot_create_standalone_stop_services: []
# 设置 StrongSwan swanctl 配置
# https://wiki.strongswan.org/projects/strongswan/wiki/UsableExamples
strongswan_swanctl_settings:
connections:
ikev2-eap:
version: 2
rekey_time: 0s
fragmentation: yes
proposals: aes192gcm16-aes128gcm16-prfsha256-ecp256-ecp521,aes192-sha256-modp3072,default
encap: yes
pools: primary-pool-ipv4
dpd_delay: 30s
local-1:
certs: cert.pem
id: myid
remote-1:
auth: eap-dynamic
eap_id: "%any"
children:
ikev2-eap:
local_ts: 0.0.0.0/0,::/0
rekey_time: 0s
dpd_action: clear
esp_proposals = aes192gcm16-aes128gcm16-prfsha256-ecp256-modp3072,aes192-sha256-ecp256-modp3072,default
pools:
primary-pool-ipv4:
addrs: 192.168.252.0/24
secrets:
eap-user:
id: user
secret: Ar3e73tTnp02
carol.strongswan.org 的主机变量:
strongswan_swanctl_settings:
connections:
home:
encap: yes
vips: 0.0.0.0
remote_addrs: moon.strongswan.org
version: 2
children:
home:
remote_ts: 0.0.0.0/0,::/0
start_action: none
local:
auth: eap-aka
eap_id: carol
remote:
auth: pubkey
id: moon.strongswan.org
secrets:
eap-carol:
id: carol
secret: Ar3etTnp
Playbook 示例
使用 PKI 证书的 StrongSwan 服务器 playbook:
- hosts: server
vars:
strongswan_letsencrypt_enable: false
roles:
- hybridadmin.strongswan
使用 Letsencrypt 证书的 StrongSwan 服务器 playbook:
- hosts: server
vars:
strongswan_letsencrypt_enable: true
certbot_certs:
- email: [email protected]
domains:
- vpn.example.com
roles:
- hybridadmin.strongswan
StrongSwan 客户端 playbook:
- hosts:
- server
roles:
- hybridadmin.strongswan
vars:
strongswan_client: true
strongswan_download_cert: true
- hosts:
- clients
roles:
- hybridadmin.strongswan
vars:
strongswan_upload_cert: true
待办事项
- 删除一些依赖角色以实现更大的灵活性。
许可证
BSD 2条款“简化”许可证
作者信息
hybridadmin
关于项目
Role to configure a strongSwan IPSec VPN server.
安装
ansible-galaxy install hybridadmin.strongswan
许可证
Unknown
下载
348
拥有者
Windows/Linux enthusiast and lover of all things automation #devops #ansible #docker #powershell