mirror of
https://github.com/ansible/awx.git
synced 2026-02-02 18:18:12 -03:30
Fixing config loading issues when the config has no [general] section
Fixed typo in help documentation Fix up sanity errors and update converted modules Remove unnecessary test playbook file
This commit is contained in:
committed by
beeankha
parent
4fc2c58ae7
commit
018dd4c1c3
@@ -7,7 +7,7 @@ from ansible.module_utils.six import PY2
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlparse, urlencode
|
||||
from ansible.module_utils.six.moves.urllib.error import HTTPError
|
||||
from ansible.module_utils.six.moves.http_cookiejar import CookieJar
|
||||
from ansible.module_utils.six.moves.configparser import ConfigParser, NoOptionError
|
||||
from ansible.module_utils.six.moves.configparser import ConfigParser, NoOptionError, MissingSectionHeaderError
|
||||
from socket import gethostbyname
|
||||
import re
|
||||
from json import loads, dumps
|
||||
@@ -137,8 +137,10 @@ class TowerModule(AnsibleModule):
|
||||
if not access(config_path, R_OK):
|
||||
raise ConfigFileException("The specified config file can not be read")
|
||||
|
||||
config.read(config_path)
|
||||
if not config.has_section('general'):
|
||||
# If the config has not sections we will get a MissingSectionHeaderError
|
||||
try:
|
||||
config.read(config_path)
|
||||
except MissingSectionHeaderError:
|
||||
self.warn("No general section in file, auto-appending")
|
||||
with open(config_path, 'r') as f:
|
||||
config.read_string('[general]\n%s' % f.read())
|
||||
|
||||
Reference in New Issue
Block a user