Reputation: 61
- name: Get names for all running Oracle databases from oratab file
slurp:
src: /etc/oratab
register: oracle_patch_oratab
- name: Extract a list of DBs which mataches the Oracle Home
set_fact:
oracle_patch_dblist: "{{ oracle_patch_oratab['content'] | b64decode | regex_findall ('(.+v12201.+)', multiline=True, ignorecase=True) }}"
In regex_findall I have hard-coded a value as v12201 and I would like to replace that with variable. If so, what would be the syntax to be used within regex_findall? Thanks in advance.
Upvotes: 2
Views: 1396
Reputation: 61
I tried the following method, it works fine.
- name: Get names for all running Oracle databases from oratab file
slurp:
src: /etc/oratab
register: oracle_patch_oratab
- name: "assign pattern"
set_fact:
ora_ver: "12201"
- name: Extract a list of DBs which mataches the Oracle Home
set_fact:
oracle_patch_dblist: "{{ oracle_patch_oratab['content'] | b64decode | regex_findall ('(.+' + ora_ver | string + '.+)', multiline=True, ignorecase=True) }}"
Upvotes: 2