How do i reference hosts from ansible tower in yaml file?

cancel
Showing results for 
Search instead for 
Did you mean: 

How do i reference hosts from ansible tower in yaml file?

I'm trying to run a simple yaml file

 

 - name: Palo Test
    hosts: all
    connection: local
    gather_facts: false

    collections:
      - paloaltonetworks.panos


    tasks:
    - name: Get vr1 info
      panos_virtual_router_facts:
        provider: '{{ provider }}'
        name: 'VR1'
      register: vrlist
 
My ansible tower template has hosts and inventory details.
How do i reference that in my playbook, specifically under "provider" so that it would run against those hosts?
 
1 REPLY 1

create variable and pass the values like mentioned below .... those username/password you can pass from survey.

 

 - namePalo Test
    hostsall
    connectionlocal
    gather_factsfalse
 
 vars:
    fw:
      ip_address'{{inventory_hostname}}'
      username'{{ username }}'
      password'{{ pass }}'

    collections:
      - paloaltonetworks.panos


    tasks:
    - nameGet vr1 info
      panos_virtual_router_facts:
        provider'{{ fw }}'
        name'VR1'
      registervrlist
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!