Unable to execute the script file using ansible playbook for redislbas & jmeter

1.1k views Asked by At

I am trying to install redislabs and jmter using ansible playbook, but unable to execute the script using playbook. Please find my playbook and error as well.

Error:

fatal: [localhost]: FAILED! => {"changed": true, "msg": "non-zero return code", 
  "rc": 127, "stderr": "/home/ansibleadm/.ansible/tmp/ansible-tmp-1576768466.18-58336526997867/jmeter.sh: 
  line 109: /home/ansibleadm/.ansible/tmp/ansible-tmp-1576768466.18-58336526997867/jmeter: No such file or directory\n",
  "stderr_lines": ["/home/ansibleadm/.ansible/tmp/ansible-tmp-1576768466.18-58336526997867/jmeter.sh: 
  line 109: /home/ansibleadm/.ansible/tmp/ansible-tmp-1576768466.18-58336526997867/jmeter: No such file or directory"], 
  "stdout": "", "stdout_lines": []}

Note: Below error for jmeter and getting same error for redislabs as well. like No such file or directory

jmeter.yaml:

---
- hosts: localhost
  user: ansibleadm
  connection: local
  become: yes
  become_method: sudo
  tasks:
  - name: creating jmeter directory
      file: path=/home/ansibleadm/jmeter  state=directory mode=0700 owner=ansibleadm group=ansibleadm 
                   
  - name: downloading jmeter tar file
    get_url:
      url: http://apache.mirrors.tds.net//jmeter/source/apache-jmeter-5.2.1_src.tgz
      dest: /home/ansibleadm/jmeter

  - name: untar the file
      unarchive:
        src: "/home/ansibleadm/jmeter/apache-jmeter-5.2.1_src.tgz"
        dest: "/home/ansibleadm/jmeter"

  - name: executing jmeter.sh file
      script: "/home/ansibleadm/jmeter/apache-jmeter-5.2.1/bin/jmeter.sh"

Playbook:

---
- hosts: redisgroup
  user: ansibleadm
  become: yes
  become_method: sudo
  tasks:
   - name: creating a directory for redislabs
     file: path=/home/ansibleadm/remote_redis owner=ansibleadm group=ansibleadm mode=0700 state=directory
   - name: defining a variable
     set_fact:
      redis_variable: "/home/ansibleadm/remote_redis"
   - name: copy the tar file from src to destination.
     copy: src=/home/ansibleadm/redislabs-5.4.6-18-rhel7-x86_64.tar dest="{{redis_variable}}/redislabs-5.4.6-18-rhel7-x86_64.tar"
   - name: untar the file
     unarchive:
      src: /home/ansibleadm/redislabs-5.4.6-18-rhel7-x86_64.tar
      dest: "{{redis_variable}}"
   - name: execute the install.sh file in remote server
     shell: "{{redis_variable}}/install.sh -y"

Error:

 FAILED! => {"changed": true, "cmd": "/home/ansibleadm/remote_redis/install.sh -y", "delta": "0:00:04.792255", 
  "end": "2019-12-20 02:33:32.430351", "msg": "non-zero return code", "rc": 1, 
  "start": "2019-12-20 02:33:27.638096", "stderr": "/home/ansibleadm/remote_redis/install.sh: line 25: 
  rlec_upgrade_tmpdir/upgrade_checks_error_codes.sh: No such file or directory\ntouch:
   cannot touch ‘/var/opt/redislabs/log/install.log’: No such file or directory\nchmod:
    cannot access ‘/var/opt/redislabs/log/install.log’: No such file or directory\n/home/ansibleadm/remote_redis/install.sh:
     line 64: /var/opt/redislabs/log/install.log: No such file or directory", "stderr_lines":
      ["/home/ansibleadm/remote_redis/install.sh: line 25: rlec_upgrade_tmpdir/upgrade_checks_error_codes.sh:
       No such file or directory", "touch: cannot touch ‘/var/opt/redislabs/log/install.log’: No such file or directory",
       "chmod: cannot access ‘/var/opt/redislabs/log/install.log’: No such file or directory", 
       "/home/ansibleadm/remote_redis/install.sh: line 64: /var/opt/redislabs/log/install.log: No such file or directory"], 
       "stdout": "/home/ansibleadm/remote_redis/install.sh: line 25: rlec_upgrade_tmpdir/upgrade_checks_error_codes.sh: 
       No such file or directory\n2019-12-20 02:33:27 [.] Checking prerequisites\n2019-12-20 02:33:27 [.] Checking hardware requirements...\n
       2019-12-20 02:33:27 [!] The node’s hardware does not meet the minimum requirements for a production system: \n
       The node has 2 cores (minimum is 4) and 7 GB RAM (minimum is 15 GB). \n
       Consider upgrading your hardware in the case of a production system.\n
       ================================================================================\n
       \u001b[1m\u001b[91mRedis\u001b[90mLabs\u001b[0m Enterprise Cluster installer.\n
       ================================================================================\n\n
       2019-12-20 02:33:28 \u001b[92m[.] Checking root access\u001b[0m\n
       2019-12-20 02:33:28 \u001b[33m[!] Running as user root, sudo is not required.\u001b[0m\n
       2019-12-20 02:33:28 \u001b[92m[.] Updating paths.sh\u001b[0m\n
       2019-12-20 02:33:28 \u001b[92m[.] Creating socket directory /var/opt/redislabs/run \u001b[0m\n
       2019-12-20 02:33:29 \u001b[92m[.] Deleting \u001b[1m\u001b[91mRedis\u001b[90mLabs\u001b[0m debug package if exist\u001b[0m\n
       2019-12-20 02:33:29 \u001b[92m[.] Installing \u001b[1m\u001b[91mRedis\u001b[90mLabs\u001b[0m packages\u001b[0m\n
       2019-12-20 02:33:29 \u001b[37m[$] executing: 'yum install -y redislabs-5.4.6-18.rhel7.x86_64.rpm redislabs-utils-5.4.6-18.rhel7.x86_64.rpm'\u001b[0m\n
       \u001b[90mLoaded plugins: enabled_repos_upload, package_upload, product-id, search-\n
                     : disabled-repos, subscription-manager, tracer_upload\nNo package redislabs-5.4.6-18.rhel7.x86_64.rpm available.\n
                     No package redislabs-utils-5.4.6-18.rhel7.x86_64.rpm available.\n
                     Error: Nothing to do\nUploading Enabled Repositories Report\n
                     Loaded plugins: product-id, subscription-manager\n
                     \u001b[0m2019-12-20 02:33:32 \u001b[91m[x] yum install failed\u001b[0m", "stdout_lines": ["/home/ansibleadm/remote_redis/install.sh: line 25: rlec_upgrade_tmpdir/upgrade_checks_error_codes.sh: No such file or directory", "2019-12-20 02:33:27 [.] Checking prerequisites", "2019-12-20 02:33:27 [.] Checking hardware requirements...", "2019-12-20 02:33:27 [!] The node’s hardware does not meet the minimum requirements for a production system: ", "The node has 2 cores (minimum is 4) and 7 GB RAM (minimum is 15 GB). ", "Consider upgrading your hardware in the case of a production system.", 
1

There are 1 answers

6
Istvan Szekeres On

In the last step change script: to shell:.

The script tasks "uploads" the script to the target host and executes the uploaded one, but it is uploaded into a temporary directory (see the ansible-tmp-XXXXXXX in the error output). The script (jmeter.sh) then tries to find jmeter in that directory but obviously it is not there. By using shell: instead it will just run the script from the proper place.