Skip to content
  • A more complicated version, setting an array from multi-line standard out:

    - name: Register the loaded modules
      command: a2query -m
      register: apache_modules_check
    
    - name: Set an array of the loaded modules
      set_fact:
        apache_modules_loaded: "{{ apache_modules_loaded | default([]) + [ item.split(' ')[0] ] }}"
      loop: "{{ apache_modules_check.stdout_lines }}"
  • Another version not using a loop:

    - name: Get a list of enabled and disabled features
      command: icinga2 feature list
      register: icinga_feature_list
    
    - name: Set a fact for enabled features
      set_fact:
        icinga_feature_disabled: "{{ (icinga_feature_list.stdout_lines[0] | regex_replace('^Disabled features: ')).split(' ') | list }}"
        icinga_feature_enabled: "{{ (icinga_feature_list.stdout_lines[1] | regex_replace('^Enabled features: ')).split(' ') | list }}"
    Edited by Chris Croome
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment