community.general.pam_limits 模块 – 修改 Linux PAM 限制
注意
此模块是 community.general 集合 (版本 10.1.0) 的一部分。
如果您使用的是 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用: ansible-galaxy collection install community.general。
要在剧本中使用它,请指定: community.general.pam_limits。
概要
- community.general.pam_limits 模块修改 PAM 限制。 
- 默认文件是 - /etc/security/limits.conf。
- 有关完整文档,请参见 - man 5 limits.conf。
参数
| 参数 | 注释 | 
|---|---|
| 创建一个包含时间戳信息的备份文件,以便您可以找回原始文件,以防您意外地错误地修改了它。 选项 
 | |
| 与限制关联的注释。 默认:  | |
| 修改 limits.conf 路径。 默认:  | |
| 用户名、@组名、通配符、UID/GID 范围。 | |
| 要设置的限制。 选项 
 | |
| 限制类型,请参见  选项 
 | |
| 如果设置为  如果指定的值高于文件中的值,则文件内容将被替换为新值,否则内容不会被修改。 选项 
 | |
| 如果设置为  如果指定的值低于文件中的值,则文件内容将被替换为新值,否则内容不会被修改。 选项 
 | |
| 限制的值。 值必须是  如果  有关更多详细信息,请参阅  | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持:完全支持 在 community.general 2.0.0 中添加 | 可以在  | |
| 支持:完全支持 在 community.general 2.0.0 中添加 | 在差异模式下,将返回有关已更改内容(或可能需要在  | 
备注
注意
- 如果 - dest文件不存在,则会创建它。
示例
- name: Add or modify nofile soft limit for the user joe
  community.general.pam_limits:
    domain: joe
    limit_type: soft
    limit_item: nofile
    value: 64000
- name: Add or modify fsize hard limit for the user smith. Keep or set the maximal value
  community.general.pam_limits:
    domain: smith
    limit_type: hard
    limit_item: fsize
    value: 1000000
    use_max: true
- name: Add or modify memlock, both soft and hard, limit for the user james with a comment
  community.general.pam_limits:
    domain: james
    limit_type: '-'
    limit_item: memlock
    value: unlimited
    comment: unlimited memory lock for james
- name: Add or modify hard nofile limits for wildcard domain
  community.general.pam_limits:
    domain: '*'
    limit_type: hard
    limit_item: nofile
    value: 39693561
