2017-11-01 10 views
0

モジュールjunos_get_factsを使用可能にしようとしています。 juniper.junosという役割の中で、メインのプレイブックといくつかのタスクがあります。例外:タスクでアクションが検出されていません。

ansible-脚本main_pb.yml

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

The error appears to have been in '/Users/macuared/Ansible_projects/roles/juniper.junos/tasks/main.yaml': line 2, column 3, but may 
be elsewhere in the file depending on the exact syntax problem. 

The offending line appears to be: 

--- 
- name: Test junos_get_facts module 
^here 


The error appears to have been in '/Users/macuared/Ansible_projects/roles/juniper.junos/tasks/main.yaml': line 2, column 3, but may 
be elsewhere in the file depending on the exact syntax problem. 

The offending line appears to be: 

--- 
- name: Test junos_get_facts module 
^here 

exception type: <class 'ansible.errors.AnsibleParserError'> 
exception: no action detected in task. This often indicates a misspelled module name, or incorrect module path. 

The error appears to have been in '/Users/macuared/Ansible_projects/roles/juniper.junos/tasks/main.yaml': line 2, column 3, but may 
be elsewhere in the file depending on the exact syntax problem. 

The offending line appears to be: 

--- 
- name: Test junos_get_facts module 
^here 

〜/ Ansible_projects/main_pb.yml

--- 
- name: Gathering Info from devices 
    hosts: man3-rc-test4200-01 
    connection: local 
    gather_facts: no 

    roles: 
    - { role: 'juniper.junos', when: DEVICE_TYPE == 'info'  } 

〜/ Ansible_projects:私は取得しています問題は、次の例外です/roles/Juniper.junos/tasks/main.yaml

--- 
- name: Test junos_get_facts module 
    tasks: 
    - name: "TEST 1 - Gather Facts" 
     junos_get_facts: 
     host: "{{ inventory_hostname}}" 
     user: "YYYYYYY" 
     passwd: "XXXXXXX" 
     ignore_errors: True 
     register: junos 

    # - debug: var=junos 

    - name: Check TEST 1 
     assert: 
     that: 
      - junos.facts.hostname 
      - junos.facts.serialnumber 
      - junos.facts.model 
      - junos.facts.fqdn 

ここで何が問題なのかよく分かりません。私はすべての依存関係がインストールされているvirtualenvを使用しています。

答えて

1

ロール内のタスクファイルには、タスクのリストが含まれている必要があります。

一方、あなたのファイルには、nametasksというキーを含む辞書を持つ単一要素のリストが含まれています。したがって、Ansibleはアクションを定義していません(name宣言は正しいですが、はアクションモジュールではありません)。

は、だからあなたmain.yamlは、次のようになります。

脚本タスクで
--- 
- name: "TEST 1 - Gather Facts" 
    junos_get_facts: 
    host: "{{ inventory_hostname}}" 
    user: "YYYYYYY" 
    passwd: "XXXXXXX" 
    ignore_errors: True 
    register: junos 

- name: Check TEST 1 
    assert: 
    that: 
     - junos.facts.hostname 
     - junos.facts.serialnumber 
     - junos.facts.model 
     - junos.facts.fqdn 

tasksの下で定義されていますが、役割に、ディレクトリ構造はすでに決定されます。

+0

ありがとうございます、今は少しはっきりしています。あなたが言ったように、問題は "タスク"辞書にありました。エラーメッセージを読むときは、辞書ではなくタスクのリストを期待していたので、今やもっと意味があります。 –

0

すぐに利用できますjunos_factsがありますが、junos_get_factsは別途インストールする必要があるカスタムモジュールです。

関連する問題