mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add support for ./ansible.cfg file
Ansible support configuration in: ``` ~/.ansible.cfg /etc/ansible/ansible.cfg ``` this patch add current user (usefull where user have some different projects) with the oreder: ``` ./ansible.cfg ~/.ansible.cfg /etc/ansible/ansible.cfg ```
This commit is contained in:
parent
565f336182
commit
0cdd081b53
1 changed files with 6 additions and 3 deletions
|
@ -35,13 +35,16 @@ def get_config(p, section, key, env_var, default):
|
||||||
|
|
||||||
def load_config_file():
|
def load_config_file():
|
||||||
p = ConfigParser.ConfigParser()
|
p = ConfigParser.ConfigParser()
|
||||||
path1 = os.path.expanduser(
|
path1 = os.getcwd() + "/ansible.cfg"
|
||||||
os.environ.get('ANSIBLE_CONFIG', "~/.ansible.cfg"))
|
path2 = os.path.expanduser(os.environ.get('ANSIBLE_CONFIG', "~/.ansible.cfg"))
|
||||||
path2 = "/etc/ansible/ansible.cfg"
|
path3 = "/etc/ansible/ansible.cfg"
|
||||||
|
|
||||||
if os.path.exists(path1):
|
if os.path.exists(path1):
|
||||||
p.read(path1)
|
p.read(path1)
|
||||||
elif os.path.exists(path2):
|
elif os.path.exists(path2):
|
||||||
p.read(path2)
|
p.read(path2)
|
||||||
|
elif os.path.exists(path3):
|
||||||
|
p.read(path3)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
return p
|
return p
|
||||||
|
|
Loading…
Reference in a new issue