gpt4 book ai didi

linux - Ansible 剧本与 pbrun 不工作

转载 作者:太空宇宙 更新时间:2023-11-04 03:42:57 25 4
gpt4 key购买 nike

first-playbook.yml:

---
- hosts: all
tasks:
- name: test
shell: chdir=/home/tibco pbrun su - tibco sh test.sh
sudo: yes

错误:

[root@c0043724 ansible]# ansible-playbook -vvv first-playbook.yml -u balp --ask-pass -c paramiko
SSH password:

PLAY [all] ********************************************************************

GATHERING FACTS ***************************************************************
<c0043725.itcs.hp.com> ESTABLISH CONNECTION FOR USER: balp on PORT 22 TO c0043725.itcs.hp.com
<c0043725.itcs.hp.com> REMOTE_MODULE setup
<c0043725.itcs.hp.com> EXEC /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1426531409.47-88648204897709 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1426531409.47-88648204897709 && echo $HOME/.ansible/tmp/ansible-tmp-1426531409.47-88648204897709'
<c0043725.itcs.hp.com> PUT /tmp/tmpNP2qY2 TO /home/balp/.ansible/tmp/ansible-tmp-1426531409.47-88648204897709/setup
<c0043725.itcs.hp.com> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /home/balp/.ansible/tmp/ansible-tmp-1426531409.47-88648204897709/setup; rm -rf /home/balp/.ansible/tmp/ansible-tmp-1426531409.47-88648204897709/ >/dev/null 2>&1'
ok: [c0043725.itcs.hp.com]

TASK: [test] ******************************************************************
<c0043725.itcs.hp.com> ESTABLISH CONNECTION FOR USER: balp on PORT 22 TO c0043725.itcs.hp.com
<c0043725.itcs.hp.com> REMOTE_MODULE command chdir=/home/tibco pbrun su - tibco sh test.sh #USE_SHELL
<c0043725.itcs.hp.com> EXEC /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1426531412.61-87821666758998 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1426531412.61-87821666758998 && echo $HOME/.ansible/tmp/ansible-tmp-1426531412.61-87821666758998'
<c0043725.itcs.hp.com> PUT /tmp/tmpNgfy06 TO /home/balp/.ansible/tmp/ansible-tmp-1426531412.61-87821666758998/command
<c0043725.itcs.hp.com> EXEC /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=torjbeltprhcmjkqbwcakmroqrxvfiai] password: " -u root /bin/sh -c "echo BECOME-SUCCESS-torjbeltprhcmjkqbwcakmroqrxvfiai; LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /home/balp/.ansible/tmp/ansible-tmp-1426531412.61-87821666758998/command; rm -rf /home/balp/.ansible/tmp/ansible-tmp-1426531412.61-87821666758998/ >/dev/null 2>&1"'
failed: [c0043725.itcs.hp.com] => {"changed": true, "cmd": "pbrun su - tibco sh test.sh", "delta": "0:00:00.024944", "end": "2015-03-16 18:43:33.371752", "rc": 127, "start": "2015-03-16 18:43:33.346808", "warnings": []}
stderr: /bin/sh: pbrun: command not found

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
to retry, use: --limit @/root/first-playbook.retry

c0043725.itcs.hp.com : ok=1 changed=0 unreachable=0 failed=1

你能帮忙解决一下吗?

最佳答案

需要更多信息以便更好地调试。但我的猜测是你正在尝试混合 3 种不同的方式来执行 su。

  • 一些名为 pbrun 的自定义工具(我猜这是您/您的运算符(operator)创建的一些脚本,以允许您进行 sudo 访问)。
  • su 在您正在执行的命令中。
  • 您通过指定 sudo: yes 来请求 ansible 进行 su。
  • (更不用说您以 root 身份运行 playbook,默认情况下,它会以 root 身份隐式连接到远程计算机(除非您在配置或 list 中的某个位置覆盖它),一开始就不需要 sudoing)

我建议您在剧本中使用 pbruntest.sh 的完整路径,并仅保留执行这三种方法中的一种 su 方法。

--编辑--

我假设您已经知道 ansible.cfg 中的 abt sudo_exe 参数

# change this for alternative sudo implementations
sudo_exe = sudo

关于linux - Ansible 剧本与 pbrun 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29084637/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com