{"id":5102,"sha1":"ff2d6aebb3ad063a4d44a7fd21513a2ba3871a77","playbook":{"id":2996,"items":{"plays":1,"tasks":3,"results":3,"hosts":1,"files":1,"records":0},"arguments":{"version":null,"verbosity":0,"private_key_file":"/home/ssh-gateway/.ssh/id_rsa","remote_user":"root","connection":"ssh","timeout":null,"ssh_common_args":null,"sftp_extra_args":null,"scp_extra_args":null,"ssh_extra_args":null,"ask_pass":false,"connection_password_file":null,"force_handlers":false,"flush_cache":false,"become":false,"become_method":"sudo","become_user":null,"become_ask_pass":false,"become_password_file":null,"tags":["all"],"skip_tags":[],"check":false,"diff":false,"inventory":["/home/ssh-gateway/ansible/hosts"],"listhosts":false,"subset":null,"extra_vars":"Not saved by ARA as configured by 'ignored_arguments'","vault_ids":[],"ask_vault_pass":false,"vault_password_files":[],"forks":20,"module_path":null,"syntax":false,"listtasks":false,"listtags":false,"step":false,"start_at_task":null,"args":["generate_inventory_from_files.yml"]},"labels":[{"id":1,"name":"remote_user:root"},{"id":2,"name":"check:False"},{"id":3,"name":"tags:all"}],"started":"2025-05-23T11:10:15.322328+01:00","ended":"2025-05-23T11:10:16.561437+01:00","duration":"00:00:01.239109","name":null,"ansible_version":"2.16.11","client_version":"1.7.2","python_version":"3.10.10","server_version":"1.7.2","status":"failed","path":"/home/ssh-gateway/ansible/kuly/generate_inventory_from_files.yml","controller":"ssh-gw-4.layershift.com","user":"root"},"content":"---\n- name: Generate Ansible inventory from fetched ini files\n  hosts: localhost\n  gather_facts: false\n  vars:\n    base_dir: \"fetched_files\"\n    output_inventory_file: \"generated_inventory.ini\"\n  tasks:\n    - name: Find all ini files under each host folder\n      ansible.builtin.find:\n        paths: \"{{ base_dir }}\"\n        patterns: \"*.ini\"\n        recurse: true\n      register: ini_files\n\n    - name: Debug found files\n      ansible.builtin.debug:\n        msg: \"Found {{ ini_files.files | length }} .ini files.\"\n\n    - name: Extract hostnames from filenames and build inventory groups\n      ansible.builtin.set_fact:\n        inventory_data: |\n          {% set data = {} %}\n          {% for item in ini_files.files %}\n            {% set filename = item.path | basename %}\n            {% set hostname = filename | regex_replace('-panel.ini$', '') %}\n            {% if 'ungrouped' not in data %}{% do data.update({'ungrouped': []}) %}{% endif %}\n            {% do data['ungrouped'].append(hostname) %}\n          {% endfor %}\n          {{ data }}\n\n    - name: Write inventory to file\n      ansible.builtin.template:\n        src: inventory_template.j2\n        dest: \"{{ output_inventory_file }}\"\n      vars:\n        hosts_list: \"{{ inventory_data.ungrouped }}\"\n","created":"2025-05-23T11:10:15.339026+01:00","updated":"2025-05-23T11:10:15.339047+01:00","path":"/home/ssh-gateway/ansible/kuly/generate_inventory_from_files.yml"}