patternMinor
How I can use multiple hosts in AWX playbook?
Viewed 0 times
canawxhostsplaybookmultiplehowuse
Problem
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:
But when I run my playbook i have warning:
35.228.80.9 is my node_2_ip. How can I apply my playbook to this 2 machines?
---
- 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: trueBut when I run my playbook i have warning:
[WARNING]: Could not match supplied host pattern, ignoring: 35.228.80.935.228.80.9 is my node_2_ip. How can I apply my playbook to this 2 machines?
Solution
I suspect you haven't set up the host in your inventory you can figure out where your hosts are being pulled from with the following command:
In practice, you probably just need to create an
Then specify the
Depending on your exact use cases it might be more scalable and maintainable to use GCE Dynamic Inventory, although this does require a little bit of extra setup.
ansible-config dump | grep HOSTIn 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.9Then specify the
-i parameter to ansible-playbook:ansible-playbook -i inventory -k playbook.ymlDepending on your exact use cases it might be more scalable and maintainable to use GCE Dynamic Inventory, although this does require a little bit of extra setup.
Code Snippets
ansible-config dump | grep HOST[nodes]
node01 ansible_host=IP OF YOUR FIRST NODE HERE!!!
node02 ansible_host=35.228.80.9ansible-playbook -i inventory -k playbook.ymlContext
StackExchange DevOps Q#9771, answer score: 2
Revisions (0)
No revisions yet.