Missing host information when starting download file

I have 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 to run 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

the owners

[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 run is as follows:

ansible-playbook test_playbook.yml -i testserver -vvv

Answer:

Any idea on what I might have misconfigured?

+4
source share
1 answer

-iindicates your inventory file, not the host. Therefore it should be -i hosts.

ansible-playbook test_playbook.yml -i hosts

, , :

ansible-playbook test_playbook.yml -i testserver,

, , .

testserver, --limit

ansible-playbook test_playbook.yml -i hosts --limit testserver
+9

All Articles