I have an ansbile.cfg file as well as a host file in a directory. In the same directory, I have a test_playbook.yml file. All three are copied below. When I run the ping (ad-hoc) command, I get a successful response. However, when I try running the ansible-playbook command, the response states the following:
[WARNING]: Host file not found: testserver
[WARNING]: provided hosts list is empty, only localhost is available
skipping: no hosts matched
ansible.cfg
[defaults]
hostfile = hosts
remote_user = testuser
##private_key_file = .vagrant/machines/default/virtualbox/private_key
##host_key_checking = False
hosts
[webservers]
testserver ansible_ssh_host=ec2-xx-xx-xxx-xxx.compute-1.amazonaws.com ansible_ssh_port=1234
test_playbook.yml
---
- hosts: all
remote_user: testuser
become: yes
become_user: testuser
tasks:
- group:
name: devops
state: present
- name: create devops user with admin privileges
user:
name: devops
comment: "Devops User"
uid: 2001
groups: devops
The command that I am running is the following:
ansible-playbook test_playbook.yml -i testserver -vvv
response:
Any idea on what I might have misconfigured?