Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add roles support for the script module #3017

Merged
merged 3 commits into from
May 29, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docsite/latest/rst/bestpractices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The top level of the directory would contain files and directories like so::
ntp.conf.j2 # <------- templates end in .j2
files/ #
bar.txt # <-- files for use with the copy resource
foo.sh # <-- script files for use with the script resource

webtier/ # same kind of structure as "common" was above, done for the webtier role
monitoring/ # ""
Expand Down
3 changes: 3 additions & 0 deletions docsite/latest/rst/playbooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ This designates the following behaviors, for each role 'x':
- If roles/x/handlers/main.yml exists, handlers listed therein will be added to the play
- If roles/x/vars/main.yml exists, variables listed therein will be added to the play
- Any copy tasks can reference files in roles/x/files/ without having to path them relatively or absolutely
- Any script tasks can reference scripts in roles/x/files/ without having to path them relatively or absolutely
- Any template tasks can reference files in roles/x/templates/ without having to path them relatively or absolutely

If any files are not present, they are just ignored. So it's ok to not have a 'vars/' subdirectory for the role,
Expand Down Expand Up @@ -526,6 +527,8 @@ If you want to define certain tasks to happen before AND after roles are applied
- shell: echo 'hello'
roles:
- { role: some_role }
tasks:
- shell: echo 'still busy'
post_tasks:
- shell: echo 'goodbye'

Expand Down
5 changes: 4 additions & 1 deletion lib/ansible/runner/action_plugins/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **
# FIXME: error handling
args = " ".join(tokens[1:])
source = template.template(self.runner.basedir, source, inject)
source = utils.path_dwim(self.runner.basedir, source)
if '_original_file' in inject:
source = utils.path_dwim_relative(inject['_original_file'], 'files', source, self.runner.basedir)
else:
source = utils.path_dwim(self.runner.basedir, source)

# transfer the file to a remote tmp location
source = source.replace('\x00','') # why does this happen here?
Expand Down