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
24ea5949
Commit
24ea5949
authored
Nov 12, 2013
by
Sergey Sudakovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix when the system does not have lsb_release script, but has /etc/lsb_release file
parent
f31cb7c6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
25 deletions
+43
-25
library/system/setup
+43
-25
No files found.
library/system/setup
View file @
24ea5949
...
@@ -50,7 +50,7 @@ options:
...
@@ -50,7 +50,7 @@ options:
description:
description:
- path used for local ansible facts (*.fact) - files in this dir
- path used for local ansible facts (*.fact) - files in this dir
will be run (if executable) and their results be added to ansible_local facts
will be run (if executable) and their results be added to ansible_local facts
if a file is not executable it is read.
if a file is not executable it is read.
File/results format can be json or ini-format
File/results format can be json or ini-format
required: false
required: false
default: '/etc/ansible/facts.d'
default: '/etc/ansible/facts.d'
...
@@ -191,7 +191,7 @@ class Facts(object):
...
@@ -191,7 +191,7 @@ class Facts(object):
fact_path
=
module
.
params
.
get
(
'fact_path'
,
None
)
fact_path
=
module
.
params
.
get
(
'fact_path'
,
None
)
if
not
fact_path
or
not
os
.
path
.
exists
(
fact_path
):
if
not
fact_path
or
not
os
.
path
.
exists
(
fact_path
):
return
return
local
=
{}
local
=
{}
for
fn
in
sorted
(
glob
.
glob
(
fact_path
+
'/*.fact'
)):
for
fn
in
sorted
(
glob
.
glob
(
fact_path
+
'/*.fact'
)):
# where it will sit under local facts
# where it will sit under local facts
...
@@ -204,7 +204,7 @@ class Facts(object):
...
@@ -204,7 +204,7 @@ class Facts(object):
rc
,
out
,
err
=
module
.
run_command
(
fn
)
rc
,
out
,
err
=
module
.
run_command
(
fn
)
else
:
else
:
out
=
open
(
fn
)
.
read
()
out
=
open
(
fn
)
.
read
()
# load raw json
# load raw json
fact
=
'loading
%
s'
%
fact_base
fact
=
'loading
%
s'
%
fact_base
try
:
try
:
...
@@ -230,7 +230,7 @@ class Facts(object):
...
@@ -230,7 +230,7 @@ class Facts(object):
if
not
local
:
if
not
local
:
return
return
self
.
facts
[
'local'
]
=
local
self
.
facts
[
'local'
]
=
local
# platform.dist() is deprecated in 2.6
# platform.dist() is deprecated in 2.6
# in 2.6 and newer, you should use platform.linux_distribution()
# in 2.6 and newer, you should use platform.linux_distribution()
def
get_distribution_facts
(
self
):
def
get_distribution_facts
(
self
):
...
@@ -376,28 +376,46 @@ class Facts(object):
...
@@ -376,28 +376,46 @@ class Facts(object):
def
get_lsb_facts
(
self
):
def
get_lsb_facts
(
self
):
lsb_path
=
module
.
get_bin_path
(
'lsb_release'
)
lsb_path
=
module
.
get_bin_path
(
'lsb_release'
)
if
lsb_path
is
None
:
if
lsb_path
:
return
self
.
facts
rc
,
out
,
err
=
module
.
run_command
([
lsb_path
,
"-a"
])
rc
,
out
,
err
=
module
.
run_command
([
lsb_path
,
"-a"
])
if
rc
==
0
:
if
rc
==
0
:
self
.
facts
[
'lsb'
]
=
{}
for
line
in
out
.
split
(
'
\n
'
):
if
len
(
line
)
<
1
:
continue
value
=
line
.
split
(
':'
,
1
)[
1
]
.
strip
()
if
'LSB Version:'
in
line
:
self
.
facts
[
'lsb'
][
'release'
]
=
value
elif
'Distributor ID:'
in
line
:
self
.
facts
[
'lsb'
][
'id'
]
=
value
elif
'Description:'
in
line
:
self
.
facts
[
'lsb'
][
'description'
]
=
value
elif
'Release:'
in
line
:
self
.
facts
[
'lsb'
][
'release'
]
=
value
elif
'Codename:'
in
line
:
self
.
facts
[
'lsb'
][
'codename'
]
=
value
if
'lsb'
in
self
.
facts
and
'release'
in
self
.
facts
[
'lsb'
]:
self
.
facts
[
'lsb'
][
'major_release'
]
=
self
.
facts
[
'lsb'
][
'release'
]
.
split
(
'.'
)[
0
]
elif
lsb_path
is
None
and
os
.
path
.
exists
(
'/etc/lsb-release'
):
self
.
facts
[
'lsb'
]
=
{}
self
.
facts
[
'lsb'
]
=
{}
for
line
in
out
.
split
(
'
\n
'
)
:
with
open
(
'/etc/lsb-release'
,
'r'
)
as
f
:
if
len
(
line
)
<
1
:
for
line
in
f
.
readlines
()
:
continue
value
=
line
.
split
(
'='
,
1
)[
1
]
.
strip
()
value
=
line
.
split
(
':'
,
1
)[
1
]
.
strip
()
if
'DISTRIB_ID'
in
line
:
if
'LSB Version:'
in
line
:
self
.
facts
[
'lsb'
][
'id'
]
=
value
self
.
facts
[
'lsb'
][
'release'
]
=
value
elif
'DISTRIB_RELEASE'
in
line
:
elif
'Distributor ID:'
in
line
:
self
.
facts
[
'lsb'
][
'release'
]
=
value
self
.
facts
[
'lsb'
][
'id'
]
=
value
elif
'DISTRIB_DESCRIPTION'
in
line
:
elif
'Description:'
in
line
:
self
.
facts
[
'lsb'
][
'description'
]
=
value
self
.
facts
[
'lsb'
][
'description'
]
=
value
elif
'DISTRIB_CODENAME'
in
line
:
elif
'Release:'
in
line
:
self
.
facts
[
'lsb'
][
'codename'
]
=
value
self
.
facts
[
'lsb'
][
'release'
]
=
value
else
:
elif
'Codename:'
in
line
:
return
self
.
facts
self
.
facts
[
'lsb'
][
'codename'
]
=
value
if
'lsb'
in
self
.
facts
and
'release'
in
self
.
facts
[
'lsb'
]:
if
'lsb'
in
self
.
facts
and
'release'
in
self
.
facts
[
'lsb'
]:
self
.
facts
[
'lsb'
][
'major_release'
]
=
self
.
facts
[
'lsb'
][
'release'
]
.
split
(
'.'
)[
0
]
self
.
facts
[
'lsb'
][
'major_release'
]
=
self
.
facts
[
'lsb'
][
'release'
]
.
split
(
'.'
)[
0
]
def
get_selinux_facts
(
self
):
def
get_selinux_facts
(
self
):
if
not
HAVE_SELINUX
:
if
not
HAVE_SELINUX
:
self
.
facts
[
'selinux'
]
=
False
self
.
facts
[
'selinux'
]
=
False
...
@@ -1509,15 +1527,15 @@ class LinuxNetwork(Network):
...
@@ -1509,15 +1527,15 @@ class LinuxNetwork(Network):
ip_path
=
module
.
get_bin_path
(
"ip"
)
ip_path
=
module
.
get_bin_path
(
"ip"
)
primary_data
=
subprocess
.
Popen
(
primary_data
=
subprocess
.
Popen
(
[
ip_path
,
'addr'
,
'show'
,
'primary'
,
device
],
[
ip_path
,
'addr'
,
'show'
,
'primary'
,
device
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
.
communicate
()[
0
]
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
.
communicate
()[
0
]
secondary_data
=
subprocess
.
Popen
(
secondary_data
=
subprocess
.
Popen
(
[
ip_path
,
'addr'
,
'show'
,
'secondary'
,
device
],
[
ip_path
,
'addr'
,
'show'
,
'secondary'
,
device
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
.
communicate
()[
0
]
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
.
communicate
()[
0
]
parse_ip_output
(
primary_data
)
parse_ip_output
(
primary_data
)
parse_ip_output
(
secondary_data
,
secondary
=
True
)
parse_ip_output
(
secondary_data
,
secondary
=
True
)
# replace : by _ in interface name since they are hard to use in template
# replace : by _ in interface name since they are hard to use in template
new_interfaces
=
{}
new_interfaces
=
{}
for
i
in
interfaces
:
for
i
in
interfaces
:
if
':'
in
i
:
if
':'
in
i
:
...
...
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