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
efe7bfa7
Commit
efe7bfa7
authored
Mar 11, 2014
by
Fabian Freyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed old variable names that referred to pkgin.
parent
880eaf38
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
library/packaging/pkgng
+19
-19
No files found.
library/packaging/pkgng
View file @
efe7bfa7
...
@@ -74,18 +74,18 @@ import os
...
@@ -74,18 +74,18 @@ import os
import
re
import
re
import
sys
import
sys
def
query_package
(
module
,
pkg
in
_path
,
name
):
def
query_package
(
module
,
pkg
ng
_path
,
name
):
rc
,
out
,
err
=
module
.
run_command
(
"
%
s info -g -e
%
s"
%
(
pkg
in
_path
,
name
))
rc
,
out
,
err
=
module
.
run_command
(
"
%
s info -g -e
%
s"
%
(
pkg
ng
_path
,
name
))
if
rc
==
0
:
if
rc
==
0
:
return
True
return
True
return
False
return
False
def
pkgng_older_than
(
module
,
pkg
in
_path
,
compare_version
):
def
pkgng_older_than
(
module
,
pkg
ng
_path
,
compare_version
):
rc
,
out
,
err
=
module
.
run_command
(
"
%
s -v"
%
pkg
in
_path
)
rc
,
out
,
err
=
module
.
run_command
(
"
%
s -v"
%
pkg
ng
_path
)
version
=
map
(
lambda
x
:
int
(
x
),
re
.
split
(
r'[\._]'
,
out
))
version
=
map
(
lambda
x
:
int
(
x
),
re
.
split
(
r'[\._]'
,
out
))
i
=
0
i
=
0
...
@@ -100,19 +100,19 @@ def pkgng_older_than(module, pkgin_path, compare_version):
...
@@ -100,19 +100,19 @@ def pkgng_older_than(module, pkgin_path, compare_version):
return
not
new_pkgng
return
not
new_pkgng
def
remove_packages
(
module
,
pkg
in
_path
,
packages
):
def
remove_packages
(
module
,
pkg
ng
_path
,
packages
):
remove_c
=
0
remove_c
=
0
# Using a for loop incase of error, we can report the package that failed
# Using a for loop incase of error, we can report the package that failed
for
package
in
packages
:
for
package
in
packages
:
# Query the package first, to see if we even need to remove
# Query the package first, to see if we even need to remove
if
not
query_package
(
module
,
pkg
in
_path
,
package
):
if
not
query_package
(
module
,
pkg
ng
_path
,
package
):
continue
continue
if
not
module
.
check_mode
:
if
not
module
.
check_mode
:
rc
,
out
,
err
=
module
.
run_command
(
"
%
s delete -y
%
s"
%
(
pkg
in
_path
,
package
))
rc
,
out
,
err
=
module
.
run_command
(
"
%
s delete -y
%
s"
%
(
pkg
ng
_path
,
package
))
if
not
module
.
check_mode
and
query_package
(
module
,
pkg
in
_path
,
package
):
if
not
module
.
check_mode
and
query_package
(
module
,
pkg
ng
_path
,
package
):
module
.
fail_json
(
msg
=
"failed to remove
%
s:
%
s"
%
(
package
,
out
))
module
.
fail_json
(
msg
=
"failed to remove
%
s:
%
s"
%
(
package
,
out
))
remove_c
+=
1
remove_c
+=
1
...
@@ -124,36 +124,36 @@ def remove_packages(module, pkgin_path, packages):
...
@@ -124,36 +124,36 @@ def remove_packages(module, pkgin_path, packages):
module
.
exit_json
(
changed
=
False
,
msg
=
"package(s) already absent"
)
module
.
exit_json
(
changed
=
False
,
msg
=
"package(s) already absent"
)
def
install_packages
(
module
,
pkg
in
_path
,
packages
,
cached
,
pkgsite
):
def
install_packages
(
module
,
pkg
ng
_path
,
packages
,
cached
,
pkgsite
):
install_c
=
0
install_c
=
0
# as of pkg-1.1.4, PACKAGESITE is deprecated in favor of repository definitions
# as of pkg-1.1.4, PACKAGESITE is deprecated in favor of repository definitions
# in /usr/local/etc/pkg/repos
# in /usr/local/etc/pkg/repos
old_pkgng
=
pkgng_older_than
(
module
,
pkg
in
_path
,
[
1
,
1
,
4
])
old_pkgng
=
pkgng_older_than
(
module
,
pkg
ng
_path
,
[
1
,
1
,
4
])
if
old_pkgng
and
(
pkgsite
!=
""
):
if
old_pkgng
and
(
pkgsite
!=
""
):
pkgsite
=
"PACKAGESITE=
%
s"
%
(
pkgsite
)
pkgsite
=
"PACKAGESITE=
%
s"
%
(
pkgsite
)
if
not
module
.
check_mode
and
cached
==
"no"
:
if
not
module
.
check_mode
and
cached
==
"no"
:
if
old_pkgng
:
if
old_pkgng
:
rc
,
out
,
err
=
module
.
run_command
(
"
%
s
%
s update"
%
(
pkgsite
,
pkg
in
_path
))
rc
,
out
,
err
=
module
.
run_command
(
"
%
s
%
s update"
%
(
pkgsite
,
pkg
ng
_path
))
else
:
else
:
rc
,
out
,
err
=
module
.
run_command
(
"
%
s update"
%
(
pkg
in
_path
))
rc
,
out
,
err
=
module
.
run_command
(
"
%
s update"
%
(
pkg
ng
_path
))
if
rc
!=
0
:
if
rc
!=
0
:
module
.
fail_json
(
msg
=
"Could not update catalogue"
)
module
.
fail_json
(
msg
=
"Could not update catalogue"
)
for
package
in
packages
:
for
package
in
packages
:
if
query_package
(
module
,
pkg
in
_path
,
package
):
if
query_package
(
module
,
pkg
ng
_path
,
package
):
continue
continue
if
not
module
.
check_mode
:
if
not
module
.
check_mode
:
if
old_pkgng
:
if
old_pkgng
:
rc
,
out
,
err
=
module
.
run_command
(
"
%
s
%
s install -g -U -y
%
s"
%
(
pkgsite
,
pkg
in
_path
,
package
))
rc
,
out
,
err
=
module
.
run_command
(
"
%
s
%
s install -g -U -y
%
s"
%
(
pkgsite
,
pkg
ng
_path
,
package
))
else
:
else
:
rc
,
out
,
err
=
module
.
run_command
(
"
%
s install -r
%
s -g -U -y
%
s"
%
(
pkg
in
_path
,
pkgsite
,
package
))
rc
,
out
,
err
=
module
.
run_command
(
"
%
s install -r
%
s -g -U -y
%
s"
%
(
pkg
ng
_path
,
pkgsite
,
package
))
if
not
module
.
check_mode
and
not
query_package
(
module
,
pkg
in
_path
,
package
):
if
not
module
.
check_mode
and
not
query_package
(
module
,
pkg
ng
_path
,
package
):
module
.
fail_json
(
msg
=
"failed to install
%
s:
%
s"
%
(
package
,
out
),
stderr
=
err
)
module
.
fail_json
(
msg
=
"failed to install
%
s:
%
s"
%
(
package
,
out
),
stderr
=
err
)
install_c
+=
1
install_c
+=
1
...
@@ -173,17 +173,17 @@ def main():
...
@@ -173,17 +173,17 @@ def main():
pkgsite
=
dict
(
default
=
""
,
required
=
False
)),
pkgsite
=
dict
(
default
=
""
,
required
=
False
)),
supports_check_mode
=
True
)
supports_check_mode
=
True
)
pkg
in
_path
=
module
.
get_bin_path
(
'pkg'
,
True
)
pkg
ng
_path
=
module
.
get_bin_path
(
'pkg'
,
True
)
p
=
module
.
params
p
=
module
.
params
pkgs
=
p
[
"name"
]
.
split
(
","
)
pkgs
=
p
[
"name"
]
.
split
(
","
)
if
p
[
"state"
]
==
"present"
:
if
p
[
"state"
]
==
"present"
:
install_packages
(
module
,
pkg
in
_path
,
pkgs
,
p
[
"cached"
],
p
[
"pkgsite"
])
install_packages
(
module
,
pkg
ng
_path
,
pkgs
,
p
[
"cached"
],
p
[
"pkgsite"
])
elif
p
[
"state"
]
==
"absent"
:
elif
p
[
"state"
]
==
"absent"
:
remove_packages
(
module
,
pkg
in
_path
,
pkgs
)
remove_packages
(
module
,
pkg
ng
_path
,
pkgs
)
# import module snippets
# import module snippets
from
ansible.module_utils.basic
import
*
from
ansible.module_utils.basic
import
*
...
...
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