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
8f9b761f
Commit
8f9b761f
authored
Feb 16, 2015
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10128 from alxgu/fix_facts_for_sles
Fix wrong distribution facts on SLES/openSUSE
parents
5416a994
d291dae5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
15 deletions
+40
-15
lib/ansible/module_utils/facts.py
+40
-15
No files found.
lib/ansible/module_utils/facts.py
View file @
8f9b761f
...
...
@@ -231,7 +231,7 @@ class Facts(object):
SLC
=
'RedHat'
,
Ascendos
=
'RedHat'
,
CloudLinux
=
'RedHat'
,
PSBM
=
'RedHat'
,
OracleLinux
=
'RedHat'
,
OVS
=
'RedHat'
,
OEL
=
'RedHat'
,
Amazon
=
'RedHat'
,
XenServer
=
'RedHat'
,
Ubuntu
=
'Debian'
,
Debian
=
'Debian'
,
SLES
=
'Suse'
,
SLED
=
'Suse'
,
OpenSu
SE
=
'Suse'
,
SuSE
=
'Suse'
,
Gentoo
=
'Gentoo'
,
Funtoo
=
'Gentoo'
,
SLED
=
'Suse'
,
openSU
SE
=
'Suse'
,
SuSE
=
'Suse'
,
Gentoo
=
'Gentoo'
,
Funtoo
=
'Gentoo'
,
Archlinux
=
'Archlinux'
,
Mandriva
=
'Mandrake'
,
Mandrake
=
'Mandrake'
,
Solaris
=
'Solaris'
,
Nexenta
=
'Solaris'
,
OmniOS
=
'Solaris'
,
OpenIndiana
=
'Solaris'
,
SmartOS
=
'Solaris'
,
AIX
=
'AIX'
,
Alpine
=
'Alpine'
,
MacOSX
=
'Darwin'
,
...
...
@@ -355,21 +355,46 @@ class Facts(object):
data
=
get_file_content
(
path
)
if
'suse'
in
data
.
lower
():
if
path
==
'/etc/os-release'
:
release
=
re
.
search
(
"PRETTY_NAME=[^(]+
\
(?([^)]+?)
\
)"
,
data
)
distdata
=
get_file_content
(
path
)
.
split
(
'
\n
'
)[
0
]
self
.
facts
[
'distribution'
]
=
distdata
.
split
(
'='
)[
1
]
if
release
:
self
.
facts
[
'distribution_release'
]
=
release
.
groups
()[
0
]
break
for
line
in
data
.
splitlines
():
distribution
=
re
.
search
(
"^NAME=(.*)"
,
line
)
if
distribution
:
self
.
facts
[
'distribution'
]
=
distribution
.
group
(
1
)
.
strip
(
'"'
)
distribution_version
=
re
.
search
(
'^VERSION_ID="?([0-9]+
\
.?[0-9]*)"?'
,
line
)
# example pattern are 13.04 13.0 13
if
distribution_version
:
self
.
facts
[
'distribution_version'
]
=
distribution_version
.
group
(
1
)
if
'open'
in
data
.
lower
():
release
=
re
.
search
(
"^PRETTY_NAME=[^(]+
\
(?([^)]+?)
\
)"
,
line
)
if
release
:
self
.
facts
[
'distribution_release'
]
=
release
.
groups
()[
0
]
elif
'enterprise'
in
data
.
lower
():
release
=
re
.
search
(
'^VERSION_ID="?[0-9]+
\
.?([0-9]*)"?'
,
line
)
# SLES doesn't got funny release names
if
release
:
release
=
release
.
group
(
1
)
else
:
release
=
"0"
# no minor number, so it is the first release
self
.
facts
[
'distribution_release'
]
=
release
break
elif
path
==
'/etc/SuSE-release'
:
data
=
data
.
splitlines
()
distdata
=
get_file_content
(
path
)
.
split
(
'
\n
'
)[
0
]
self
.
facts
[
'distribution'
]
=
distdata
.
split
()[
0
]
for
line
in
data
:
release
=
re
.
search
(
'CODENAME *= *([^
\n
]+)'
,
line
)
if
release
:
self
.
facts
[
'distribution_release'
]
=
release
.
groups
()[
0
]
.
strip
()
break
if
'open'
in
data
.
lower
():
data
=
data
.
splitlines
()
distdata
=
get_file_content
(
path
)
.
split
(
'
\n
'
)[
0
]
self
.
facts
[
'distribution'
]
=
distdata
.
split
()[
0
]
for
line
in
data
:
release
=
re
.
search
(
'CODENAME *= *([^
\n
]+)'
,
line
)
if
release
:
self
.
facts
[
'distribution_release'
]
=
release
.
groups
()[
0
]
.
strip
()
elif
'enterprise'
in
data
.
lower
():
lines
=
data
.
splitlines
()
distribution
=
lines
[
0
]
.
split
()[
0
]
if
"Server"
in
data
:
self
.
facts
[
'distribution'
]
=
"SLES"
elif
"Desktop"
in
data
:
self
.
facts
[
'distribution'
]
=
"SLED"
for
line
in
lines
:
release
=
re
.
search
(
'PATCHLEVEL = ([0-9]+)'
,
line
)
# SLES doesn't got funny release names
if
release
:
self
.
facts
[
'distribution_release'
]
=
release
.
group
(
1
)
self
.
facts
[
'distribution_version'
]
=
self
.
facts
[
'distribution_version'
]
+
'.'
+
release
.
group
(
1
)
elif
name
==
'Debian'
:
data
=
get_file_content
(
path
)
if
'Debian'
in
data
:
...
...
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