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
ce15813e
Commit
ce15813e
authored
Apr 28, 2014
by
Christian Berendt
Committed by
James Cammarata
May 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made enabled/disabled checks of apache2_module workable
parent
f05d4575
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
23 deletions
+14
-23
library/web_infrastructure/apache2_module
+14
-23
No files found.
library/web_infrastructure/apache2_module
View file @
ce15813e
#!/usr/bin/python
#!/usr/bin/python
#coding: utf-8 -*-
#coding: utf-8 -*-
# (c) 2013, Christian Berendt <berendt@b1-systems.de>
# (c) 2013
-2014
, Christian Berendt <berendt@b1-systems.de>
#
#
# This module is free software: you can redistribute it and/or modify
# This module is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
...
@@ -44,39 +44,31 @@ EXAMPLES = '''
...
@@ -44,39 +44,31 @@ EXAMPLES = '''
- apache2_module: state=absent name=wsgi
- apache2_module: state=absent name=wsgi
'''
'''
def
_module_is_enabled
(
module
):
import
re
name
=
module
.
params
[
'name'
]
a2enmod_binary
=
module
.
get_bin_path
(
"a2enmod"
)
result
,
stdout
,
stderr
=
module
.
run_command
(
"
%
s -q
%
s"
%
(
a2enmod_binary
,
name
))
return
result
==
0
def
_module_is_disabled
(
module
):
return
_module_is_enabled
(
module
)
==
False
def
_disable_module
(
module
):
def
_disable_module
(
module
):
name
=
module
.
params
[
'name'
]
name
=
module
.
params
[
'name'
]
a2dismod_binary
=
module
.
get_bin_path
(
"a2dismod"
)
result
,
stdout
,
stderr
=
module
.
run_command
(
"
%
s
%
s"
%
(
a2dismod_binary
,
name
))
if
_module_is_disabled
(
module
):
if
re
.
match
(
r'.*already disabled.*'
,
stdout
):
module
.
exit_json
(
changed
=
False
,
result
=
"Success"
)
module
.
exit_json
(
changed
=
False
,
result
=
"Success"
)
elif
result
!=
0
:
result
,
stdout
,
stderr
=
module
.
run_command
(
"a2dismod
%
s"
%
name
)
if
result
!=
0
:
module
.
fail_json
(
msg
=
"Failed to disable module
%
s:
%
s"
%
(
name
,
stdout
))
module
.
fail_json
(
msg
=
"Failed to disable module
%
s:
%
s"
%
(
name
,
stdout
))
else
:
module
.
exit_json
(
changed
=
True
,
result
=
"Disabled"
)
module
.
exit_json
(
changed
=
True
,
result
=
"Disabled"
)
def
_enable_module
(
module
):
def
_enable_module
(
module
):
name
=
module
.
params
[
'name'
]
name
=
module
.
params
[
'name'
]
if
_module_is_enabled
(
module
):
module
.
exit_json
(
changed
=
False
,
result
=
"Success"
)
a2enmod_binary
=
module
.
get_bin_path
(
"a2enmod"
)
a2enmod_binary
=
module
.
get_bin_path
(
"a2enmod"
)
result
,
stdout
,
stderr
=
module
.
run_command
(
"
%
s
%
s"
%
(
a2enmod_binary
,
name
))
result
,
stdout
,
stderr
=
module
.
run_command
(
"
%
s
%
s"
%
(
a2enmod_binary
,
name
))
if
result
!=
0
:
module
.
fail_json
(
msg
=
"Failed to enable module
%
s:
%
s"
%
(
name
,
stdout
))
module
.
exit_json
(
changed
=
True
,
result
=
"Enabled"
)
if
re
.
match
(
r'.*already enabled.*'
,
stdout
):
module
.
exit_json
(
changed
=
False
,
result
=
"Success"
)
elif
result
!=
0
:
module
.
fail_json
(
msg
=
"Failed to enable module
%
s:
%
s"
%
(
name
,
stdout
))
else
:
module
.
exit_json
(
changed
=
True
,
result
=
"Enabled"
)
def
main
():
def
main
():
module
=
AnsibleModule
(
module
=
AnsibleModule
(
...
@@ -95,4 +87,3 @@ def main():
...
@@ -95,4 +87,3 @@ def main():
# import module snippets
# import module snippets
from
ansible.module_utils.basic
import
*
from
ansible.module_utils.basic
import
*
main
()
main
()
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