Ansible 1.5 仍然无法找到主机

Ansible 1.5 仍然无法找到主机

您能发现下面的主机定义有什么错误吗?

# ansible --list-hosts -i inventory  -m fortimgr revision.yml
No hosts matched
root@vuwunicoids0001:/home/scripts/fortimanager# cat inventory
[all:vars]
ansible_python_interpreter=python

[fortimanager]
vuwvapcofmg0001 ansible_ssh_host=10.190.10.75 ansible_ssh_user=automation ansible_ssh_password=abc123
root@vuwunicoids0001:/home/scripts/fortimanager# cat revision.yml
---
- name: DEMONSTRATE REVISIONS
  hosts: fortimanager
  connection: local
  gather_facts: false
  tasks:
    - name: CREATE NEW REVISION
      fortimgr_revision:
        host: "{{ ansible_ssh_host }}"
        username: "{{ ansible_ssh_user }}"
        password: "{{ ansible_ssh_password }}"
        adom: "root"
        created_by: "automation"
        description: "ADOM Revision"
        revision_name: "Lab Revision"

    - name: DELETE REVISION
      fortimgr_revision:
        host: "{{ ansible_ssh_host }}"
        username: "{{ ansible_ssh_user }}"
        password: "{{ ansible_ssh_password }}"
        adom: "root"
        revision_name: "Lab Revision"
        state: "absent"

    - name: RESTORE REVISION
      fortimgr_revision:
        host: "{{ ansible_ssh_host }}"
        username: "{{ ansible_ssh_user }}"
        password: "{{ ansible_ssh_password }}"
        adom: "root"
        created_by: "automatino"
        description: "ADOM Revert"
        revision_name: "Good Revision"
        restore_name: "Rollback"

答案1

您所做的事情存在多个问题。

  • 问题:您正在将revision.yml主机模式传递给ansible命令,这就是没有匹配的主机的原因。
    解决方案:您实际上正在尝试运行剧本,因此您应该使用命令ansible-playbook而不是ansible
  • 问题:fortimgrAnsible 中 没有这样的模块。
    解决方案:从您的命令中删除-m fortimgr现在以 开头的命令ansible-playbook

相关内容