Below is the task.. I need to connect to host server.. fetch the host name
nad current java version and store it in the database on local server. I am
able to fetch the host name and java version.. but need assistance reading
the sotring the value of variable in DATABASE. Can anyone please suggest
how to proceed with that -
---
- hosts: myserver
tasks:
- name: Get the Host Name
shell: host $(hostname -i) | awk '{print $NF }'|sed 's/\.$//'
register: hosts
- set_fact: the_hosts=hosts.stdout
- debug: var={{the_hosts}}
- name: Fetch Java Version
shell: /opt/app/java/jdk/jdk180_66/64bit/bin/java -version 2>&1 | grep
version | awk '{print $3}' | sed 's/"//g'
register: result
- set_fact: the_count=result.stdout
- debug: var={{the_count}}
- hosts: localhost
tasks:
- debug: var=hostvars['zlp12036']['result']['stdout']
- debug: var=hostvars['zlp12037']['result']['stdout']
- debug: var=hostvars['zlp12036']['hosts']['stdout']
- debug: var=hostvars['zlp12037']['hosts']['stdout']
----------------------------------------------------------------------------------------------------------------------------------------------------------
I am able to get the values under the debug.
Second step is to store the same inside the Database on my local server.
Need information for the same.
--
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/90594b46-1e35-4d59-a7d0-6bdfdc2fefb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.