Execution
Date 28 Jul 2025 11:39:20 +0100
Duration 00:00:16.28
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.11
ara 1.7.2 / 1.7.2
Python 3.10.10
Summary
24 Hosts
6 Tasks
129 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/check_mig_json.yaml

---
- name: Check migration_timeout_minutes and skip null values
  hosts: all-prod
  gather_facts: false
  vars:
    config_file: "/etc/solus/agent.json"

  tasks:
    - name: Check if config file exists
      ansible.builtin.stat:
        path: "{{ config_file }}"
      register: config_file_stat
    - name: Read migration_timeout_minutes value
      ansible.builtin.shell: |
        set -o pipefail
        jq -r '.migration_timeout_minutes' {{ config_file }}
      args:
        executable: /bin/bash
      when: config_file_stat.stat.exists
      register: timeout_result
      ignore_errors: true
    - name: Set fact for timeout value
      ansible.builtin.set_fact:
        migration_timeout: "{{ timeout_result.stdout | default('null') }}"
      when: config_file_stat.stat.exists and timeout_result is not failed
    - name: Skip host if value is null or missing
      ansible.builtin.meta: end_host
      when:
        - config_file_stat.stat.exists
        - (timeout_result is failed) or (timeout_result.stdout == "null")
    - name: Display migration timeout value
      ansible.builtin.debug:
        msg: "Migration timeout for {{ inventory_hostname }}: {{ migration_timeout }} minutes"
      when: migration_timeout != "null"
    - name: Fail if timeout is null
      ansible.builtin.fail:
        msg: "migration_timeout_minutes is null or missing on {{ inventory_hostname }}"
      when:
        - config_file_stat.stat.exists
        - (timeout_result is failed) or (timeout_result.stdout == "null")