Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where to create ansible hosts file in virtualenv?

I installed ansible with pip into my virtualenv, but I didn't find hosts file.

I have one /etc/ansible/hosts, but this is related to global install of ansible on the system.

like image 214
Július Marko Avatar asked Aug 18 '17 06:08

Július Marko


People also ask

Where is Ansible hosts file?

The default location for the inventory file is /etc/ansible/hosts. You can also create project-specific inventory files in alternate locations. The inventory file can list individual hosts or user-defined groups of hosts.

Where is Ansible CFG in Virtualenv?

Home directory. /etc/ansible/ansible. cfg.

How do I run Ansible in Virtualenv?

Set up virtualenv¶After you install virtualenv, you can create a “virtual environment” to host your local copy of Ansible. This command creates a directory called myansible in your current working directory. This directory contains a copy of Python that will install modules in the myansible directory.


1 Answers

You can create inventory file anywhere you like.

Just point Ansible to it via -i /path/to/inventory parameter or setting:

[defaults]
inventory = /path/to/inventory

in your local ansible.cfg file.

Ansible searches for config file here (in this order):

  • ANSIBLE_CONFIG (an environment variable)
  • ansible.cfg (in the current directory)
  • .ansible.cfg (in the home directory)
  • /etc/ansible/ansible.cfg
like image 72
Konstantin Suvorov Avatar answered Nov 10 '22 18:11

Konstantin Suvorov