Я пытаюсь запустить модуль с другим пользователем, используя становление_метода как pbrun:
---
- name: test pb
hosts: '{{ host }}'
gather_facts: true
tasks:
- name: Get TWS status linux
become: true
become_method: pbrun
become_user: 'testuser'
shell: 'whoami'
register: test_shell
when: ansible_os_family == 'RedHat'
- debug:
msg: '{{ test_shell }}'
Когда я запускаю эту книгу, я получаю следующую ошибку:
PLAY [test pb]
TASK [Gathering Facts]
ok: [csc2cxn00000734.cloud.kp.org]
TASK [Get TWS status linux]
fatal: [csc2cxn00000734.cloud.kp.org]: FAILED! => {"changed": false, "module_stderr":
"Shared connection to csc2cxn00000734.cloud.kp.org closed.\r\n", "module_stdout": "ksh:
.profile: not found [No such file or directory]\r\n", "msg": "MODULE FAILURE\nSee
stdout/stderr for the exact error", "rc": 0}
TASK [set_fact]
ok: [csc2cxn00000734.cloud.kp.org]
TASK [debug]
ok: [csc2cxn00000734.cloud.kp.org] => {
"msg": {
"changed": false,
"failed": true,
"module_stderr": "Shared connection to csc2cxn00000734.cloud.kp.org closed.\r\n",
"module_stdout": "ksh: .profile: not found [No such file or directory]\r\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 0
}
}
Но я могу переключиться на testuser с помощью pbrun и запустить эту команду вручную на этом хосте.