Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you specify localhost in an ansible YAML file

Tags:

ansible

I am looking to create a inventory YAML file specifying localhost.

I have tried

all:
 hosts:
  localhost:
   ansible_connection: local
all:
 hosts:
  localhost

but I get an error about using ssh

like image 681
iamsimonsmale Avatar asked Dec 29 '25 21:12

iamsimonsmale


1 Answers

I found the following command ansible-inventory -i inventory.ini -y --list > inventory.yaml that converts ini files to yaml. I created an ini file with:

localhost ansible_connection=local

ran the command and got the following output that worked when I ran my playbook

all:
  children:
    ungrouped:
      hosts:
        localhost:
          ansible_connection: local

like image 182
iamsimonsmale Avatar answered Jan 01 '26 16:01

iamsimonsmale



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!