# Uyuni: Configuration management, patch management, and infrastructure installation and management Tool

This article explains how to install and manage Uyuni on **openSUSE Leap Micro 5.5 and above**. The purpose of setting up Uyuni is primarily for **patch management, configuration management, and integrating Ansible control**. Uyuni serves as a centralized management tool, ensuring systems are up-to-date and compliant with organizational standards.

---

## Prerequisites

* **Operating System:** openSUSE Leap Micro 5.5 or higher
    
* **RAM:** 16GB
    
* **CPU:** 4 cores
    
* **Storage:** 1000GB
    

---

## Installation of Uyuni Server on openSUSE

### 1\. Preparation

* Login as `root` and run:
    

```bash
hostnamectl set-hostname uyuni.q21.in
```

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">This is needed as installation will fail without this, and you need this to be pointed from DNS</div>
</div>

```bash
transactional-update shell
```

### 2\. Add Uyuni Repository

```bash
zypper ar https://download.opensuse.org/repositories/systemsmanagement:/Uyuni:/Stable/images/repo/Uyuni-Server-POOL-$(arch)-Media1/ uyuni-server-stable
zypper ref
```

### 3\. Install Uyuni Packages

```bash
zypper in mgradm mgrctl mgradm-bash-completion mgrctl-bash-completion uyuni-storage-setup-server
transactional-update
```

### 4\. Reboot Server

Reboot the server as Uyuni requires a restart to apply changes on Leap Micro.

---

## Installing Podman

After reboot, log in `root` and install Podman:

```bash
sudo mgradm install podman
```

Uyuni is now installed. Access the UI via your browser and set up admin user.

---

## Ports Used by Uyuni

* **80:** HTTP
    
* **443:** HTTPS
    
* **4505:** Salt Communication
    
* **4506:** Salt Communication
    

---

## Setting Up Repositories

### Why This Is Needed

Setting up repositories is essential to ensure that client systems receive the appropriate packages and updates. This is particularly useful for **patch management and configuration management**. Additionally, it integrates well with **Ansible control systems**, allowing for seamless configuration automation.

**Diagram: Uyuni Server Installation Process**

```bash
   +----------------+       +----------------------+        +----------------+    
   | OpenSUSE Leap  | ----->| Add Uyuni Repository | ----->  | Install Uyuni  |  
   | Micro 5.5      |       |   using Zypper       |         | Packages &     |  
   |                |       |                      |         | Podman         |  
   +----------------+       +----------------------+        +----------------+
```

1. Login to Uyuni dashboard: `Softwares > Manage > Channel > Create a Channel`
    
2. Enable repositories via command:
    

```bash
podman ps
podman exec -it <container-id> sh
```

3. To list the available repos
    

```bash
spacewalk-common-channels -l
```

3. Add Ubuntu 22.04 repos:
    

syntax:

```bash
spacewalk-common-channels \
<base_channel_label> \
<child_channel_label_1> \
<child_channel_label_2> \
... <child_channel_label_n>
```

command:

