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
47ec93b3
Commit
47ec93b3
authored
Apr 27, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #270 from skvidal/devel
first_if_available and yum fixes
parents
40f54698
a3ab793b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
6 deletions
+50
-6
lib/ansible/playbook.py
+4
-2
lib/ansible/runner.py
+28
-0
library/copy
+2
-2
library/yum
+16
-2
No files found.
lib/ansible/playbook.py
View file @
47ec93b3
...
...
@@ -390,8 +390,10 @@ class PlayBook(object):
module_args
=
tokens
[
1
]
# include task specific vars
module_vars
=
task
.
get
(
'vars'
)
module_vars
=
task
.
get
(
'vars'
,
{})
if
'first_available_file'
in
task
:
module_vars
[
'first_available_file'
]
=
task
.
get
(
'first_available_file'
)
# tasks can be direct (run on all nodes matching
# the pattern) or conditional, where they ran
# as the result of a change handler on a subset
...
...
lib/ansible/runner.py
View file @
47ec93b3
...
...
@@ -390,6 +390,20 @@ class Runner(object):
# apply templating to source argument
inject
=
self
.
setup_cache
.
get
(
conn
.
host
,{})
# if we have first_available_file in our vars
# look up the files and use the first one we find as src
if
'first_available_file'
in
self
.
module_vars
:
found
=
False
for
fn
in
self
.
module_vars
.
get
(
'first_available_file'
):
fn
=
utils
.
template
(
fn
,
inject
,
self
.
setup_cache
)
if
os
.
path
.
exists
(
fn
):
source
=
fn
found
=
True
break
if
not
found
:
return
(
host
,
True
,
dict
(
failed
=
True
,
msg
=
"could not find src"
),
''
)
source
=
utils
.
template
(
source
,
inject
,
self
.
setup_cache
)
# transfer the file to a remote tmp location
...
...
@@ -480,6 +494,20 @@ class Runner(object):
# apply templating to source argument so vars can be used in the path
inject
=
self
.
setup_cache
.
get
(
conn
.
host
,{})
# if we have first_available_file in our vars
# look up the files and use the first one we find as src
if
'first_available_file'
in
self
.
module_vars
:
found
=
False
for
fn
in
self
.
module_vars
.
get
(
'first_available_file'
):
fn
=
utils
.
template
(
fn
,
inject
,
self
.
setup_cache
)
if
os
.
path
.
exists
(
fn
):
source
=
fn
found
=
True
break
if
not
found
:
return
(
host
,
True
,
dict
(
failed
=
True
,
msg
=
"could not find src"
),
''
)
source
=
utils
.
template
(
source
,
inject
,
self
.
setup_cache
)
(
host
,
ok
,
data
,
err
)
=
(
None
,
None
,
None
,
None
)
...
...
library/copy
View file @
47ec93b3
...
...
@@ -43,9 +43,9 @@ for x in items:
src
=
params
[
'src'
]
dest
=
params
[
'dest'
]
if
src
:
src
=
os
.
path
.
expanduser
(
src
)
src
=
os
.
path
.
expanduser
(
src
)
if
dest
:
dest
=
os
.
path
.
expanduser
(
dest
)
dest
=
os
.
path
.
expanduser
(
dest
)
# raise an error if there is no src file
if
not
os
.
path
.
exists
(
src
):
...
...
library/yum
View file @
47ec93b3
...
...
@@ -57,13 +57,24 @@ def pkg_to_dict(po):
'epoch'
:
po
.
epoch
,
'release'
:
po
.
release
,
'version'
:
po
.
version
,
'repo'
:
po
.
ui_from_repo
,
'_nevra'
:
po
.
ui_nevra
,
}
if
type
(
po
)
==
yum
.
rpmsack
.
RPMInstalledPackage
:
d
[
'yumstate'
]
=
'installed'
d
[
'repo'
]
=
'installed'
else
:
d
[
'yumstate'
]
=
'available'
d
[
'repo'
]
=
po
.
repoid
if
hasattr
(
po
,
'ui_from_repo'
):
d
[
'repo'
]
=
po
.
ui_from_repo
if
hasattr
(
po
,
'ui_nevra'
):
d
[
'_nevra'
]
=
po
.
ui_nevra
else
:
d
[
'_nevra'
]
=
'
%
s-
%
s-
%
s.
%
s'
%
(
po
.
name
,
po
.
version
,
po
.
release
,
po
.
arch
)
return
d
...
...
@@ -215,6 +226,9 @@ def ensure(my, state, pkgspec):
if
state
==
'latest'
:
updates
=
my
.
doPackageLists
(
pkgnarrow
=
'updates'
,
patterns
=
[
pkgspec
])
.
updates
# sucks but this is for rhel5 - won't matter for rhel6 or fedora or whatnot
e
,
m
,
u
=
yum
.
parsePackages
(
updates
,
[
pkgspec
],
casematch
=
True
)
updates
=
e
+
m
avail
=
my
.
doPackageLists
(
pkgnarrow
=
'available'
,
patterns
=
[
pkgspec
])
.
available
if
not
updates
and
not
avail
:
if
not
my
.
doPackageLists
(
pkgnarrow
=
'installed'
,
patterns
=
[
pkgspec
])
.
installed
:
...
...
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