Skip to content

Commit

Permalink
Merge pull request #6452 from tsheibar/issue-6427
Browse files Browse the repository at this point in the history
Issue #6427 fix : Choose Package Provider on CentOS Boxes with Custom /etc/centos-release Content
  • Loading branch information
thatch45 committed Jul 31, 2013
2 parents cc9de9a + 4cb95ad commit fa8e3db
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions salt/grains/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,22 @@ def os_data():
grains['lsb_distrib_release'] = comps[2]
grains['lsb_distrib_codename'] = \
comps[3].replace('(', '').replace(')', '')
elif os.path.isfile('/etc/centos-release'):
# CentOS Linux
grains['lsb_distrib_id'] = 'CentOS'
with salt.utils.fopen('/etc/centos-release') as ifile:
for line in ifile:
# Need to pull out the version and codename
# in the case of custom content in /etc/centos-release
find_release = re.compile('\d+\.\d+')
find_codename = re.compile('(?<=\()(.*?)(?=\))')
release = find_release.search(line)
codename = find_codename.search(line)
if release is not None:
grains['lsb_distrib_release'] = release.group()
if codename is not None:
grains['lsb_distrib_codename'] = codename.group()

# Use the already intelligent platform module to get distro info
# (though apparently it's not intelligent enough to strip quotes)
(osname, osrelease, oscodename) = \
Expand Down

0 comments on commit fa8e3db

Please sign in to comment.