@ -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,29 +126,28 @@ 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 = {
repo = {
" id " : repo_id ,
" id " : repo_id ,
@ -156,7 +155,9 @@ def get_repository_list(module, list_parameter):
" url " : repo_url ,
" url " : repo_url ,
" enabled " : True if repo_enabled == ' 1 ' else False
" 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 )