Ошибка загрузчика данных при выполнении ansible.windows.win_powershellLinux

Ответить
Anonymous
 Ошибка загрузчика данных при выполнении ansible.windows.win_powershell

Сообщение Anonymous »

У меня установлен Ansible 2.17 в дистрибутиве Debian. У меня есть очень простая книга сценариев Ansible, которая должна выполнять сценарий PowerShell на целевой машине с Windows (сам сценарий находится на хосте Ansible).

Код: Выделить всё

---
- name: Configures AD for a new server
hosts: "{{ host }}"
fact_path: c:\Ansible\Facts
become_method: runas

vars:
scripts_folder: "/home/xxx/AnsiblePlaybooks/MyServerConfig/Scripts"
#extra-vars: ServerName

tasks:
- name: Add new server to Active Directory
ansible.windows.win_powershell:
path: "{{scripts_folder}}/ActiveDirectoryNewServer.ps1"
parameters:
ServerName: "{{ServerName}}"
Вот команда, которую я использую для выполнения этой книги:

Код: Выделить всё

ansible-playbook AD_config.yml --ask-pass --user xxx -e "force=true" --extra-vars "ServerName=MyServer" -vvvv
Однако я получаю непонятную мне ошибку. Вот полный результат:

Код: Выделить всё

ansible-playbook [core 2.17.14]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/xxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/xxx/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible-playbook
python version = 3.11.2 (main, Apr 28 2025, 14:11:48) [GCC 12.2.0] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
Loading collection ansible.builtin from
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
Loading collection ansible.windows from /home/xxx/.ansible/collections/ansible_collections/ansible/windows
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3/dist-packages/ansible/plugins/callback/default.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: AD_config.yml ********************************************************
Positional arguments: AD_config.yml
verbosity: 4
remote_user: xxxx
connection: ssh
ask_pass: True
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/hosts',)
extra_vars: ('force=true', 'ServerName=MyServer')
forks: 10
1 plays in AD_config.yml

PLAY [Configures AD for a new server] ******************************************

TASK [Gathering Facts] *********************************************************
task path: /home/xxx/AnsiblePlaybooks.git/Playbooks/MyServerConfig/AD_config.yml:2
redirecting (type: modules) ansible.builtin.setup to ansible.windows.setup
Using module file /home/xxx/.ansible/collections/ansible_collections/ansible/windows/plugins/modules/setup.ps1
Pipelining is enabled.
 ESTABLISH WINRM CONNECTION FOR USER: xxx on PORT 5985 TO 192.168.10.110
EXEC (via pipeline wrapper)
ok: [xxxDC1]

TASK [Add new server to Active Directory] **************************************
task path: /home/xxx/AnsiblePlaybooks.git/Playbooks/MyServerConfig/AD_config.yml:12
The full traceback is:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/ansible/executor/task_executor.py", line 644, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xxx/.ansible/collections/ansible_collections/ansible/windows/plugins/action/win_powershell.py", line 38, in run
module_args['script'] = self._loader.get_text_file_contents(full_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'DataLoader' object has no attribute 'get_text_file_contents'
fatal: [xxxDC1]: FAILED! => {
"msg": "Unexpected failure during module execution: 'DataLoader' object has no attribute 'get_text_file_contents'",
"stdout": ""
}

PLAY RECAP *********************************************************************
xxxDC1                     : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
Ключевая ошибка здесь:

Код: Выделить всё

AttributeError: 'DataLoader' object has no attribute 'get_text_file_contents'
Как будто код здесь не знает об объекте DataLoader, который присутствует в ansible.parsing (хотя файлы Python присутствуют в моей системе).
У меня установлены последние версии моих коллекций:

Код: Выделить всё

# /home/xxx/.ansible/collections/ansible_collections
Collection                               Version
---------------------------------------- -------
ansible.netcommon                        8.1.0
ansible.posix                            2.1.0
ansible.utils                            6.0.0
ansible.windows                          3.2.0
community.general                        11.4.0
Я искал именно эту ошибку, но ничего не нашел.

Подробнее здесь: https://stackoverflow.com/questions/797 ... powershell
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Linux»