From 5859af7285e425113b124c58def6939f3911cb4b Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Sat, 25 May 2013 16:51:59 +0200 Subject: [PATCH] script support for roles: use the files/ directory instead of an additional scripts/ directory --- docsite/latest/rst/bestpractices.rst | 3 +-- docsite/latest/rst/playbooks.rst | 4 +--- lib/ansible/runner/action_plugins/script.py | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/docsite/latest/rst/bestpractices.rst b/docsite/latest/rst/bestpractices.rst index ac66c3ebcd..c0afa4488f 100644 --- a/docsite/latest/rst/bestpractices.rst +++ b/docsite/latest/rst/bestpractices.rst @@ -48,12 +48,11 @@ The top level of the directory would contain files and directories like so:: main.yml # <-- tasks file can include smaller files if warranted handlers/ # main.yml # <-- handlers file - scripts/ # - foo.sh # <-- script files for use with the script resource templates/ # <-- files for use with the template resource 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/ # "" diff --git a/docsite/latest/rst/playbooks.rst b/docsite/latest/rst/playbooks.rst index ef63349a67..cb403b1ee3 100644 --- a/docsite/latest/rst/playbooks.rst +++ b/docsite/latest/rst/playbooks.rst @@ -463,14 +463,12 @@ Example project structure:: roles/ common/ files/ - scripts/ templates/ tasks/ handlers/ vars/ webservers/ files/ - scripts/ templates/ tasks/ handlers/ @@ -490,7 +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/sripts/ 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, diff --git a/lib/ansible/runner/action_plugins/script.py b/lib/ansible/runner/action_plugins/script.py index 8794c343c5..84c0ab015b 100644 --- a/lib/ansible/runner/action_plugins/script.py +++ b/lib/ansible/runner/action_plugins/script.py @@ -42,7 +42,7 @@ class ActionModule(object): args = " ".join(tokens[1:]) source = template.template(self.runner.basedir, source, inject) if '_original_file' in inject: - source = utils.path_dwim_relative(inject['_original_file'], 'scripts', source, self.runner.basedir) + source = utils.path_dwim_relative(inject['_original_file'], 'files', source, self.runner.basedir) else: source = utils.path_dwim(self.runner.basedir, source)