community.general.pamd 模块 – 管理 PAM 模块
注意
此模块是 community.general 集合 (版本 10.1.0) 的一部分。
如果您使用的是 ansible 软件包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用: ansible-galaxy collection install community.general。
要在 playbook 中使用它,请指定: community.general.pamd。
概要
- 编辑 PAM 服务的类型、控制、模块路径和模块参数。 
- 为了修改 PAM 规则,类型、控制和 module_path 必须与现有规则匹配。有关详细信息,请参阅 man(5) pam.d。 
参数
| 参数 | 注释 | 
|---|---|
| 创建一个包含时间戳信息的备份文件,以便如果意外错误地覆盖了文件,您可以恢复原始文件。 选项 
 | |
| 要修改的 PAM 规则的控制。 这可能是一个带有括号的复杂控制。如果是这种情况,请确保将“[括号控制]”放在引号中。 
 | |
| 当  当  当  此外,如果模块参数取一个由  | |
| 要修改的 PAM 规则的模块路径。 
 | |
| 名称通常指的是要更改的 PAM 服务文件,例如 system-auth。 | |
| 要分配给新规则的新控制。 | |
| 要分配给新规则的新模块路径。 | |
| 要分配给新规则的新类型。 选项 
 | |
| 这是 PAM 服务文件的路径。 默认值:  | |
| 
 使用  类似地,使用  使用  如果 state 为  状态  选项 
 | |
| 要修改的 PAM 规则的类型。 
 选项 
 | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持:完全支持 | 可以在 | |
| 支持:不支持 | 在diff模式下,将返回关于已更改内容(或在 | 
备注
注意
- 此模块不处理authselect配置文件。 
示例
- name: Update pamd rule's control in /etc/pam.d/system-auth
  community.general.pamd:
    name: system-auth
    type: auth
    control: required
    module_path: pam_faillock.so
    new_control: sufficient
- name: Update pamd rule's complex control in /etc/pam.d/system-auth
  community.general.pamd:
    name: system-auth
    type: session
    control: '[success=1 default=ignore]'
    module_path: pam_succeed_if.so
    new_control: '[success=2 default=ignore]'
- name: Insert a new rule before an existing rule
  community.general.pamd:
    name: system-auth
    type: auth
    control: required
    module_path: pam_faillock.so
    new_type: auth
    new_control: sufficient
    new_module_path: pam_faillock.so
    state: before
- name: Insert a new rule pam_wheel.so with argument 'use_uid' after an \
        existing rule pam_rootok.so
  community.general.pamd:
    name: su
    type: auth
    control: sufficient
    module_path: pam_rootok.so
    new_type: auth
    new_control: required
    new_module_path: pam_wheel.so
    module_arguments: 'use_uid'
    state: after
- name: Remove module arguments from an existing rule
  community.general.pamd:
    name: system-auth
    type: auth
    control: required
    module_path: pam_faillock.so
    module_arguments: ''
    state: updated
- name: Replace all module arguments in an existing rule
  community.general.pamd:
    name: system-auth
    type: auth
    control: required
    module_path: pam_faillock.so
    module_arguments: 'preauth
        silent
        deny=3
        unlock_time=604800
        fail_interval=900'
    state: updated
- name: Remove specific arguments from a rule
  community.general.pamd:
    name: system-auth
    type: session
    control: '[success=1 default=ignore]'
    module_path: pam_succeed_if.so
    module_arguments: crond,quiet
    state: args_absent
- name: Ensure specific arguments are present in a rule
  community.general.pamd:
    name: system-auth
    type: session
    control: '[success=1 default=ignore]'
    module_path: pam_succeed_if.so
    module_arguments: crond,quiet
    state: args_present
- name: Ensure specific arguments are present in a rule (alternative)
  community.general.pamd:
    name: system-auth
    type: session
    control: '[success=1 default=ignore]'
    module_path: pam_succeed_if.so
    module_arguments:
    - crond
    - quiet
    state: args_present
- name: Module arguments requiring commas must be listed as a Yaml list
  community.general.pamd:
    name: special-module
    type: account
    control: required
    module_path: pam_access.so
    module_arguments:
    - listsep=,
    state: args_present
- name: Update specific argument value in a rule
  community.general.pamd:
    name: system-auth
    type: auth
    control: required
    module_path: pam_faillock.so
    module_arguments: 'fail_interval=300'
    state: args_present
- name: Add pam common-auth rule for duo
  community.general.pamd:
    name: common-auth
    new_type: auth
    new_control: '[success=1 default=ignore]'
    new_module_path: '/lib64/security/pam_duo.so'
    state: after
    type: auth
    module_path: pam_sss.so
    control: 'requisite'
返回值
常见返回值已在此处记录,以下是此模块独有的字段
| 键 | 描述 | 
|---|---|
| 如果创建了备份文件,则为备份文件的名称。 返回:成功 | |
| 更改了多少条规则。 返回:成功 示例: | 
