Sorry to reply to myself, but I checked and (with the meta pattern on 1.9.x at least), the kibana role _will_ be able to trigger the handlers defined in the apache role. Which is nice.
On 14 July 2016 at 22:17, Dick Davies <[email protected]> wrote: > Right, let me check I get the requirement - > so for example we're talking about say an 'apache' role and a 'kibana' > role that's going to need a vhost setup. > > (with ansible 1.9 at least), if I set a vhost_conf_dir var in my > apache role (which is a path to a directory you can drop .vhost files > into to have them auto-included, nginx etc. has a similar feature) and > then have my kibana role list 'apache' as a dependency in its > meta/main.yml, it will be able to see that var and use it. > > Another way is to explicitly set a 'global' (play wide or host wide, > point is its set external to the roles ) vhost_conf_dir and have each > role use it (that's less 'magical' so personally I prefer it, it's > easier to see what's going on). > > One downside is the 'kibana' role needs handlers to restart the > webserver, which is a bit ugly. > > Either way, you're going to have 2 roles that are co-dependant and not > too re-usable. That would > still be the case if you had the exact feature you describe, of course. > > I'm of the opinion that 'role reuse' is a wild goose chase in CM > systems, so I'm fine with that :) > > On 14 July 2016 at 21:19, Neubyr N <[email protected]> wrote: >> >> Thank you for the details. I am wondering how to pass file name in one role >> to another role as variable parameter. >> >> As mentioned in previous post, take example of configuring webserver for a >> particular application. webserver setup remains same for multiple >> applications except configuration file. So if we develop a webserver role >> that accepts file path parameter, then same webserver role could be reused >> by other application roles. Now it makes sense to keep application specific >> webserver configuration file inside application role and pass it's path to >> webserver role. This helps in keeping all application specific configuration >> files inside a single role. >> >> If Ansible had some roles path variable or special path 'role', then it >> would make above pattern easy. So we could say something like >> src=ROLES/myapp/files/testfile . >> >> It seems like that is not possible with Ansible. >> >> - N >> >> >> On Thursday, July 14, 2016 at 7:10:54 AM UTC-7, Dick Davies wrote: >>> >>> On 13 July 2016 at 22:09, Neubyr N <[email protected]> wrote: >>> > >>> >Right now file name >>> > passed to the webserver role is relative path from the playbook file. Is >>> > there any way to make this path independent of playbook location and >>> > reference it using role directory? >>> >>> Yes - if you have tasks in a role 'thingy' like this: >>> >>> - name: config >>> copy: src=etc/file.conf >>> dest=/etc/file.conf >>> >>> - name: more config >>> template: src=etc/file2.conf.j2 >>> dest=/etc/file2.conf >>> >>> >>> then >>> >>> * the copy task will load its source file from >>> roles/thingy/files/etc/file.conf >>> * the template task will load its template from >>> roles/thingy/templates/etc/file2.conf.j2 -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAK5eLPSwgE97%2B5crEp6XANLu4N%3DL34KMGz7DoFyBE6xS4vwOnA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
