Hi Brian, I've written a Python module in a role using data that I'm going to change from time to time. That's why I wanted to separate the Python code from its data, I manually wrote it in a YAML file. I naively thought the "files" directory of the role would be the best place to keep it, but don't know how to access it from the running Python module.
If it's not obvious, maybe I should keep data into the Python code of the module even if I don't feel it very clean (list of 80+ dictionaries)... On Wednesday, June 3, 2015 at 6:53:44 PM UTC+2, Brian Coca wrote: > > modules do not access local files on the master (unless running with > localhost target/local_action/etc) in the case of copy, it's > action_plugin is the one doing this, then copying the file remotely so > the copy module can use it. > > On Wed, Jun 3, 2015 at 5:03 AM, <[email protected] <javascript:>> wrote: > > Thank you for your reply. > > > > As I wrote, I've created a Python module. I now access files in "files" > > directory through absolute path, but I would like to be more flexible, > > staying in the role directory. > > > > My question is: How do I write, in Python, access to a file in > > "files"directory"? > > > > > > > > On Monday, June 1, 2015 at 2:44:21 PM UTC+2, Шалыгин Константин wrote: > >> > >> Any file in files can used ai is, like > >> - name: Copy files > >> copy: src='my_file.yml' dest='/etc/' group='root' owner='root' > >> mode='0644' > >> > >> If u catch some vars from thist yml, just place it on my_role/vars dir. > >> > >> > >> > >> On Monday, June 1, 2015 at 1:35:20 PM UTC+6, [email protected] wrote: > >>> > >>> Hello, > >>> > >>> I've created a role with its main task using my Python module that > should > >>> access a yaml file located in files dir of the role: > >>> > >>> roles > >>> my_role > >>> tasks > >>> main.yml > >>> library > >>> my_module > >>> files > >>> my_file.yml > >>> > >>> From my_module (Python), how can I access my_file.yml without absolute > >>> path? I would like something as "files/my_file.yml", does this exists? > >>> > > -- > > 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] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/ansible-project/b8dc1366-0c5c-4c8a-a0de-8b23b6ec392b%40googlegroups.com. > > > > > > For more options, visit https://groups.google.com/d/optout. > > > > -- > Brian Coca > -- 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/fb0ed18a-0306-4e13-96ba-e0255da42081%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
