Total Pageviews

Wednesday, May 14, 2025

How to Automate Oracle AHF Upgrade Using Ansible

  In this guide, we’ll walk through creating an Ansible playbook to automate the upgrade process for Oracle Autonomous Health Framework (AHF) across multiple servers.

Step 1: Create the Ansible Playbook on the Master Server

First, create your playbook file on the master (control) server under the following directory:

[root@srv1]# ls -lrth /home/oracle/mypdb/ahfupgrd.yml

 Step 2: Prepare Target Servers

On each target server where AHF needs to be upgraded, create a directory to store the installation files:

[[oracle@srv2]$ mkdir /tmp/ahf_upgrade

 Step 3: Validate and Execute the Playbook

Before executing the playbook, it's a good practice to run a syntax check:

ansible-playbook --syntax-check ahfupgrd.yml

If everything looks good, run the playbook as below:

ansible-playbook ahfupgrd.yml

 

Sample Ansible Playbook: ahfupgrd.yml

 ---
- name: Upgrade Oracle AHF
  hosts: all
  become: yes
  vars:
    ahf_zip: "/tmp/AHF-LINUX_v25.4.0.zip"
    ahf_extract_dir: "/tmp/ahf_upgrade"
    oracle_user: "oracle"
    install_user_home: "/home/oracle"
    ahf_install_command: "/tmp/ahf_upgrade/ahf_setup"
 
  tasks:
    - name: Ensure AHF zip is present
      copy:
        src: "{{ ahf_zip }}"
        dest: "/tmp/AHF-LINUX_v25.4.0.zip"
        owner: "{{ oracle_user }}"
        mode: '0644'
 
    - name: Create extraction directory
      file:
        path: "{{ ahf_extract_dir }}"
        state: directory
        owner: "{{ oracle_user }}"
        mode: '0755'
 
    - name: Extract AHF zip
      unarchive:
        src: "/tmp/AHF-LINUX_v25.4.0.zip"
        dest: "{{ ahf_extract_dir }}"
        remote_src: yes
        owner: "{{ oracle_user }}"
 
    - name: Run AHF upgrade installer
      become_user: "{{ oracle_user }}"
      command: "{{ ahf_install_command }}"
      args:
        chdir: "{{ ahf_extract_dir }}/ahf"
      register: ahf_upgrade_result
 
    - name: Show upgrade output
      debug:
        var: ahf_upgrade_result.stdout
 
    - name: Verify AHF version
      become_user: "{{ oracle_user }}"
      command: "/home/oracle/oracle.ahf/bin/ahfctl version"
      register: ahf_version_check
 
    - name: Output current AHF version
      debug:
        var: ahf_version_check.stdout