Answers: <p>I suspect you haven't set up the host in <a href="http://docs.ansible.com/ansible/latest/intro_inventory.html" rel="nofollow noreferrer">your inventory</a> you can figure out where your hosts are being pulled from with the following command:</p>
  
  <pre><code>ansible-config dump | grep HOST
  </code></pre>
  
  <p>In practice, you probably just need to create an <code>inventory</code> file with the following content:</p>
  
  <pre><code>[nodes]
  node01 ansible_host=IP OF YOUR FIRST NODE HERE!!!
  node02 ansible_host=35.228.80.9
  </code></pre>
  
  <p>Then specify the <code>-i</code> parameter to <code>ansible-playbook</code>:</p>
  
  <pre><code>ansible-playbook -i inventory -k playbook.yml
  </code></pre>
  
  <p>Depending on your exact use cases it might be more scalable and maintainable to use <a href="https://docs.ansible.com/ansible/latest/scenario_guides/guide_gce.html#gce-dynamic-inventory" rel="nofollow noreferrer">GCE Dynamic Inventory</a>, although this does require a little bit of extra setup.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-11-12T12:23:14.003Z
Answers: 2019-11-12T12:23:14.003Z
Answers: Richard Slater
Body: <p>I have workflow that create 2 virtual machines on GCP. When virtual instance created I store output with external ip to variable. In next playbook i want to use all of my ip addresses in host section. My code is:</p>
  
  <pre><code>---
  - name: Download and install jenkins
    hosts: 
     - "{{ node_1_ip }}"
     - "{{ node_2_ip }}"
    tasks:
     - name: Install java
       yum:
         name: java-1.8.0-openjdk-devel
       become: true
  </code></pre>
  
  <p>But when I run my playbook i have warning:</p>
  
  <pre><code>[WARNING]: Could not match supplied host pattern, ignoring: 35.228.80.9
  </code></pre>
  
  <p>35.228.80.9 is my node_2_ip. How can I apply my playbook to this 2 machines?</p>
  
Tags: <ansible>
Title: How I can use multiple hosts in AWX playbook?
UserDisplayName: Danylo Mysko
ThreadText: # How I can use multiple hosts in AWX playbook?
  
  (Asked by: username_0 on 2019-11-12)
  
  I have workflow that create 2 virtual machines on GCP. When virtual instance created I store output with external ip to variable. In next playbook i want to use all of my ip addresses in host section. My code is:
  
  ```
  ---
  - name: Download and install jenkins
    hosts: 
     - "{{ node_1_ip }}"
     - "{{ node_2_ip }}"
    tasks:
     - name: Install java
       yum:
         name: java-1.8.0-openjdk-devel
       become: true
  
  ```
  
  But when I run my playbook i have warning:
  
  ```
  [WARNING]: Could not match supplied host pattern, ignoring: 35.228.80.9
  
  ```
  
  35.228.80.9 is my node\_2\_ip. How can I apply my playbook to this 2 machines?
  
  **Tags:** ansible
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-11-12. Score: 2 | Accepted answer
  
  I suspect you haven't set up the host in [your inventory](http://docs.ansible.com/ansible/latest/intro_inventory.html) you can figure out where your hosts are being pulled from with the following command:
  
  ```
  ansible-config dump | grep HOST
  
  ```
  
  In practice, you probably just need to create an `inventory` file with the following content:
  
  ```
  [nodes]
  node01 ansible_host=IP OF YOUR FIRST NODE HERE!!!
  node02 ansible_host=35.228.80.9
  
  ```
  
  Then specify the `-i` parameter to `ansible-playbook`:
  
  ```
  ansible-playbook -i inventory -k playbook.yml
  
  ```
  
  Depending on your exact use cases it might be more scalable and maintainable to use [GCE Dynamic Inventory](https://docs.ansible.com/ansible/latest/scenario_guides/guide_gce.html#gce-dynamic-inventory), although this does require a little bit of extra setup.
  
  
  ---
  
  