我尝试使用ansible playbook安装redislabs和jmter,但无法使用playbook执行脚本。请找出我的剧本和错误。
错误代码:
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": []}
注:下面是jmeter的错误,redislabs也有同样的错误。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"
攻略:
---
- 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"
错误代码:
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条答案
按热度按时间8i9zcol21#
在最后一步中,将
script:
更改为shell:
。script
任务将脚本“上传”到目标主机并执行上传的脚本,但它被上传到一个临时目录中(请参阅错误输出中的ansible-tmp-XXXXXXX)。然后脚本(jmeter.sh)尝试在该目录中查找jmeter,但显然它不在那里。通过使用shell:
,它只会从正确的位置运行脚本。