mk-ansible-roles.subscribe-repos

subscribe-repos

This playbook sets up a RHEL server to get updates from a reposync server. First, register your server with RHN on the reposync server, then run the script below as a cron job (or use the setup-reposerver role):

#!/bin/bash

SERVERIP=1.2.3.4 ## update this with your server's IP

cd /var/www/html/repos

# Sync the Repositories (either full or diff)
reposync -n -d -l --downloadcomps --download-metadata

# For each directory, create the repo
ls -l | grep ^d | awk '{print $9}' | while read dirs; do
  echo $dirs
  if [ -f ${dirs}/comps.xml ]; then
     createrepo -v ${dirs}/ -g comps.xml
  else
     createrepo -v ${dirs}/
  fi

  rf=/var/www/html/repofiles/${dirs}.repo
  echo "[$dirs]" > $rf
  echo "name=$dirs" >> $rf
  echo "baseurl=http://${SERVERIP}/repos/$dirs/" >> $rf
  echo "enabled=1" >> $rf
  echo "gpgcheck=0" >> $rf

done

This role should be one of the first to run after installing the base system to set up the repositories.

Requirements

To use this role, you need a properly configured repo server as described above that serves the repositories.

Role Variables

You can set the following variables in your playbook:

  • reposrvurl: URL pointing to the directory where the repo files are located, e.g., rhel-7-server-rpms.repo
    Example:

    reposrvurl: http://$SERVERIP/repofiles/
    
  • repo_reset: Set to true if you want to remove or disable all previously existing repositories. Default is false:

    repo_reset: true
    
  • repositories: Use this to specify the list of repositories you want to subscribe to:

    repositories:
        - rhel-7-server-rpms
        - repo2
        - repo3
    

Example Playbook

Here’s an example playbook that adds two repositories on the clients (hosts in group clients) and disables all previously set repositories. The repository server that contains the repo files is set in reposrvurl:

- hosts: clients
  remote_user: root

  vars:
      reposrvurl: http://myserver.lan/repofiles/
      repo_reset: true
      repositories:
          - rhel-7-server-rpms
          - rhel-sap-hana-for-rhel-7-server-rpms

  roles:
     - { role: mk-ansible-roles.subscribe-repos }

License

Apache License
Version 2.0, January 2004

Author Information

Markus Koch

Please leave comments in the GitHub repo issue list.

Informazioni sul progetto

subscribe repositories from reposync server

Installa
ansible-galaxy install mk-ansible-roles.subscribe-repos
Licenza
apache-2.0
Download
71
Proprietario