2017-04-04 115 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