--- # Playbook: ora_standalone_patch.yml # Usage: ansible-playbook playbooks/ora_standalone_patch.yml -e "server=togoria oracle_sid=NABOOPRD opatch_zip=/mnt/yavin4/kit/Oracle/opatch/p6880880_190000_Linux-x86-64.zip dbru_zip=/mnt/yavin4/kit/Oracle/Oracle_Database_19/patch/GIRU_19.29/p38298204_190000_Linux-x86-64.zip" - name: Gather facts for a specific inventory host hosts: "{{ server }}" gather_facts: yes become: true become_user: oracle become_method: su pre_tasks: - name: Ensure 'server' variable is provided assert: that: server is defined fail_msg: "Please provide the server via -e 'server='" - name: Ensure 'oracle_sid' variable is provided assert: that: oracle_sid is defined fail_msg: "Please provide the oracle_sid via -e 'oracle_sid='" - name: Ensure 'opatch_zip' variable is provided assert: that: opatch_zip is defined fail_msg: "Please provide the opatch_zip via -e 'opatch_zip='" - name: Ensure 'dbru_zip' variable is provided assert: that: dbru_zip is defined fail_msg: "Please provide the dbru_zip via -e 'dbru_zip='" tasks: - name: Show selected system facts debug: msg: hostname: "{{ (ansible_facts.nodename | default(ansible_facts.hostname)) | default('unknown') }}" os_family: "{{ ansible_facts.os_family | default(ansible_facts.distribution | default('unknown')) }}" operating_system: "{{ ansible_facts.distribution | default('unknown') }} {{ ansible_facts.distribution_version | default('') }}" ip_address: "{{ ansible_default_ipv4.address | default('unknown') }}" hardware_model: "{{ ansible_facts['machine'] | default('unknown') }}" cpu_count: "{{ ansible_facts['processor_vcpus'] | default(ansible_facts['processor_count'] | default('unknown')) }}" ram_gb: "{{ (ansible_facts['memtotal_mb'] / 1024) | int | default('unknown') }}" - name: Source oraenv and display OPatch informations shell: | . oraenv <<< {{ oracle_sid }} && $ORACLE_HOME/OPatch/opatch version && echo && echo && $ORACLE_HOME/OPatch/opatch lspatches register: opatch_output when: oracle_sid is defined - name: Display OPatch directory contents debug: var: opatch_output.stdout_lines when: oracle_sid is defined # - name: Remove /app/oracle/staging_area if present # file: # path: /app/oracle/staging_area # state: absent # - name: Recreate /app/oracle/staging_area # file: # path: /app/oracle/staging_area # state: directory # mode: '0755' # - name: Check local zip path exists on controller (only if provided) # stat: # path: "{{ dbru_zip }}" # delegate_to: localhost # run_once: true # register: local_zip_stat # when: dbru_zip is defined # - name: Fail if local zip file not found on controller # fail: # msg: "Local zip file {{ dbru_zip }} not found on controller" # when: dbru_zip is defined and (local_zip_stat.stat is not defined or not local_zip_stat.stat.exists) # run_once: true # - name: Copy local zip file to remote staging_area # copy: # src: "{{ dbru_zip }}" # dest: "/app/oracle/staging_area/{{ dbru_zip | basename }}" # mode: '0644' # when: dbru_zip is defined # - name: Unarchive uploaded zip into staging_area # unarchive: # src: "/app/oracle/staging_area/{{ dbru_zip | basename }}" # dest: /app/oracle/staging_area # remote_src: yes # when: dbru_zip is defined # - name: Remove uploaded zip from remote staging_area # file: # path: "/app/oracle/staging_area/{{ dbru_zip | basename }}" # state: absent # when: dbru_zip is defined