1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

script support for roles: use the files/ directory

instead of an additional scripts/ directory
This commit is contained in:
Serge van Ginderachter 2013-05-25 16:51:59 +02:00
parent 0224dc464d
commit 5859af7285
3 changed files with 3 additions and 6 deletions

View file

@ -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 main.yml # <-- tasks file can include smaller files if warranted
handlers/ # handlers/ #
main.yml # <-- handlers file main.yml # <-- handlers file
scripts/ #
foo.sh # <-- script files for use with the script resource
templates/ # <-- files for use with the template resource templates/ # <-- files for use with the template resource
ntp.conf.j2 # <------- templates end in .j2 ntp.conf.j2 # <------- templates end in .j2
files/ # files/ #
bar.txt # <-- files for use with the copy resource 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 webtier/ # same kind of structure as "common" was above, done for the webtier role
monitoring/ # "" monitoring/ # ""

View file

@ -463,14 +463,12 @@ Example project structure::
roles/ roles/
common/ common/
files/ files/
scripts/
templates/ templates/
tasks/ tasks/
handlers/ handlers/
vars/ vars/
webservers/ webservers/
files/ files/
scripts/
templates/ templates/
tasks/ tasks/
handlers/ 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/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 - 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 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 - 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, If any files are not present, they are just ignored. So it's ok to not have a 'vars/' subdirectory for the role,

View file

@ -42,7 +42,7 @@ class ActionModule(object):
args = " ".join(tokens[1:]) args = " ".join(tokens[1:])
source = template.template(self.runner.basedir, source, inject) source = template.template(self.runner.basedir, source, inject)
if '_original_file' in 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: else:
source = utils.path_dwim(self.runner.basedir, source) source = utils.path_dwim(self.runner.basedir, source)