Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-7-sonnet-20250219-thinking-32k· AnthropicHugging Face LMArena Human Preference 140K

Could you give a full list of modules, which don't handle check mode explicitly?

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Metallama-4-maverick-17b-128e-instruct’s answer.
  1. User

    Could you give a full list of modules, which don't handle check mode explicitly?

  2. Claude Assistant

    Ansible Modules That Don't Handle Check Mode Well

    Ansible modules fall into different categories regarding check mode support. Here's a comprehensive list of modules that either don't support check mode or have limited support:

    Command Execution Modules

    These modules can't predict their outcome without actually running:

    • ansible.builtin.command
    • ansible.builtin.shell
    • ansible.builtin.raw
    • ansible.builtin.script
    • ansible.builtin.expect

    API and Service Interaction

    • uri - Cannot predict API responses
    • Many cloud provider modules (portions of AWS, Azure, GCP modules)
    • docker_container (when creating containers)
    • k8s modules (many operations)

    Database Modules

    • mysql_query/postgresql_query - Can't predict query outcomes
    • mongodb_* modules - Many operations
    • elasticsearch_* modules

    Network Modules

    • Many *_command network modules
    • Certain operations in ios_*, junos_*, eos_* modules

    System Modules

    • reboot
    • package_facts
    • setup (gathers facts regardless of check mode)
    • service_facts

    File Operations (Special Cases)

    • fetch - Reads but doesn't modify remote systems
    • find - Only gathers information
    • stat - Only reports file information

    Other Notable Modules

    • pause/wait_for - Time-based operations
    • assert - Tests conditions but doesn't change state
    • fail - Task failure testing
    • include_*/import_* - Dynamic inclusions
    • set_fact/set_stats - Variable manipulation
    • debug - Information display only

    Custom/Third-Party Modules

    • Many custom or third-party modules may not implement check mode properly

    How to Handle These Modules

    When using these modules in playbooks that may run in check mode:

    - name: Run a command that can't be checked
      ansible.builtin.command: "critical_operation.sh"
      check_mode: no  # Will run even in check mode
      # OR
      when: not ansible_check_mode  # Will skip in check mode
    

    You can also add check mode support for command/shell modules with changed_when:

    - name: Check if service needs restart
      ansible.builtin.command: "systemctl status myservice"
      register: service_status
      changed_when: "'active (running)' not in service_status.stdout"
      check_mode: no  # Only gather info
    

    Note that Ansible continues to improve check mode support with each release, so this list may change over time.

  3. User

    Why do check mode fail with following Ansible tasks?

    • name: Create logical volume on system disk for K3s data community.general.lvol: vg: "{{ ansible_distribution|lower + '-vg' | default('ubuntu-vg') }}" lv: "k3s-data-lv" size: "{{ k3s.storage.data_size }}" force: false # never shrink (or remove)
      • name: Format logical volume on system disk for K3s data community.general.filesystem: fstype: ext4 dev: "/dev/{{ ansible_distribution|lower + '-vg' | default('ubuntu-vg') }}/k3s-data-lv"
      • name: Create mountpoint of logical volume for K3s data ansible.builtin.file: path: "/k3s-data" state: directory mode: "0755"
      • name: Mount logical volume for K3s data ansible.posix.mount: path: "/k3s-data" src: "/dev/{{ ansible_distribution|lower + '-vg' | default('ubuntu-vg') }}/k3s-data-lv" fstype: ext4 state: mounted
  4. Claude Assistant

    Why These Tasks Fail in Check Mode

    Your tasks are failing in check mode because they form a dependency chain where each task depends on the previous one actually creating resources. When running in check mode, those resources aren't created, causing subsequent tasks to fail.

    The Specific Issues

    1. community.general.lvol (Create logical volume):

      • In check mode, this verifies if creation is needed but doesn't actually create the logical volume
      • The module tries to determine if changes are needed, but the device path doesn't exist yet
    2. community.general.filesystem (Format LV):

      • Fails because it's trying to check a device that doesn't exist in check mode
      • The previous task didn't actually create the logical volume
    3. ansible.posix.mount (Mount):

      • Fails when validating the device path which wasn't created during check mode

    How to Fix This

    The solution is to add appropriate handling for check mode. Here's how to fix your playbook:

    - name: Create logical volume on system disk for K3s data
      community.general.lvol:
        vg: "{{ ansible_distribution|lower + '-vg' | default('ubuntu-vg') }}"
        lv: "k3s-data-lv"
        size: "{{ k3s.storage.data_size }}"
        force: false
      register: lv_created
    
    - name: Format logical volume on system disk for K3s data
      community.general.filesystem:
        fstype: ext4
        dev: "/dev/{{ ansible_distribution|lower + '-vg' | default('ubuntu-vg') }}/k3s-data-lv"
      when: not ansible_check_mode or lv_created is not changed
    
    - name: Create mountpoint of logical volume for K3s data
      ansible.builtin.file:
        path: "/k3s-data"
        state: directory
        mode: "0755"
      # This should work fine in check mode
    
    - name: Mount logical volume for K3s data
      ansible.posix.mount:
        path: "/k3s-data"
        src: "/dev/{{ ansible_distribution|lower + '-vg' | default('ubuntu-vg') }}/k3s-data-lv"
        fstype: ext4
        state: mounted
      when: not ansible_check_mode or lv_created is not changed
    

    Alternative Approach

    If you need to validate more thoroughly during check mode, consider:

    - name: Check if LV exists
      command: lvs "{{ ansible_distribution|lower + '-vg' | default('ubuntu-vg') }}/k3s-data-lv"
      register: lv_check
      failed_when: false
      changed_when: false
      check_mode: no  # Always run this check
    
    - name: Create logical volume on system disk for K3s data
      community.general.lvol:
        vg: "{{ ansible_distribution|lower + '-vg' | default('ubuntu-vg') }}"
        lv: "k3s-data-lv"
        size: "{{ k3s.storage.data_size }}"
        force: false
      register: lv_created
    
    # Continue with subsequent tasks with proper when conditions
    

    This approach lets you accurately determine the starting state even in check mode.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.