reallyenglish.cyrus-sasl
ansible-role-cyrus-sasl
安装 cyrus-sasl
、saslauthd
并配置 SASL 数据库中的用户。此角色仅支持本地 SASL 数据库和 saslauthd
。如果需要其他后端,这个角色不适合你。
sasl_check_pw
此角色安装一个 Python 脚本,用于检查用户密码,脚本位于所有平台的 /usr/local/bin
下。由于无法直接比较角色变量中定义的密码与数据库中的密码,脚本会读取 cyrus_sasl_sasldb_file
并查找用户及其密码。脚本假设 cyrus_sasl_sasldb_file
为 dbm
格式。
sasl_check_pw path user domain
其中 path
是 cyrus_sasl_sasldb_file
的路径,user
是 cyrus_sasl_sasldb_file
中的用户名,domain
是用户所属的域名。将待检查的密码设置为环境变量 userPassword
。当密码与 cyrus_sasl_sasldb_file
中的密码匹配时,脚本会在标准输出中打印 matched
;不匹配时,会打印 does not match
。该脚本必须由具有读取 cyrus_sasl_sasldb_file
权限的用户执行。
需求
无
角色变量
变量 | 描述 | 默认值 |
---|---|---|
cyrus_sasl_package |
cyrus-sasl 的包名称 |
{{ __cyrus_sasl_package }} |
cyrus_sasl_saslauthd_service |
saslauthd 的服务名称 |
{{ __cyrus_sasl_saslauthd_service }} |
cyrus_sasl_saslauthd_enable |
是否启用 saslauthd |
yes |
cyrus_sasl_saslauthd_flags |
服务变量及其值的字典(见下文) | {} |
cyrus_sasl_saslauthd_flags_default |
服务变量及其值的默认值 | {{ __cyrus_sasl_saslauthd_flags_default }} |
cyrus_sasl_plugin_dir |
应用程序配置所在的插件目录 | {{ __cyrus_sasl_plugin_dir }} |
cyrus_sasl_saslpassword_command |
管理用户密码的命令 | {{ __cyrus_sasl_saslpassword_command }} |
cyrus_sasl_sasldblistusers_command |
列出数据库中的用户命令 | {{ __cyrus_sasl_sasldblistusers_command }} |
cyrus_sasl_sasldb_file |
SASL 数据库文件的路径 | {{ __cyrus_sasl_sasldb_file }} |
cyrus_sasl_sasldb_owner |
SASL 数据库文件的拥有者 | root |
cyrus_sasl_sasldb_group |
SASL 数据库文件的组 | {{ __cyrus_sasl_sasldb_group }} |
cyrus_sasl_sasldb_file_permission |
SASL 数据库文件的权限 | {{ __cyrus_sasl_sasldb_file_permission }} |
cyrus_sasl_config |
应用程序配置的字典(见下文) | {} |
cyrus_sasl_user |
SASL 数据库文件中的用户字典(见下文) | {} |
cyrus_sasl_saslauthd_flags
此变量是启动配置文件的变量字典,如 /etc/default
、/etc/sysconfig
和 /etc/rc.conf.d
下的文件。假设这些文件是由启动机制以 sh(1)
源方式加载。字典中的键是文件中变量的名称,值则是该变量的值。该变量与名称相同但后缀为 _default
的变量相结合,生成启动配置文件,通常为每个平台特定目录下的 key="value"
格式的文件。
当平台为 OpenBSD 时,上述说明不适用。在该情况下,唯一有效的键是 flags
,其值传递给 rc.conf(5)
中描述的 daemon_flags
,其中 daemon
是 rc.d(8)
守护进程控制脚本之一的名称。
cyrus_sasl_saslauthd_flags_default
此变量是源自上游默认配置的键值字典,除非绝对必要,否则应视为常量。默认情况下,角色为每个平台创建一个与此变量相同的启动配置文件。
当平台为 OpenBSD 时,变量只有一个键 flags
,其值为空字符串。
cyrus_sasl_config
键是应用程序名称,值是一个字典,其中键是变量名称,值是其值。示例:
cyrus_sasl_config:
myapp:
pwcheck_method: saslauthd
cyrus_sasl_user
键是用户名,其值是一个字典。
键 | 值 |
---|---|
domain |
用户的域 |
password |
用户的密码 |
appname |
用户的 appname |
state |
present 或 absent 。如果为 present ,角色会创建该用户;如果为 absent ,则会删除该用户 |
cyrus_sasl_user:
foo:
domain: reallyenglish.com
password: password
appname: argus
state: present
Debian
变量 | 默认值 |
---|---|
__cyrus_sasl_package |
libsasl2-2 |
__cyrus_sasl_saslauthd_service |
saslauthd |
__cyrus_sasl_saslauthd_flags_default |
{"MECHANISMS"=>"pam", "MECH_OPTIONS"=>"", "THREADS"=>5, "OPTIONS"=>"-c -m /var/run/saslauthd"} |
__cyrus_sasl_plugin_dir |
/usr/lib/sasl2 |
__cyrus_sasl_saslpassword_command |
saslpasswd2 |
__cyrus_sasl_sasldblistusers_command |
sasldblistusers2 |
__cyrus_sasl_sasldb_file |
/etc/sasldb2 |
__cyrus_sasl_sasldb_file_permission |
0660 |
__cyrus_sasl_sasldb_group |
root |
FreeBSD
变量 | 默认值 |
---|---|
__cyrus_sasl_package |
cyrus-sasl |
__cyrus_sasl_saslauthd_service |
saslauthd |
__cyrus_sasl_saslauthd_flags_default |
{} |
__cyrus_sasl_plugin_dir |
/usr/local/lib/sasl2 |
__cyrus_sasl_saslpassword_command |
saslpasswd2 |
__cyrus_sasl_sasldblistusers_command |
sasldblistusers2 |
__cyrus_sasl_sasldb_file |
/usr/local/etc/sasldb2 |
__cyrus_sasl_sasldb_file_permission |
600 |
__cyrus_sasl_sasldb_group |
wheel |
OpenBSD
变量 | 默认值 |
---|---|
__cyrus_sasl_package |
cyrus-sasl-- |
__cyrus_sasl_saslauthd_service |
saslauthd |
__cyrus_sasl_saslauthd_flags_default |
{"flags"=>"-a getpwent"} |
__cyrus_sasl_plugin_dir |
/usr/local/lib/sasl2 |
__cyrus_sasl_saslpassword_command |
saslpasswd2 |
__cyrus_sasl_sasldblistusers_command |
sasldblistusers2 |
__cyrus_sasl_sasldb_file |
/etc/sasldb2 |
__cyrus_sasl_sasldb_file_permission |
600 |
__cyrus_sasl_sasldb_group |
wheel |
RedHat
变量 | 默认值 |
---|---|
__cyrus_sasl_package |
cyrus-sasl |
__cyrus_sasl_saslauthd_service |
saslauthd |
__cyrus_sasl_saslauthd_flags_default |
{"SOCKETDIR"=>"/run/saslauthd", "MECH"=>"pam", "FLAGS"=>""} |
__cyrus_sasl_plugin_dir |
/usr/lib64/sasl2 |
__cyrus_sasl_saslpassword_command |
saslpasswd2 |
__cyrus_sasl_sasldblistusers_command |
sasldblistusers2 |
__cyrus_sasl_sasldb_file |
/etc/sasldb2 |
__cyrus_sasl_sasldb_file_permission |
0640 |
__cyrus_sasl_sasldb_group |
root |
依赖
无
示例剧本
- hosts: localhost
roles:
- ansible-role-cyrus-sasl
vars:
cyrus_sasl_user:
foo:
domain: reallyenglish.com
password: password
appname: argus
state: present
cyrus_sasl_config:
myapp:
pwcheck_method: saslauthd
argus:
pwcheck_method: auxprop
auxprop_plugin: sasldb
mech_list: DIGEST-MD5
cyrus_sasl_sasldb_group: "{% if ansible_os_family == 'Debian' %}nogroup{% else %}nobody{% endif %}"
cyrus_sasl_sasldb_file_permission: "0640"
extra_variables_debian:
THREADS: 6
extra_variables_redhat:
FLAGS: -n 6
extra_variables_freebsd:
saslauthd_flags: -a pam -n 6
extra_variables_openbsd:
flags: -a getpwent -n 6
cyrus_sasl_saslauthd_flags: "{% if ansible_os_family == 'Debian' %}{{ extra_variables_debian }}{% elif ansible_os_family == 'RedHat' %}{{ extra_variables_redhat }}{% elif ansible_os_family == 'FreeBSD' %}{{ extra_variables_freebsd }}{% elif ansible_os_family == 'OpenBSD' %}{{ extra_variables_openbsd }}{% endif %}"
许可证
版权 (c) 2017 Tomoyuki Sakurai <tomoyukis@reallyenglish.com>
特此授予使用、复制、修改和分发本软件的许可,目的不限于任何用途,无论是否收费,前提是上述版权声明和本许可声明出现在所有副本中。
本软件是按“现状”提供,作者对本软件不承担任何担保责任,包括所有关于适销性和适用性的隐含担保。在任何情况下,作者不对因使用本软件或其表现而导致的任何特别、直接、间接或后果性损害或任何损害负责,包括使用、数据或利润的损失,无论是在合同诉讼、过失或其他侵权行为中发生。
作者信息
Tomoyuki Sakurai tomoyukis@reallyenglish.com
此 README 是由 qansible 创建的