Installing MariaDB behind proxy with Ansible

Hi,

with Ansible my plan was and still is, to automate the deployment for around 15 servers with latest Oracle Linux (don’t ask, it’s a requirement) and mariadb.

So far so good and nothing special. One big problem is, that the servers are running in an environment behind a proxy. The proxy should only be active for dnf commands. This is something a got working with every server.
Installing a dedicated mariadb version (11.4) was at first possible too. (See Download MariaDB Server - MariaDB.org)

Long story short: After the first server was installed successfully, all others got an error message, that the repo file could not be downloaded. When installing mariadb with “normal” dnf command on the server itself, no error occures.

Soes somebody have any idea, how I might debug this error? The exact message and the playbook I’ll privide tomorrow from work.

Thanks a lot.

Hi @Marcusc

How did you configure proxy at the system level? DNF should honor proxy set via http(s)_proxy environment variables so you can try this:

- name: Install MariaDB
  ansible.builtin.dnf:
  ...
  environment:
    http_proxy: http://proxy.example.com:8080
    https_proxy: http://proxy.example.com:8080

Hi,

Thanks for your answer.

Yes, I added the proxy to the dnf config file.
But using environment I did not test.

Edit:
I tried the environment change → still the same.
My playbook:

---
- name: Plannet - Installation und Einrichtung MariaDB
  hosts: password-test
  become: true

  environment:
    http_proxy: http://IP:8080
    https_proxy: http://IP:8080

  tasks:
    - name: Ensure proxy is set in dnf.conf
      ansible.builtin.lineinfile:
        path: /etc/dnf/dnf.conf
        line: 'proxy=http://10.127.255.28:8080'
        state: present

    - name: Ensure SSL Check is disabled
      ansible.builtin.lineinfile:
        path: /etc/dnf/dnf.conf
        line: 'sslverify=0'
        state: present

    - name: Update everything
      ansible.builtin.dnf:
        name: "*"
        state: latest
        update_cache: true
        validate_certs: false
      environment:
        http_proxy: http://IP:8080
        https_proxy: http://IP:8080

    - name: Ensure repo list present
      ansible.builtin.blockinfile:
        path: /etc/yum.repos.d/MariaDB.repo
        block: |
          # MariaDB 11.4 RedHatEnterpriseLinux repository list - created 2026-06-08 13:40 UTC
          # https://mariadb.org/download/
          [mariadb]
          name = MariaDB
          # rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
          # baseurl = https://rpm.mariadb.org/11.4/rhel/$releasever/$basearch
          baseurl = https://mirror1.hs-esslingen.de/pub/Mirrors/mariadb/yum/11.4/rhel/$releasever/$basearch
          # gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
          gpgkey = https://mirror1.hs-esslingen.de/pub/Mirrors/mariadb/yum/RPM-GPG-KEY-MariaDB
          gpgcheck = 1
        create: true
        state: present

    - name: Add GPG key of HS Esslingen
      ansible.builtin.rpm_key:
        state: present
        key: https://mirror1.hs-esslingen.de/pub/Mirrors/mariadb/yum/RPM-GPG-KEY-MariaDB
        validate_certs: false

    - name: Install MariaDB
      ansible.builtin.dnf:
        name:
          - MariaDB-server
          - MariaDB-client
        state: present
        validate_certs: false
      environment:
        http_proxy: http://IP:8080
        https_proxy: http://IP:8080

    - name: Check if MariaDB service ist enabled
      ansible.builtin.service:
        name: mariadb
        enabled: yes

    - name: Check if MariaDB service is running
      ansible.builtin.service:
        name: mariadb
        state: started

The exact error:

[ERROR]: Task failed: Module failed: Failed to download metadata for repo ‘mariadb’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Origin: /home/user/ansible/mariadb/playbook.yml:23:7

21 state: present
22
23 - name: Update everything
^ column 7

fatal: [IP]: FAILED! => {“changed”: false, “msg”: “Failed to download metadata for repo ‘mariadb’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried”, “rc”: 1, “results”: }

As your posts don’t mention that you’ve done it. Instead of trying to get ansible working though the proxy, I’d confirm that the system in question has connectivity through the proxy. If you do (or have already done ) that, then you know for sure where the issue lays.

Hi,

Thanks for your answer.
It worked in the past with the posted script.

And the configuration with the proxy set in the dnf.conf file is working. I’m able to install mariadb without any error.

Sorry for not mentioning this fact.

to add some more details.

  • if I install mariadb with sudo dnf install MariaDB-server, it just works without a breeze.
  • Installing the repository with the same proxy worked.

Does anybody have an idea on how I can debug this?

Thanks in advance.