Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Ansible setup module without an ansible.cfg

I want to run the ansible setup module, by declaring a specific host.

I am using Windows 10 machine , with windows subsystem for linux where ansible is installed.

I can run the setup module when using localhost, ie:

ansible localhost -m setup

I can run it when using the ansible.cfg file I use from one virtual environment, against a virtual machine ie:

ansible TestVm -m setup

In another virtual environment i have installed ansible without setting up an ansible.cfg file, and my hosts.yml file is in the windows (not the WSL filesystem).

No matter which directory i switch, I cannot run the setup module using for instance:

ansible -i inventory -m setup

.

Is there a way to run setup without a configuration file and if yes what part of the call am i missing?

like image 375
workaround Avatar asked Dec 08 '25 09:12

workaround


1 Answers

Try this:

ansible all -i inventory -m setup

Where the inventory is a directory with at least the hosts.yml file.

And this an example of hosts.yml

all:
  hosts:
    192.168.2.9:
    192.168.2.3:
    192.168.2.4:

Also before any of these you must have added pywinrm:

pip install pywinrm
like image 76
theofilis Avatar answered Dec 11 '25 01:12

theofilis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!