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
9961c1e2
Commit
9961c1e2
authored
Oct 19, 2012
by
Derek Carter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make policy only be required if state is not disabled
parent
84f48562
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
11 deletions
+23
-11
library/selinux
+23
-11
No files found.
library/selinux
View file @
9961c1e2
...
...
@@ -28,8 +28,8 @@ version_added: "0.7"
options:
policy:
description:
- "name of the SELinux policy to use (example: 'targeted')"
required:
tru
e
- "name of the SELinux policy to use (example: 'targeted')
will be required if state is not 'disabled'
"
required:
fals
e
default: null
state:
description:
...
...
@@ -44,11 +44,12 @@ options:
default: "/etc/selinux/config"
examples:
- code: selinux policy=targeted state=enforcing
- code: selinux policy=targeted state=disabled
- code: selinux policy=targeted state=permissive
- code: selinux state=disabled
notes:
- Not tested on any debian based system
requirements: [ ]
author: Derek Carter
requirements: [
libselinux-python
]
author: Derek Carter
<goozbach@friocorte.com>
'''
import
os
...
...
@@ -101,7 +102,7 @@ def set_state(state):
pass
else
:
msg
=
'trying to set invalid runtime state
%
s'
%
state
fail_json
(
msg
=
msg
)
module
.
fail_json
(
msg
=
msg
)
def
set_config_policy
(
policy
,
configfile
):
# edit config file with state value
...
...
@@ -117,11 +118,11 @@ def set_config_policy(policy, configfile):
def
main
():
if
(
not
HAVE_SELINUX
):
fail_json
(
msg
=
'python-selinux required for this module'
)
module
.
fail_json
(
msg
=
'python-selinux required for this module'
)
module
=
AnsibleModule
(
argument_spec
=
dict
(
policy
=
dict
(
required
=
Tru
e
),
policy
=
dict
(
required
=
Fals
e
),
state
=
dict
(
choices
=
[
'enforcing'
,
'permissive'
,
'disabled'
],
required
=
True
),
configfile
=
dict
(
aliases
=
[
'conf'
,
'file'
],
default
=
'/etc/selinux/config'
)
)
...
...
@@ -145,6 +146,14 @@ def main():
config_policy
=
get_config_policy
(
configfile
)
config_state
=
get_config_state
(
configfile
)
# check to see if policy is set if state is not 'disabled'
if
(
state
!=
'disabled'
):
if
(
policy
==
''
or
policy
==
None
):
module
.
fail_json
(
msg
=
'policy is required if state is not
\'
disabled
\'
'
)
else
:
if
(
policy
==
''
or
policy
==
None
):
policy
=
config_policy
# check changed values and run changes
if
(
policy
!=
runtime_policy
):
# cannot change runtime policy
...
...
@@ -158,10 +167,13 @@ def main():
if
(
state
!=
runtime_state
):
if
(
state
==
'disabled'
):
msgs
.
append
(
'
disabled stat
e will take effect next reboot'
)
msgs
.
append
(
'
state chang
e will take effect next reboot'
)
else
:
msgs
.
append
(
'runtime state changed from
\'
%
s
\'
to
\'
%
s
\'
'
%
(
runtime_state
,
state
))
set_state
(
state
)
if
(
runtime_enabled
):
set_state
(
state
)
msgs
.
append
(
'runtime state changed from
\'
%
s
\'
to
\'
%
s
\'
'
%
(
runtime_state
,
state
))
else
:
msgs
.
append
(
'state change will take effect next reboot'
)
changed
=
True
if
(
state
!=
config_state
):
...
...
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