Tôi muốn tạo nhiều thư mục (test1, test2) với 2 thư mục con (/ home/test1/bin và/home/test2/conf) tương tự cho test2. playbook của tôi trông như thế này:tạo nhiều thư mục bằng cách sử dụng ansible
--
- hosts: localhost
tasks:
- name: Create directory
file: path=/home/{{item}}/bin state=directory
file: path=/home/{{item}}/conf state=directory
with_items:
- test1
- test2
Tuy nhiên tôi nhận được lỗi sau:
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/root/ansible/lib/ansible/executor/process/worker.py", line 122, in run
executor_result = TaskExecutor(host, task, job_vars, new_play_context, self._new_stdin, self._loader, shared_loader_obj).run()
File "/root/ansible/lib/ansible/executor/task_executor.py", line 89, in run
items = self._get_loop_items()
File "/root/ansible/lib/ansible/executor/task_executor.py", line 179, in _get_loop_items
items = self._shared_loader_obj.lookup_loader.get(self._task.loop, loader=self._loader, templar=templar).run(terms=loop_terms, variables=vars_copy)
File "/root/ansible/lib/ansible/plugins/lookup/items.py", line 26, in run
return self._flatten(terms)
TypeError: _flatten() takes exactly 2 arguments (1 given)
fatal: [localhost]: FAILED! => {"failed": true, "stdout": ""}
Whats vấn đề ở đây? Tôi đang sử dụng thanh toán git mới nhất. Có cách nào tốt hơn để tiếp cận điều này?
bạn có thể hiển thị các dòng mã của bạn mà là cho vấn đề này? Rõ ràng bạn đang thiếu một đối số cho một số chức năng. – dasjkdj
@victor Tôi chưa viết bất kỳ mã nào cho công việc trên, tôi chỉ sử dụng các mô-đun ansible để hoàn thành công việc. – jugal