You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ansible Playbook执行失败排查请求:remote_user配置失效、unarchive模块报错及文件权限异常

Troubleshooting Ansible Playbook Issues: File Permissions, Remote User & Unarchive Failure

Let's break down and fix the three key issues you're facing with your Ansible Playbook:


1. Fix the Unarchive Module Failure

The error message clearly points to the root cause:

Could not find or access '/home/ldb/servicebroker/servicebroker-4.1.0-rc6.x86_64.tar.gz' on the Ansible Controller

By default, the unarchive module looks for files on your local Ansible controller and uploads them to remote nodes. But your tar.gz file is already downloaded directly to the remote server via get_url. To fix this, add the remote_src: yes parameter to tell the module to use the file on the remote node:

- name: unzip tar file
  unarchive:
    src: /home/ldb/servicebroker/servicebroker-4.1.0-rc6.x86_64.tar.gz
    dest: /home/ldb/servicebroker/
    remote_src: yes  # Critical parameter to resolve the file not found error

2. Correct File Ownership (Root Instead of ldb)

Your downloaded files are owned by root because either:

  • The Playbook is running with elevated privileges (become: yes) without explicitly setting ownership, or
  • The remote_user: ldb setting isn't taking effect, so tasks run as root by default.

Fix Steps:

  1. Ensure the download directory belongs to ldb:
    - name: Create download directory
      file:
        path: /home/ldb/servicebroker
        state: directory
        owner: ldb
        group: ldb
        mode: 0755
    
  2. Force file ownership in the get_url task:
    - name: download DB and service_broker
      get_url:
        url: "http://192.168.1.133:12345/stage/{{ item }}"
        dest: /home/ldb/servicebroker
        mode: 0755
        timeout: 30
        owner: ldb  # Set owner explicitly
        group: ldb  # Set group explicitly
      with_items:
        - linkoopdb/4.1.0/zettabase-4.1.0-rc6.x86_64.iso
        - service_broker/4.1.0/servicebroker-4.1.0-rc6.x86_64.tar.gz
    

3. Make remote_user: ldb Take Effect

If the remote_user setting isn't working, check these common causes:

  • Inventory Override: Verify your inventory file (e.g., hosts) isn't overriding the user for the db group. Look for lines like:
    [db]
    192.168.14.94 ansible_user=root
    
    Change ansible_user to ldb or remove this line to respect the Playbook's remote_user setting.
  • Ansible.cfg Global Setting: Check your ansible.cfg file for a global remote_user parameter that's set to root:
    [defaults]
    remote_user = root
    
    Either modify this to ldb or explicitly set ansible_user: ldb in your Playbook (it takes priority over remote_user).
  • Become Configuration: If you have become: yes enabled (either in the Playbook or ansible.cfg) with become_user: root, tasks will run as root regardless of remote_user. If you don't need elevated privileges, remove become: yes. If you do need it, keep using the owner/group parameters in tasks to enforce file ownership.

Bonus: Fix a Typo in the Slave Start Task

Your Start slave task has a duplicate brokerServer in the shell command. Correct it to:

- name: Start slave
  shell: "/home/ldb/servicebroker/brokerServer --master_ip 192.168.14.94 --master_port 7777 --slave_ip {{ item }} --slave_port 7777 join"
  with_items:
    - 192.168.14.95
    - 192.168.14.94
    - 192.168.14.96
    - 192.168.14.97
    - 192.168.14.37
    - 192.168.14.38
    - 192.168.14.39

内容的提问来源于stack exchange,提问作者YanGang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 19:07:41