Below is my directory structure for ansibel role called webserver
localhost roles # tree
.
├── readme.md
├── site.yml
└── webserver
├── files
│ ├── createswap.sh
│ └── nginxkeyadd.sh
├── handlers
│ └── main.yml
├── tasks
│ └── main.yml
├── templates
│ ├── helloworld.conf.j2
│ └── index.html.j2
└── vars
└── main.yml
my tasks/main.yml looks like
- name: Create swap file 50MB
script: /etc/ansible/roles/webserver/files/createswap.sh
- name: add GPG key for nginx
script: /etc/ansible/roles/webserver/files/nginxkeyadd.sh
- name: Install nginx on target
apt: name={{ item }} state=latest
with_items:
- rsync
- git
- nginx
in the task/main.yml im specifying absolute path to local scriptfile like
script: /etc/ansible/roles/webserver/files/nginxkeyadd.sh
and script: /etc/ansible/roles/webserver/files/createswap.sh
. The scripts don't have any ansible variables.
is it good practice in ansible ?