mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 23:44:00 -07:00
update config code
This commit is contained in:
parent
1cadfcbf61
commit
7ab0d60b1a
2 changed files with 1 additions and 24 deletions
|
@ -33,16 +33,13 @@ def get_config(p, section, key, env_var, default):
|
||||||
return os.environ.get(env_var, default)
|
return os.environ.get(env_var, default)
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
def load_config_file():
|
def load_config_file():
|
||||||
p = ConfigParser.ConfigParser()
|
p = ConfigParser.ConfigParser()
|
||||||
path1 = os.path.expanduser("~/.ansible.cfg")
|
path1 = os.path.expanduser("~/.ansible.cfg")
|
||||||
path2 = "/etc/ansible/ansible.cfg"
|
path2 = "/etc/ansible/ansible.cfg"
|
||||||
if os.path.exists(path1):
|
if os.path.exists(path1):
|
||||||
print "A1"
|
|
||||||
p.read(path1)
|
p.read(path1)
|
||||||
elif os.path.exists(path2):
|
elif os.path.exists(path2):
|
||||||
print "A2"
|
|
||||||
p.read(path2)
|
p.read(path2)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
@ -77,24 +74,3 @@ DEFAULT_TRANSPORT_OPTS = ['local', 'paramiko', 'ssh']
|
||||||
DEFAULT_SUDO_PASS = None
|
DEFAULT_SUDO_PASS = None
|
||||||
DEFAULT_SUBSET = None
|
DEFAULT_SUBSET = None
|
||||||
|
|
||||||
def get_config(parser, section, key, env_var, default):
|
|
||||||
try:
|
|
||||||
return parser.get(section, key)
|
|
||||||
except:
|
|
||||||
if env_var is not None:
|
|
||||||
return os.environ.get(env_var, default)
|
|
||||||
return default
|
|
||||||
|
|
||||||
def load_config_file():
|
|
||||||
config = ConfigParser.ConfigParser()
|
|
||||||
path1 = os.path.expanduser("~/.ansible.cfg")
|
|
||||||
path2 = "/etc/ansible/ansible.cfg"
|
|
||||||
if os.path.exists(path1):
|
|
||||||
config.read(path1)
|
|
||||||
elif os.path.exists(path2):
|
|
||||||
config.read(path2)
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
return config
|
|
||||||
|
|
||||||
print "MODULE PATH=%s" % DEFAULT_MODULE_PATH
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ def main():
|
||||||
chdir = module.params['chdir']
|
chdir = module.params['chdir']
|
||||||
args = module.params['args']
|
args = module.params['args']
|
||||||
|
|
||||||
|
|
||||||
if chdir:
|
if chdir:
|
||||||
os.chdir(chdir)
|
os.chdir(chdir)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue