Execution
Date 11 Mar 2026 17:11:46 +0000
Duration 00:00:01.09
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.13
ara 1.7.4 / 1.7.4
Python 3.10.10
Summary
0 Hosts
1 Tasks
0 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/RM10320-replace-repo-urls.yaml

---
- name: Update MariaDB repository URL and GPG key
  hosts: all
  gather_facts: false
  vars:
    repo_file: "/etc/yum.repos.d/mariadb.repo"
    backup_file: "{{ repo_file }}.backup"
  tasks:
    - name: Ensure MariaDB repo file exists
      ansible.builtin.stat:
        path: "{{ repo_file }}"
      register: file_check
    - name: Fail if repo file missing
      ansible.builtin.fail:
        msg: "MariaDB repo file not found at {{ repo_file }}"
      when: not file_check.stat.exists
    - name: Create backup before making changes
      ansible.builtin.copy:
        src: "{{ repo_file }}"
        dest: "{{ backup_file }}"
        remote_src: true
        mode: preserve
      register: backup
    - name: Update repository URLs
      ansible.builtin.replace:
        path: "{{ repo_file }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      loop:
        - regexp: 'baseurl\s*=\s*http://yum\.mariadb\.org/10\.6/rhel8-amd64'
          replace: 'baseurl = https://rpm.mariadb.org/10.6/rhel/$releasever/$basearch'
        - regexp: 'gpgkey\s*=\s*https://yum\.mariadb\.org/RPM-GPG-KEY-MariaDB'
          replace: 'gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB'
      register: updates
    - name: Show summary
      ansible.builtin.debug:
        msg:
          - "Host: {{ inventory_hostname }}"
          - "Backup: {{ backup.dest }}"
          - "Changes made:"
          - "  - BaseURL: {{ 'Yes' if updates.results[0].changed else 'No' }}"
          - "  - GPGKey: {{ 'Yes' if updates.results[1].changed else 'No' }}"