Мое требование - прочитать файл tnsnames.ora и получить имена его схем в списке переменных.Также нужно, чтобы они добавили в шаблон.
Я могу сопоставить требуемые имена схем из файла tnsnames.ora ( Соответствие ).но в ansible я не уверен, как сохранить все подходящие слова в списке переменных.Благодарим вас за помощь в поиске разрешения.
- name: Lookup "{{ ansible_env.TNS_ADMIN }}/tnsnames.ora"
slurp:
src: "{{ ansible_env.TNS_ADMIN}}/tnsnames.ora"
register: contents
- set_fact: matches="{{ contents['content'] | b64decode|regex_search(reg_pattern) |list|join("")}}"
- debug: msg="{{ item }}"
with_items:
- "{{ matches }}"
Ниже приведен шаблон регулярных выражений, который помогает мне получать только имена схем.
reg_pattern: '^([^#()\W ][a-zA-Z.]*(?:[.][a-zA-Z]*\s?=)?)((\d*[a-zA-Z]*|(\0*)))'
Ниже приведен мой файл tnsnames.ora.
abcdsvsurv = ( DESCRIPTION =
(FAILOVER = ON)
(ENABLE=BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.43.165)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = survdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 30)
(DELAY = 5)
)
)
)
abcdsvsg = ( DESCRIPTION =
(FAILOVER = ON)
(ENABLE=BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.43.165)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = survdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 2)
)
)
)
abcdsvser = ( DESCRIPTION =
(FAILOVER = ON)
(ENABLE=BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.43.165)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = survdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 2)
)
)
)
abcdsvmtech = ( DESCRIPTION =
(FAILOVER = ON)
(ENABLE=BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.43.165)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = survdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 2)
)
)
)
abcdsvyaan = ( DESCRIPTION =
(FAILOVER = ON)
(ENABLE=BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.43.165)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = survdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 2)
)
)
)
abcdsvmrs = ( DESCRIPTION =
(FAILOVER = ON)
(ENABLE=BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.43.165)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = survdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 2)
)
)
)
fltsurv03 = ( DESCRIPTION =
(FAILOVER = ON)
(ENABLE=BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.43.165)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = survdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 30)
(DELAY = 5)
)
)
)
fltsurvsg03 = ( DESCRIPTION =
(FAILOVER = ON)
(ENABLE=BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.43.165)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = survdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 2)
)
)
)
fltsurvser03 = ( DESCRIPTION =
(FAILOVER = ON)
(ENABLE=BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.43.165)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = survdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 2)
)
)
)
fltsurvmtech03 = ( DESCRIPTION =
(FAILOVER = ON)
(ENABLE=BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.43.165)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = survdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 2)
)
)
)
fltsurvyaan03 = ( DESCRIPTION =
(FAILOVER = ON)
(ENABLE=BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.43.165)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = survdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 2)
)
)
)
fltsurv03surv = ( DESCRIPTION =
(FAILOVER = ON)
(ENABLE=BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.43.165)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = survdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 30)
(DELAY = 5)
)
)
)
fltsurvmrs03 = ( DESCRIPTION =
(FAILOVER = ON)
(ENABLE=BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.43.165)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = survdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 2)
)
)
)