```bash
spacewalk-common-channels -u *** -p '***' -a amd64-deb \
ubuntu-2204-pool-amd64-uyuni ubuntu-2204-amd64-main-uyuni \
ubuntu-2204-amd64-main-updates-uyuni ubuntu-2204-amd64-main-security-uyuni \
ubuntu-2204-amd64-uyuni-client
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1742676242888/1ced9eb7-cda7-4fe9-b296-781e519599d8.jpeg align="center")

You can go to channels and sync the repositories.

---

## Installing `venv-salt-minion` on Ubuntu Clients

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1742676882071/7b744c5d-7dfe-454e-a5e6-863cc0449493.jpeg align="center")

1. Clear machine ID if duplicated:
    

```bash
cat /dev/null > /etc/machine-id
sudo systemd-machine-id-setup
```

2. Remove existing salt-minion service:
    

```bash
sudo rm -rf /etc/salt/minion_id
sudo rm -rf /var/cache/venv-salt-minion/minion
sudo rm -rf /etc/salt/minion.d/*
systemctl stop salt-minion
```

3. Add repository and install:
    

```bash
wget -qO - https://download.opensuse.org/repositories/systemsmanagement:/Uyuni:/Stable:/Ubuntu2204-Uyuni-Client-Tools/xUbuntu_22.04/Release.key | sudo apt-key add -

vim /etc/apt/sources.list
```

Add this line:

```bash
deb https://download.opensuse.org/repositories/systemsmanagement:/Uyuni:/Stable:/Ubuntu2204-Uyuni-Client-Tools/xUbuntu_22.04/ ./
```

4. Install `venv-salt-minion`:
    

```bash
apt update
apt install venv-salt-minion
systemctl enable venv-salt-minion
```

5. Start and restart service:
    

```bash
systemctl start salt-minion
systemctl restart salt-minion
```

---

## Configuration

Edit configuration file:

```bash
vim /etc/venv-salt-minion/minion
```

Add:

```yaml
master: ***.q21.in
grains:
  susemanager:
    activation_key: "fg12***df43"
server_id_use_crc: adler32
enable_legacy_startup_events: False
enable_fqdns_grains: False
```

---

## Changing SSL Certificates

To use your SSL certificates:

```bash
for f in root-cert.pem cert.pem private.key; do
  mgrctl cp $f server:/tmp
done

mgrctl exec -ti -- mgr-ssl-cert-setup --root-ca-file=/tmp/root-cert.pem --server-cert-file=/tmp/cert.pem --server-key-file=/tmp/private.key
```

---

### Ansible Playbook for venv-salt-minion Installation

```yaml
- name: Install and configure venv-salt-minion on Ubuntu 22.04
  hosts: all
  become: yes
  serial: 1
  tasks:

  - name: Clear /etc/machine-id
    command: cat /dev/null > /etc/machine-id

  - name: Regenerate machine-id
    command: systemd-machine-id-setup

  - name: Remove old Salt minion configs
    file:
      path: "{{ item }}"
      state: absent
    loop:
    - /etc/salt/minion_id
    - /var/cache/venv-salt-minion/minion
    - /etc/salt/minion.d/

  - name: Add Uyuni repo key
    apt_key:
      url: https://download.opensuse.org/repositories/systemsmanagement:/Uyuni:/Stable:/Ubuntu2204-Uyuni-Client-Tools/xUbuntu_22.04/Release.key
      state: present

  - name: Add Uyuni repo to sources list
    apt_repository:
      repo: deb https://download.opensuse.org/repositories/systemsmanagement:/Uyuni:/Stable:/Ubuntu2204-Uyuni-Client-Tools/xUbuntu_22.04/ ./
      state: present

  - name: Update APT cache
    apt:
      update_cache: yes

  - name: Install venv-salt-minion
    apt:
      name: venv-salt-minion
      state: present

  - name: Enable venv-salt-minion service
    systemd:
      name: venv-salt-minion
      enabled: yes

  - name: Configure venv-salt-minion
    blockinfile:
      path: /etc/venv-salt-minion/minion
      create: yes
      block: |
        master: ***.q21.in
        grains:
          susemanager:
            activation_key: "fg12***df43"
        server_id_use_crc: adler32
        enable_legacy_startup_events: False
        enable_fqdns_grains: False

  - name: Start venv-salt-minion service
    systemd:
      name: venv-salt-minion
      state: started

  - name: Wait for 2 minutes
    pause:
      minutes: 2

  - name: Restart venv-salt-minion service
    systemd:
      name: venv-salt-minion
      state: restarted
```

---

## Registering Clients with Uyuni

To register Ubuntu clients with Uyuni:

1. **Create Activation Keys:**
    
    * Go to `Systems > Activation Keys > Create Key`.
        
    * Enter a description and select the desired channels.
        
2. **Register the Client:**
    

use previous steps to register the uyuni clients and accept the keys from UI under salt section.

3. **Verify Registration:**
    
    * Check the Uyuni UI under `Systems > Systems List`.
        
    * Ensure the client appears and is properly assigned to the activation key.
        

The client registration process allows Ubuntu systems to receive patches and configuration changes via Uyuni, ensuring centralized management.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1742678216691/da2d2ff1-6d6a-400f-99e9-bca8ff19014e.png align="center")

---

## Best Practices

* **Regularly Update Uyuni Server:** Ensure your Uyuni server is up-to-date to avoid security vulnerabilities.
    
* **Use Activation Keys Efficiently:** Pre-define activation keys to automate client registration.
    
* **Monitor Logs Frequently:** Review logs for errors and unusual behavior.
    
* **Backup Configurations:** Regularly backup configuration files to avoid data loss during updates.
    
* **Test Changes:** Test new configurations on a non-production environment before applying to production servers.
    

---

## Additional Resources

* [Uyuni Documentation](https://www.uyuni-project.org/uyuni-docs/en/uyuni/index.html)
    
* [Salt Documentation](https://www.uyuni-project.org/uyuni-docs/en/uyuni/client-configuration/registration-cli.html)
    
* [Ansible Integration Guide](https://www.uyuni-project.org/uyuni-docs/en/uyuni/administration/ansible-integration.html)
    

---

## My Links

* [GitHub](https://github.com/yogeshgowdagr)
    
* [Blog](https://blogs.q21.in/)
    
* [Portfolio](https://yogesh.q21.in)
    
* [LinkedIn](https://www.linkedin.com/in/yogesh-gowda-gr/)
    
* [Buy Me a Coffee](https://buymeacoffee.com/yogeshgowdq)
    

---

## Conclusion

In this guide, we have covered the installation and configuration of Uyuni on **openSUSE Leap Micro**. We explained the purpose of setting up Uyuni for **patch management, configuration management, and Ansible control integration**. Additionally, we went through the processes of setting up repositories, installing `venv-salt-minion` on Ubuntu clients, configuring SSL certificates, and registering clients. Following the best practices mentioned will ensure a smoother operation of Uyuni in your infrastructure.

If you need any help or have questions, feel free to ask! 😊
