From 1d89c8c43a5e5e20db939866a9b370ceebb18dbb Mon Sep 17 00:00:00 2001 From: Erwan Granger <32554862+erwangranger@users.noreply.github.com> Date: Fri, 3 May 2019 10:01:05 -0400 Subject: [PATCH] Fixing an issue with the code that deploys jq The previous method was failing as the playbook folder only existed on the Ansible Controller. Also, with the new code, jq is only installed when it's missing. --- .../tasks/pre.required_packages_config.yml | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/playbooks/pre-install-playbook/roles/viya-ark.preinstall/tasks/pre.required_packages_config.yml b/playbooks/pre-install-playbook/roles/viya-ark.preinstall/tasks/pre.required_packages_config.yml index a8d50ab..fe7c145 100644 --- a/playbooks/pre-install-playbook/roles/viya-ark.preinstall/tasks/pre.required_packages_config.yml +++ b/playbooks/pre-install-playbook/roles/viya-ark.preinstall/tasks/pre.required_packages_config.yml @@ -133,28 +133,36 @@ ## Install jq-1.5 utility for VI - block: - - name: "Download jq-1.5 utility" - get_url: - url: "{{jq_url}}" - dest: "{{playbook_dir}}/jq" - mode: a+x - - - name: "Check for downloaded content, {{playbook_dir}}/jq file" - stat: - path: "{{playbook_dir}}/jq" - register: jq_util_file - - - name: "Copy jq utility to /usr/bin" - copy: - src: "{{playbook_dir}}/jq" - dest: /usr/bin/jq - mode: a+x - when: jq_util_file.stat.exists - - - name: "Delete pre-copied jq utility from {{playbook_dir}}/jq" - file: - path: "{{playbook_dir}}/jq" - state: absent + - name: Determine if jq is available + changed_when: false + check_mode: no + ignore_errors: yes + shell: which jq + register: which_jq + + # - debug: var=which_jq + ## Block start (if jq can't be found) + + - block: + - name: Confirm that /usr/bin/jq does not exist + stat: + path: "/usr/bin/jq" + register: usr_bin_jq + + - name: Display whether /usr/bin/jq exists or not + debug: var=usr_bin_jq + + - name: "If jq is not found in /usr/bin, download jq-1.5 utility into it" + get_url: + url: "{{jq_url}}" + dest: "/usr/bin/jq" + mode: 0755 + owner: root + group: root + when: usr_bin_jq.stat.exists == false + + ## block end (if jq can't be found) + when: which_jq.rc != 0 tags: - jq