请在下面找到我的 Ansible 目录结构。
\n\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 inventories\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 ansible_host\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 group_vars\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 all\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 vars\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 plays\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 01_recovery.yml\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 restore_all.yml\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 roles\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 01_recovery_lostMaster\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 defaults\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.yml\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 files\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 handlers\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.yml\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 meta\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.yml\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 README.md\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tasks\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.yml\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 templates\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tests\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 inventory\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 test.yml\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 vars\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.yml\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 remove_failed_master\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 defaults\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.yml\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 files\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 handlers\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.yml\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 meta\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.yml\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 README.md\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tasks\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.yml\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 templates\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tests\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 inventory\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 test.yml\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 vars\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.yml\nRun Code Online (Sandbox Code Playgroud)\n\n1) 家长手册:restore_all.yml
- name: Demo of restore plan\n hosts: localhost\n gather_facts: False\n\n vars_prompt:\n - name: "Action"\n prompt: |\n - Choose Action ?\n - 1] Action 1\n - 2] Action 2\n - Please select anyone action\n private: no\n\n tasks:\n\n - name: Action 1 Details\n when: Action == "1"\n import_playbook: plays/01_recovery.yml\n\n - name: Action 2 Details\n when: Action == "2"\n import_playbook: plays/02_recovery.yml\nRun Code Online (Sandbox Code Playgroud)\n\n2)01_recovery.yml
---\n- name: Restore role\n hosts: localhost\n roles:\n - { role: restore/roles/01_recovery_lostMaster, tags: [\'01_recovery_lostMaster\'] }\n\n- name: remove failed master\n hosts: master-01\n become: true\n roles:\n - { role: restore/roles/remove_failed_master, tags: [\'remove_failed_master\'] }\nRun Code Online (Sandbox Code Playgroud)\n\n最后,当我使用 import_playbook 运行剧本时,出现以下错误。
\n\n[root@api localhost]# ansible-playbook restore_all.yml -e "host=localhost"\n[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match \'all\'\nERROR! this task \'import_playbook\' has extra params, which is only allowed in the following modules: shell, win_shell, include_vars, add_host, raw, include_role, meta, set_fact, include, import_tasks, script, import_role, include_tasks, group_by, command, win_command\nRun Code Online (Sandbox Code Playgroud)\n\n该错误似乎位于 中\'/home/ec2-user/restore/restore_all.yml\': line 20, column 7,但\n可能位于文件的其他位置,具体取决于具体的语法问题。
有问题的行似乎是:
\n\n- name: Action 1 Details\n ^ here\nRun Code Online (Sandbox Code Playgroud)\n\n而且,我也尝试使用 import_tasks,它给了我以下错误:
\n\n[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match \'all\'\nERROR! conflicting action statements: hosts, roles\nRun Code Online (Sandbox Code Playgroud)\n\n请问您能根据上述场景帮助解决我的问题吗?
\n\nRestore_all.yml --> 导入另一个剧本 --> 在本地主机中运行一个角色,在另一台主机中运行另一个角色。
\n| 归档时间: |
|
| 查看次数: |
15464 次 |
| 最近记录: |