community.general.modprobe (8.5.0) — module

Load or unload kernel modules

Authors: David Stygstra (@stygstra), Julien Dauphant (@jdauphant), Matt Jeffery (@mattjeffery)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Load or unload kernel modules.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add the 802.1q module
  community.general.modprobe:
    name: 8021q
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add the dummy module
  community.general.modprobe:
    name: dummy
    state: present
    params: 'numdummies=2'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add the dummy module and make sure it is loaded after reboots
  community.general.modprobe:
    name: dummy
    state: present
    params: 'numdummies=2'
    persistent: present

Inputs

    
name:
    description:
    - Name of kernel module to manage.
    required: true
    type: str

state:
    choices:
    - absent
    - present
    default: present
    description:
    - Whether the module should be present or absent.
    type: str

params:
    default: ''
    description:
    - Modules parameters.
    type: str

persistent:
    choices:
    - disabled
    - absent
    - present
    default: disabled
    description:
    - Persistency between reboots for configured module.
    - This option creates files in C(/etc/modules-load.d/) and C(/etc/modprobe.d/) that
      make your module configuration persistent during reboots.
    - If V(present), adds module name to C(/etc/modules-load.d/) and params to C(/etc/modprobe.d/)
      so the module will be loaded on next reboot.
    - If V(absent), will comment out module name from C(/etc/modules-load.d/) and comment
      out params from C(/etc/modprobe.d/) so the module will not be loaded on next reboot.
    - If V(disabled), will not touch anything and leave C(/etc/modules-load.d/) and C(/etc/modprobe.d/)
      as it is.
    - Note that it is usually a better idea to rely on the automatic module loading by
      PCI IDs, USB IDs, DMI IDs or similar triggers encoded in the kernel modules themselves
      instead of configuration like this.
    - In fact, most modern kernel modules are prepared for automatic loading already.
    - B(Note:) This option works only with distributions that use C(systemd) when set
      to values other than V(disabled).
    type: str