Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
1f6f7c94
Commit
1f6f7c94
authored
Aug 14, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #867 from willthames/config_file_location
Further fixes for constants following config introduction
parents
7ab0d60b
c01040ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
lib/ansible/constants.py
+15
-7
No files found.
lib/ansible/constants.py
View file @
1f6f7c94
...
@@ -35,7 +35,8 @@ def get_config(p, section, key, env_var, default):
...
@@ -35,7 +35,8 @@ 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
(
"~/.ansible.cfg"
)
path1
=
os
.
path
.
expanduser
(
os
.
environ
.
get
(
'ANSIBLE_CONFIG'
,
"~/.ansible.cfg"
))
path2
=
"/etc/ansible/ansible.cfg"
path2
=
"/etc/ansible/ansible.cfg"
if
os
.
path
.
exists
(
path1
):
if
os
.
path
.
exists
(
path1
):
p
.
read
(
path1
)
p
.
read
(
path1
)
...
@@ -45,6 +46,13 @@ def load_config_file():
...
@@ -45,6 +46,13 @@ def load_config_file():
return
None
return
None
return
p
return
p
def
shell_expand_path
(
path
):
''' shell_expand_path is needed as os.path.expanduser does not work
when path is None, which is the default for ANSIBLE_PRIVATE_KEY_FILE '''
if
path
:
path
=
os
.
path
.
expanduser
(
path
)
return
path
p
=
load_config_file
()
p
=
load_config_file
()
active_user
=
pwd
.
getpwuid
(
os
.
geteuid
())[
0
]
active_user
=
pwd
.
getpwuid
(
os
.
geteuid
())[
0
]
...
@@ -53,19 +61,19 @@ active_user = pwd.getpwuid(os.geteuid())[0]
...
@@ -53,19 +61,19 @@ active_user = pwd.getpwuid(os.geteuid())[0]
DEFAULTS
=
'defaults'
DEFAULTS
=
'defaults'
# configurable things
# configurable things
DEFAULT_HOST_LIST
=
get_config
(
p
,
DEFAULTS
,
'hostfile'
,
'ANSIBLE_HOSTS'
,
'/etc/ansible/hosts'
)
DEFAULT_HOST_LIST
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'hostfile'
,
'ANSIBLE_HOSTS'
,
'/etc/ansible/hosts'
)
)
DEFAULT_MODULE_PATH
=
get_config
(
p
,
DEFAULTS
,
'library'
,
'ANSIBLE_LIBRARY'
,
'/usr/share/ansible'
)
DEFAULT_MODULE_PATH
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'library'
,
'ANSIBLE_LIBRARY'
,
'/usr/share/ansible'
)
)
DEFAULT_REMOTE_TMP
=
get_config
(
p
,
DEFAULTS
,
'remote_tmp'
,
'ANSIBLE_REMOTE_TEMP'
,
'$HOME/.ansible/tmp'
)
DEFAULT_REMOTE_TMP
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'remote_tmp'
,
'ANSIBLE_REMOTE_TEMP'
,
'$HOME/.ansible/tmp'
)
)
DEFAULT_MODULE_NAME
=
get_config
(
p
,
DEFAULTS
,
'module_name'
,
None
,
'command'
)
DEFAULT_MODULE_NAME
=
get_config
(
p
,
DEFAULTS
,
'module_name'
,
None
,
'command'
)
DEFAULT_PATTERN
=
get_config
(
p
,
DEFAULTS
,
'pattern'
,
None
,
'*'
)
DEFAULT_PATTERN
=
get_config
(
p
,
DEFAULTS
,
'pattern'
,
None
,
'*'
)
DEFAULT_FORKS
=
get_config
(
p
,
DEFAULTS
,
'fork
_count'
,
'ANSIBLE_FORKS'
,
5
)
DEFAULT_FORKS
=
get_config
(
p
,
DEFAULTS
,
'fork
s'
,
'ANSIBLE_FORKS'
,
5
)
DEFAULT_MODULE_ARGS
=
get_config
(
p
,
DEFAULTS
,
'module_args'
,
'ANSIBLE_MODULE_ARGS'
,
''
)
DEFAULT_MODULE_ARGS
=
get_config
(
p
,
DEFAULTS
,
'module_args'
,
'ANSIBLE_MODULE_ARGS'
,
''
)
DEFAULT_TIMEOUT
=
get_config
(
p
,
DEFAULTS
,
'timeout'
,
'ANSIBLE_TIMEOUT'
,
10
)
DEFAULT_TIMEOUT
=
get_config
(
p
,
DEFAULTS
,
'timeout'
,
'ANSIBLE_TIMEOUT'
,
10
)
DEFAULT_POLL_INTERVAL
=
get_config
(
p
,
DEFAULTS
,
'poll_interval'
,
'ANSIBLE_POLL_INTERVAL'
,
15
)
DEFAULT_POLL_INTERVAL
=
get_config
(
p
,
DEFAULTS
,
'poll_interval'
,
'ANSIBLE_POLL_INTERVAL'
,
15
)
DEFAULT_REMOTE_USER
=
get_config
(
p
,
DEFAULTS
,
'remote_user'
,
'ANSIBLE_REMOTE_USER'
,
active_user
)
DEFAULT_REMOTE_USER
=
get_config
(
p
,
DEFAULTS
,
'remote_user'
,
'ANSIBLE_REMOTE_USER'
,
active_user
)
DEFAULT_PRIVATE_KEY_FILE
=
get_config
(
p
,
DEFAULTS
,
'private_key_file'
,
'ANSIBLE_PRIVATE_KEY_FILE'
,
None
)
DEFAULT_PRIVATE_KEY_FILE
=
shell_expand_path
(
get_config
(
p
,
DEFAULTS
,
'private_key_file'
,
'ANSIBLE_PRIVATE_KEY_FILE'
,
None
)
)
DEFAULT_SUDO_USER
=
get_config
(
p
,
DEFAULTS
,
'sudo_user'
,
'ANSIBLE_SUDO_USER'
,
'root'
)
DEFAULT_SUDO_USER
=
get_config
(
p
,
DEFAULTS
,
'sudo_user'
,
'ANSIBLE_SUDO_USER'
,
'root'
)
DEFAULT_REMOTE_PORT
=
get_config
(
p
,
DEFAULTS
,
'remote_port'
,
'ANSIBLE_REMOTE_PORT'
,
22
)
DEFAULT_REMOTE_PORT
=
int
(
get_config
(
p
,
DEFAULTS
,
'remote_port'
,
'ANSIBLE_REMOTE_PORT'
,
22
)
)
DEFAULT_TRANSPORT
=
get_config
(
p
,
DEFAULTS
,
'transport'
,
'ANSIBLE_TRANSPORT'
,
'paramiko'
)
DEFAULT_TRANSPORT
=
get_config
(
p
,
DEFAULTS
,
'transport'
,
'ANSIBLE_TRANSPORT'
,
'paramiko'
)
# non-configurable things
# non-configurable things
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment