from pyinfra.operations import zypper# Update package list and install packageszypper.packages( name="Install Vim and Vim enhanced", packages=["vim-enhanced", "vim"], update=True,)
baseurl, description, gpgcheck, and gpgkey are only valid when src is a filename (not a URL). Use a URL to download and install remote repository files.
from pyinfra.operations import zypper# Download a repository filezypper.repo( name="Install container virtualization repo via URL", src="https://download.opensuse.org/repositories/Virtualization:containers/openSUSE_Tumbleweed/Virtualization:containers.repo",)
from pyinfra.operations import zypperzypper.rpm( name="Install task from rpm", src="https://github.com/go-task/task/releases/download/v2.8.1/task_linux_amd64.rpm",)
from pyinfra.operations import zypperzypper.packages( name="Install web server stack", packages=[ "nginx", "php", "php-fpm", "mariadb", ], update=True,)
openSUSE uses patterns for installing groups of related packages:
from pyinfra.operations import zypper# Install development patternzypper.packages( name="Install development pattern", packages=["devel_basis", "devel_C_C++"],)
Repository Management
List and manage repositories:
from pyinfra.operations import server# List repositoriesserver.shell( name="List repositories", commands=["zypper repos"],)# Refresh repositoriesserver.shell( name="Refresh repositories", commands=["zypper refresh"],)
Package Locks
Lock packages to prevent updates:
from pyinfra.operations import server# Lock a packageserver.shell( name="Lock kernel package", commands=["zypper addlock kernel-default"],)# Unlock a packageserver.shell( name="Unlock kernel package", commands=["zypper removelock kernel-default"],)
Distribution Upgrade
Upgrade to a new openSUSE version:
from pyinfra.operations import server# Distribution upgradeserver.shell( name="Upgrade distribution", commands=["zypper dup --no-confirm"],)