-
-
Notifications
You must be signed in to change notification settings - Fork 642
Add ability to provide custom shell scripts to run after provisioning #174
Comments
This will need a documentation page, since usage will not be 100% intuitive/discoverable. |
I did a good deal of testing for this on Ansible 2.0.0 (still not the stable release yet), and it looks like the following code should do the trick, since 2.x includes files during playbook runs, and doesn't precompile everything: # Include custom tasks file if it's present.
- name: Check if custom_tasks.yml is present.
stat: path=provisioning/tasks/custom-tasks.yml
register: custom_tasks_file
connection: local
sudo: no
- include: tasks/custom-tasks.yml
when: custom_tasks_file.stat.exists This would require the user place the I may be able to use a better strategy, like using |
Postponed, because I can't see a way to do this until Ansible 2.x is publicly available. This will make a nice blog post though! |
Hmm... another thought I just had—I can include a user-provided shell script in the same way, but since it's not an Ansible |
Once you upgrade to 2.0, it would be nice if we removed the That would make it possible to use this repo as a git submodule or otherwise an unmodified tree together with 7e87005 |
Getting extremely close to the finish line here; instead of an ansible playbook, I'm just allowing users to add a list of shell scripts to run after provisioning is complete. I'm already going to use this for a few of my instances where I need to copy Solr search core configuration in place and restart solr as part of setup! |
Woohoo! See the docs for information on how to provide scripts to run post-provision. This is working great, and allows zero, one, or as many shell scripts you want! |
Woo awesome 👍 |
Looks good! Quick question though (I haven't looked at the code yet), do these scripts execute directly on the virtual machine itself, or do they execute on the host to allow the commands to run on the host to affect the virtual machine indirectly? |
@fubarhouse - I added in the example scripts since they were missing—but they execute within the VM. You reference shell scripts present on your host, then those scripts will be run directly on the VM after all the other provisioning steps. |
Excellent, thanks again! |
@geerlingguy is there a reason why |
@cdmo - Mostly so scripts that people would add wouldn't be tracked inside Drupal VM's repo directly—for upstream projects, you probably want to remove that from gitignore (same with a |
The custom script documentation has been moved to http://docs.drupalvm.com/en/latest/extending/scripts/ |
It would be great if a user could add a custom Ansible tasks file (or maybe even extra roles, and we add the
roles
directory to.gitignore
), that would be run if present, ignored if not present.Maybe call it
extra_tasks.yml
and have it included from the project root directory (if present). This isn't supported OOTB by Ansible, but this might be a viable approach (default to an empty file if the extra tasks file isn't present): http://stackoverflow.com/a/29583251/100134The text was updated successfully, but these errors were encountered: