@ -115,10 +115,10 @@ def get_repository_list(module, list_parameter):
' +----------------------------------------------------------+ ' ,
' +----------------------------------------------------------+ ' ,
' Available Repositories in /etc/yum.repos.d/redhat.repo '
' Available Repositories in /etc/yum.repos.d/redhat.repo '
]
]
repo_id_re _str = r ' Repo ID: (.*) '
repo_id_re = re . compile ( r ' Repo ID: \ s+(.*) ' )
repo_name_re _str = r ' Repo Name: (.*) '
repo_name_re = re . compile ( r ' Repo Name: \ s+(.*) ' )
repo_url_re _str = r ' Repo URL: (.*) '
repo_url_re = re . compile ( r ' Repo URL: \ s+(.*) ' )
repo_enabled_re _str = r ' Enabled: (.*) '
repo_enabled_re = re . compile ( r ' Enabled: \ s+(.*) ' )
repo_id = ' '
repo_id = ' '
repo_name = ' '
repo_name = ' '
@ -126,37 +126,38 @@ def get_repository_list(module, list_parameter):
repo_enabled = ' '
repo_enabled = ' '
repo_result = [ ]
repo_result = [ ]
for line in out . splitlines ( ) :
for line in out . split ( ' \n ' ) :
if line == ' ' or line in skip_lines :
if line in skip_lines :
continue
continue
repo_id_ re = re . match ( repo_id_re_str , line )
repo_id_ match = repo_id_re . match ( line )
if repo_id_ re :
if repo_id_ match :
repo_id = repo_id_ re . group ( 1 )
repo_id = repo_id_ match . group ( 1 )
continue
continue
repo_name_ re = re . match ( repo_name_re_str , line )
repo_name_ match = repo_name_re . match ( line )
if repo_name_ re :
if repo_name_ match :
repo_name = repo_name_ re . group ( 1 )
repo_name = repo_name_ match . group ( 1 )
continue
continue
repo_url_ re = re . match ( repo_url_re_str , line )
repo_url_ match = repo_url_re . match ( line )
if repo_url_ re :
if repo_url_ match :
repo_url = repo_url_ re . group ( 1 )
repo_url = repo_url_ match . group ( 1 )
continue
continue
repo_enabled_re = re . match ( repo_enabled_re_str , line )
repo_enabled_match = repo_enabled_re . match ( line )
if repo_enabled_re :
if repo_enabled_match :
repo_enabled = repo_enabled_re . group ( 1 )
repo_enabled = repo_enabled_match . group ( 1 )
repo = {
" id " : repo_id ,
" name " : repo_name ,
" url " : repo_url ,
" enabled " : True if repo_enabled == ' 1 ' else False
}
repo = {
" id " : repo_id ,
" name " : repo_name ,
" url " : repo_url ,
" enabled " : True if repo_enabled == ' 1 ' else False
}
repo_result . append ( repo )
repo_result . append ( repo )
return repo_result
return repo_result
@ -206,7 +207,7 @@ def repository_modify(module, state, name):
if not module . check_mode :
if not module . check_mode :
rc , out , err = run_subscription_manager ( module , rhsm_arguments )
rc , out , err = run_subscription_manager ( module , rhsm_arguments )
results = out . split ( ' \n ' )
results = out . split lines ( )
module . exit_json ( results = results , changed = changed , repositories = updated_repo_list , diff = diff )
module . exit_json ( results = results , changed = changed , repositories = updated_repo_list , diff = diff )