- name: Weblogic Version hosts: docker tasks: - shell: source /u01/weblogic/domains/osb/bin/setDomainEnv.sh && java weblogic.version ignore_errors: yes register: uname_result # En una misma lĂnea - debug: msg="{{ uname_result.stdout }}" # En lineas separadas - debug: msg="{{ uname_result.stdout_lines }}"
osb.yml
- hosts: osb vars: wls_user: weblogic wls_group: weblogic wls_scripts: /u01/weblogic/scrics wls_home: /u01/weblogic/mid12212 wls_domains: /u01/weblogic/domains osb_domain_name: osb osb_admin_user: weblogic osb_admin_pass: weblogic01 osb_cluster_nodes: - managed_name: 'osb_1' - managed_name: 'osb_2' - managed_name: 'osb_3' tasks: - name: Creacion dominio template: src={{ item.file }} dest={{ item.dest }} mode={{ item.mode }} owner={{ wls_user }} group={{ wls_group }} with_items: - { file: "osb.sh.j2", dest: "{{ wls_scripts }}/osb.sh", mode: '0700' } tags: template
osb.sh.j2
#!/bin/bash {{ wls_home }}/oracle_common/common/bin/wlst.sh << EOF createDomain("{{ wls_home }}/wlserver/common/templates/wls/wls.jar","{{ wls_domains }}/{{ osb_domain_name }}","{{ osb_admin_user }}","{{ osb_admin_pass }}") readDomain("{{ wls_domains }}/{{ osb_domain_name }}") #selectTemplate('Oracle Service Bus','12.2.1.3.0') #loadTemplates() cd('/') set('ProductionModeEnabled',true) {% for node in osb_cluster_nodes %} cd('/') create('Server','{{ node.managed_name }}') {% endfor %} updateDomain() exit() EOF
ejecutamos:
ansible-playbook osb.yml
Nos genera el servidor destino:
osb.sh
- hosts: osb vars: wls_user: weblogic wls_group: weblogic wls_scripts: /u01/weblogic/scrics wls_home: /u01/weblogic/mid12212 wls_domains: /u01/weblogic/domains osb_domain_name: osb osb_admin_user: weblogic osb_admin_pass: weblogic01 osb_cluster_nodes: - managed_name: 'osb_1' - managed_name: 'osb_2' - managed_name: 'osb_3' tasks: - name: Creacion dominio template: src={{ item.file }} dest={{ item.dest }} mode={{ item.mode }} owner={{ wls_user }} group={{ wls_group }} with_items: - { file: "osb.sh.j2", dest: "{{ wls_scripts }}/osb.sh", mode: '0700' } tags: template