Forum Discussion

Aditya_Mehra's avatar
Aug 01, 2019

Ansible playbook error

Hi,

Need help in Ansible playbook.

Trying to run a basic playbook to fetch facts and command, but it keeps popping error. Can please anyone help.

Playbook 1

- name: Collect
  bigip_device_facts:
    gather_subset:
      - interfaces
      - vlans
    provider:
      server: x.x.x.x
      user: <username>
      password: <password>

Error

 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'


ERROR! 'bigip_device_facts' is not a valid attribute for a Play


The error appears to have been in '/ansible-01/playbook.yml': line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.


The offending line appears to be:




- name: Collect
  ^ here


Playbook 2

- name: run show version
  bigip_command:
     commands: show sys version
     provider:
        server: x.x.x.x
        user: <username>
        password: <password>

Error

 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'


ERROR! 'bigip_command' is not a valid attribute for a Play


The error appears to have been in '/ansible-01/playbook1.yml': line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.


The offending line appears to be:




- name: run show version
  ^ here

Thanks,

Aditya

  • Mael's avatar
    Mael
    Icon for Nimbostratus rankNimbostratus

    Hello Aditya,

    It seems that your playbook structure is incorrect. You're missing the host and task information.

    You should try the following:

    -  hosts: localhost
       connection: local
       gather_facts: no
       tasks:
       - name: Collect
         bigip_device_facts:
           gather_subset:
             - interfaces
             - vlans
           provider:
             server: x.x.x.x
             user: <username>
             password: <password>

    Be careful to respect the indentation.

    Best,

    Mael