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
dd1b44ac
Commit
dd1b44ac
authored
Oct 13, 2013
by
Renan Ivo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create install_options parameter to homebrew module
parent
b35337a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
library/packaging/homebrew
+21
-4
No files found.
library/packaging/homebrew
View file @
dd1b44ac
...
...
@@ -42,6 +42,11 @@ options:
required: false
default: "no"
choices: [ "yes", "no" ]
install_options:
description:
- options flags to install a package
required: false
default: ""
notes: []
'''
EXAMPLES
=
'''
...
...
@@ -49,6 +54,7 @@ EXAMPLES = '''
- homebrew: name=foo state=present update_homebrew=yes
- homebrew: name=foo state=absent
- homebrew: name=foo,bar state=absent
- homebrew: name=foo state=present install_options=with-baz,enable-debug
'''
...
...
@@ -98,7 +104,7 @@ def remove_packages(module, brew_path, packages):
module
.
exit_json
(
changed
=
False
,
msg
=
"package(s) already absent"
)
def
install_packages
(
module
,
brew_path
,
packages
):
def
install_packages
(
module
,
brew_path
,
packages
,
options
):
""" Installs one or more packages if not already installed. """
installed_count
=
0
...
...
@@ -109,7 +115,8 @@ def install_packages(module, brew_path, packages):
if
module
.
check_mode
:
module
.
exit_json
(
changed
=
True
)
rc
,
out
,
err
=
module
.
run_command
([
brew_path
,
'install'
,
package
])
rc
,
out
,
err
=
module
.
run_command
([
brew_path
,
'install'
,
package
,
options
])
if
not
query_package
(
module
,
brew_path
,
package
):
module
.
fail_json
(
msg
=
"failed to install
%
s:
%
s"
%
(
package
,
out
.
strip
()))
...
...
@@ -121,13 +128,22 @@ def install_packages(module, brew_path, packages):
module
.
exit_json
(
changed
=
False
,
msg
=
"package(s) already present"
)
def
generate_options_string
(
install_options
):
options_str
=
''
for
option
in
install_options
:
options_str
+=
' --
%
s'
%
option
return
options_str
.
strip
()
def
main
():
module
=
AnsibleModule
(
argument_spec
=
dict
(
name
=
dict
(
aliases
=
[
"pkg"
],
required
=
True
),
state
=
dict
(
default
=
"present"
,
choices
=
[
"present"
,
"installed"
,
"absent"
,
"removed"
]),
update_homebrew
=
dict
(
default
=
"no"
,
aliases
=
[
"update-brew"
],
type
=
'bool'
)
update_homebrew
=
dict
(
default
=
"no"
,
aliases
=
[
"update-brew"
],
type
=
'bool'
),
install_options
=
dict
(
default
=
""
,
aliases
=
[
"options"
],
type
=
'list'
)
),
supports_check_mode
=
True
)
...
...
@@ -142,7 +158,8 @@ def main():
pkgs
=
p
[
"name"
]
.
split
(
","
)
if
p
[
"state"
]
in
[
"present"
,
"installed"
]:
install_packages
(
module
,
brew_path
,
pkgs
)
opt
=
generate_options_string
(
p
[
"install_options"
])
install_packages
(
module
,
brew_path
,
pkgs
,
opt
)
elif
p
[
"state"
]
in
[
"absent"
,
"removed"
]:
remove_packages
(
module
,
brew_path
,
pkgs
)
...
...
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