Thanks for the info...I'll definitely try this out :) On Friday, March 3, 2017 at 3:03:33 PM UTC-5, Kai Stian Olstad wrote: > > On 03. mars 2017 19:51, Gilberto Valentin wrote: > > Hello, I am interested in pulling specific data from a table/field and > > apply that data to a .j2 template. For example, if I have a license key > in > > a table on a field called RedHat license, I want to pull that license > value > > and have my .j2 template use it for the creation of an XML template. I > was > > pointed to the lookup plugin ( > > https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/lookup) > > > but there isn't anything there for MySQL. There is one for MongoDB, > though. > > The issue is that I don't know how I would use these plugins and I don't > > know how to write plugins yet or how I would include one for the lookup > > plugin. What would be the best approach in my case? If I need to write > my > > own plugin, is there a document that can guide me on this and how I > would > > incorporate it with lookup? Thanks > > You could use the command module and run an mysql query. > > - name: Run a playbook > command: mysql -u <user> -p<passwd> --silent --skip-column-names > --execute="SELECT <column> FROM <table>" > register: result > > Then you can use the variable result.stdout and/or result.stdout_lines > to get the result. > > (I don't recommend using -p<passwd>, use a option file instead, but > easier to show a -p on the command line) > > -- > Kai Stian Olstad >
-- 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/b4cb273d-8537-4e7e-84c6-dd4fd7a96323%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
