My requirement as follows:
<Resource auth="Container" logAbandoned="true" name="jdbc/InfraForms"
type="javax.sql.DataSource" url="jdbc:jtds:sqlserver://<MY_SERVER_IP>:143;lastUpdateCount=true;useLOBs=false"
username="XXXXX" password="qqqTyIDd7Rd4JahLDjHJH6LvQ=="
testOnBorrow="true" validationQuery="SELECT 1" closeMethod="close"/>
<Manager pathname=""/>
</Context>
Above is the content in one file contact.xml where i need to get value of the password qqqTyIDd7Rd4JahLDjHJH6LvQ==
.
How can I achive that through an Ansible task?
If you wanted to try to use module that are included you could use the slurp module and the set_fact module and with jinja2 you can extract the password using a regex like such:
- name: Slurp file
ansible.builtin.slurp:
src: /your/file
register: passwordfile
- name: Set Password
ansible.builtin.set_fact:
your_password: "{{ passwordfile['content'] | b64decode | regex_findall('\bpassword\b\=\"(.+)\"') }}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With