I'm trying sort out my inventory.yaml file to arrange hosts by groups and then call them in an Ansible playbook.
The inventory.yaml file looks like this:
---
all:
hosts:
children:
MY_Lab:
Ubuntu_18:
hosts:
BWT_BKP_A:
ansible_host: "10.2.8.19"
BWT_BKP_B:
ansible_host: "10.2.8.22"
BWT_BKP_C:
ansible_host: "10.2.9.12"
vars:
ansible_connection: ssh
ansible_user: administrator
ansible_ssh_pass: P@ssword
ansible_sudo_pass: P@ssword
From my Ansible playbook I'd like to access hosts on Ubuntu_18 section, but I can't:
name: Test connectivity
hosts: BWT_BKP_A
vars:
ansible_python_interpreter: /usr/bin/python3
tasks:
- name: Ping test
ping:
I get the following error:
ansible-playbook ping-test.yaml -i inventory.yaml
[WARNING]: Could not match supplied host pattern, ignoring: BWT_BKP_A
PLAY [Test connectivity] *****************************************************************************************************
skipping: no hosts matched
If I try the whole group, like :
hosts: Ubuntu_18
I get the same error.
Not sure what I'm missing. I'm using ansible 2.9.12