2017-04-04 111 views
0

我试图运行Ansible模块junos_cli和junos_rollback,我得到以下错误:Ansible - 无法运行某些JUNOS模块

ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path. 

The error appears to have been in '/home/quake/network-ansible/roles/junos-rollback/tasks/main.yml': line 2, column 3, but may 
be elsewhere in the file depending on the exact syntax problem. 

The offending line appears to be: 

--- 
- name: I've made a huge mistake 
^here 

这是有问题的角色:

--- 
- name: I've made a huge mistake 
    junos_rollback: 
    host={{ inventory_hostname }} 
    user=ansible 
    comment={{ comment }} 
    confirm={{ confirm }} 
    rollback={{ rollback }} 
    logfile={{ playbook_dir }}/library/logs/rollback.log 
    diffs_file={{ playbook_dir }}/configs/{{ inventory_hostname }} 

这里是瞻博网页: http://junos-ansible-modules.readthedocs.io/en/1.3.1/junos_rollback.html

他们的例子的语法有点奇怪。主机使用冒号而其余使用=符号。我尝试过混合使用,只使用其中一种。我不断收到错误。

我也证实了我的Junos的eznc版本高于1.2.2(我有2.0.1)

我已经能够前使用junos_cli,我不知道,如果版本不匹配发生。在官方的Ansible文档中,没有提到junos_cli或junos_rollback。也许他们不再支持?

http://docs.ansible.com/ansible/list_of_network_modules.html#junos

谢谢,

回答

0

junos_cli & junos_rollback是银河的一部分,而不是核心模块。你可以在 https://galaxy.ansible.com/Juniper/junos/

这里发布的内容是否包含你的操作手册的全部内容?如果是,您需要在剧本中定义其他项目,例如角色,连接,本地。例如

参考https://github.com/Juniper/ansible-junos-stdlib#example-playbook

```

--- 
- name: rollback example 
    hosts: all 
    roles: 
    - Juniper.junos 
    connection: local 
    gather_facts: no 

    tasks: 
    - name: I've made a huge mistake 
     junos_rollback: 
     host = {{inventory_hostname}} 
     ---- 
     ---- 

```

+0

上面的示例是由我的操作手册调用的角色。 我也已经安装了Juniper.Junos包: '$ ansible星系安装Juniper.junos - 已安装Juniper.junos,skipping.' 这是什么困惑我。一个月前,我能够使用junos_cli模块,现在我发现模块未找到错误。也许更新Ansible到2.0.2打破了他们?我不知道。 ''' – Quake

0

你在哪里保存juniper.junos模块的内容?你能发布你的剧本的内容和tree命令的输出来查看你的文件结构吗?这可能有帮助。

我有一个类似的问题,Ansible没有找到我的模块,我做的是将juniper.junos文件夹复制到我的角色文件夹,然后在其中添加一个任务文件夹,从那里执行main.yaml。

事情是这样的: /Users/macuared/Ansible_projects/roles/Juniper.junos/tasks

--- 
- name: "TEST 1 - Gather Facts" 
    junos_get_facts: 
    host: "{{ inventory_hostname}}" 
    user: "uuuuu" 
    passwd: "yyyyyy" 
    savedir: "/Users/macuared/Ansible_projects/Ouput/Facts" 
    ignore_errors: True 
    register: junos 

- name: Checking Device Version 
    debug: msg="{{ junos.facts.serialnumber }}" 

此外,我会在你的YAML “” 添加到字符串值。类似这样的:

--- 
- name: I've made a huge mistake 
    junos_rollback: 
    host="{{ inventory_hostname }}" 
    user=ansible 
    comment="{{ comment }}" 
    confirm={{ confirm }} 
    rollback={{ rollback }} 
    logfile="{{ playbook_dir }}/library/logs/rollback.log" 
    diffs_file="{{ playbook_dir }}/configs/{{ inventory_hostname }}" 

关于这个“我试过混合使用,只使用其中一个,我总是收到错误。”

我只使用冒号和我的工作正常,即使在文档中建议=迹象。请参阅junos_get_facts