{"id":4150,"sha1":"a420f1580d4cc7abf1e3bc92e5e0a92c47e0a671","playbook":{"id":2129,"items":{"plays":1,"tasks":1,"results":0,"hosts":0,"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":["agent360_check_for_upgrade.yaml"]},"labels":[{"id":1,"name":"remote_user:root"},{"id":2,"name":"check:False"},{"id":3,"name":"tags:all"}],"started":"2024-11-05T17:28:16.406694Z","ended":"2024-11-05T17:28:19.731560Z","duration":"00:00:03.324866","name":null,"ansible_version":"2.16.11","client_version":"1.7.2","python_version":"3.10.10","server_version":"1.7.2","status":"expired","path":"/home/ssh-gateway/ansible/kuly/agent360_check_for_upgrade.yaml","controller":"ssh-gw-4.layershift.com","user":"root"},"content":"---\n- name: Playbook to check agent360 version and upgrade it\n  hosts: all\n  become: true\n  vars:\n    desired_agent360_version: \"1.3.0\"\n    output_file: /home/ssh-gateway/ansible/kuly/outputs/agent_versions.txt\n    upgrade_playbook: \"/home/ssh-gateway/ansible/kuly/agent360_upgrade.yaml\"\n  tasks:\n    - name: Get installed agent360 version using pip\n      ansible.builtin.shell: |\n        set -o pipefail\n        pip$(head -1 $(which agent360) | awk -F 'python' '{print $2}') show agent360 | grep Version | awk '{print $2}'\n      args:\n        executable: /bin/bash\n      register: agent360_version_result\n      changed_when: false\n      failed_when: agent360_version_result.rc != 0\n\n    - name: Display installed version of agent360\n      ansible.builtin.debug:\n        msg: \"Installed agent360 version: {{ agent360_version_result.stdout }}\"\n\n    - name: Save hostname and version if agent360 version is outdated and save_to_file is true\n      ansible.builtin.lineinfile:\n        dest: \"{{ output_file }}\"\n        create: true\n        mode: '0644'\n        line: \"{{ inventory_hostname }} - Agent360 version {{ agent360_version_result.stdout }} (outdated)\"\n      delegate_to: 127.0.0.1\n      when:\n        - agent360_version_result.stdout is version(desired_agent360_version, '<')\n        - save_to_file | default(false) | bool\n\n    - name: Run upgrade playbook if agent360 version is outdated and run_upgrade is true\n      ansible.builtin.include_vars:\n        file: \"{{ upgrade_playbook }}\"\n      when:\n        - agent360_version_result.stdout is version(desired_agent360_version, '<')\n        - run_upgrade | default(false) | bool\n","created":"2024-11-05T17:28:16.427126Z","updated":"2024-11-05T17:28:16.427147Z","path":"/home/ssh-gateway/ansible/kuly/agent360_check_for_upgrade.yaml"}