Blank Template to add custom Ansible roles to Saltbox.
-
Install this repo:
git clone https://github.com/saltyorg/saltbox_mod.git /opt/saltbox_mod
or alternatively :
sb install saltbox_mod
-
CD into the
saltbox_mod
folder:cd /opt/saltbox_mod
-
Create folders for the Ansible role:
mkdir -p /opt/saltbox_mod/roles/newrole/tasks/
-
Place the task file there:
touch /opt/saltbox_mod/roles/newrole/tasks/main.yml
-
Add custom variables into
settings.yml
:/opt/saltbox_mod/settings.yml
-
Add the Ansible role to
saltbox_mod.yml
:To edit:
nano /opt/saltbox_mod/saltbox_mod.yml
Add the following line under
roles:
:- { role: newrole, tags: ['newrole'] }
Final result:
--- - hosts: localhost vars_files: - settings.yml - ['/srv/git/saltbox/accounts.yml', '/srv/git/saltbox/defaults/accounts.yml.default'] - ['/srv/git/saltbox/settings.yml', '/srv/git/saltbox/defaults/settings.yml.default'] - ['/srv/git/saltbox/adv_settings.yml', '/srv/git/saltbox/defaults/adv_settings.yml.default'] roles: - { role: pre_tasks } - { role: myrole, tags: ['myrole'] } - { role: newrole, tags: ['newrole'] }
Note: The
pre_tasks
role is required and should not be removed. -
Run the Ansible role:
sudo ansible-playbook saltbox_mod.yml --tags newrole
Step 3 to 5 can be simplified by using the helloworld role as a template. It should be usable without to much modification for most webapp that use a single web port.
cp -r /opt/saltbox_mod/roles/helloworld /opt/saltbox_mod/roles/newrole
sed -i 's/helloworld/newrole/g' /opt/saltbox_mod/roles/defaults/main.yml
then edit the defaults settings.
nano /opt/saltbox_mod/roles/newrole/tasks/main.yml
At the very minimum, you may expect to update the following variables:
newrole_web_port:
newrole_docker_image:
newrole_docker_envs_default:
newrole_docker_volumes_default: