Skip to content

Commit

Permalink
Add offline/online mode for Red Hat (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
erzetpe authored Sep 23, 2019
1 parent 004fd70 commit cc00b03
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
#!/bin/bash

PACKAGE_LIST=$(cat $1)
LOG_FILE=/root/script-execution.log
EPIPHANY_FILES_LOCATION=$1;
OFFLINE_MODE=$2;
LOG_FILE=/root/script-execution.log;

WWW_SERVER_PATH=/var/www/html;

REPOSITORY_PATH=$WWW_SERVER_PATH/repos;
FILES_PATH=$WWW_SERVER_PATH/files;
IMAGES_PATH=$WWW_SERVER_PATH/images;
if $OFFLINE_MODE = true;
then
rpm -i $EPIPHANY_FILES_LOCATION/offline_prereqs/*.rpm;
else
yum install -y httpd createrepo yum-utils;
fi

mkdir -p $WWW_SERVER_PATH;
mkdir -p $REPOSITORY_PATH;
mkdir -p $FILES_PATH;
mkdir -p $IMAGES_PATH;

yum install -y httpd createrepo yum-utils;

for package in $PACKAGE_LIST ; do
echo "========== $package =========" | tee $LOG_FILE;
repoquery -a --qf '%{ui_nevra}' $package;
repoquery -a --qf '%{ui_nevra}' $package | xargs yumdownloader --destdir $REPOSITORY_PATH | tee $LOG_FILE;
echo "========== $package - dependencies =========" | tee $LOG_FILE;
repoquery -R --resolve -a --qf '%{ui_nevra}' $package;
repoquery -R --resolve -a --qf '%{ui_nevra}' $package | xargs yumdownloader --destdir $REPOSITORY_PATH | tee $LOG_FILE;
done
mv $EPIPHANY_FILES_LOCATION/* $WWW_SERVER_PATH;

setenforce 0;
systemctl start httpd;

createrepo $REPOSITORY_PATH;


Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
---

- name: Copy local packages
copy:
src: /tmp/epiphany_install
dest: /tmp/
directory_mode: yes
when:
- offline_mode == true
- groups['kubernetes_master'][0] == inventory_hostname

- name: Copy data files
copy:
src: "{{ ansible_os_family }}/"
Expand All @@ -11,22 +20,30 @@
dest: "/tmp/{{ ansible_os_family }}"
mode: a+x

- name: Download packages and create repository
shell: /tmp/{{ ansible_os_family }}/create-repository-rh.sh /tmp/{{ ansible_os_family }}/rh-package-list.txt
- name: Create epirepo repository
shell: /tmp/{{ ansible_os_family }}/create-repository-rh.sh /tmp/epiphany_install {{ offline_mode }}
when:
- groups['kubernetes_master'][0] == inventory_hostname

- name: Create active repositories list
shell: /tmp/{{ ansible_os_family }}/generate-enabled-system-repository-list.sh
when:
- not groups['kubernetes_master'][0] == inventory_hostname

- name: Disable active system repositories
shell: /tmp/{{ ansible_os_family }}/disable-system-repos.sh
- name: Disable system repositories and setup epirepo for offline mode
block:
- name: Create active repositories list
shell: /tmp/{{ ansible_os_family }}/generate-enabled-system-repository-list.sh
- name: Disable active system repositories
shell: /tmp/{{ ansible_os_family }}/disable-system-repos.sh
- name: Setup epirepo on clients
shell: /tmp/{{ ansible_os_family }}/setup-epirepo-client-rh.sh {{ groups['kubernetes_master'][0] }}
when:
- not groups['kubernetes_master'][0] == inventory_hostname
- offline_mode == true

- name: Setup epirepo on clients
shell: /tmp/{{ ansible_os_family }}/setup-epirepo-client-rh.sh {{ groups['kubernetes_master'][0] }}
- name: Disable system repositories and setup epirepo for online mode
block:
- name: Create active repositories list
shell: /tmp/{{ ansible_os_family }}/generate-enabled-system-repository-list.sh
- name: Disable active system repositories
shell: /tmp/{{ ansible_os_family }}/disable-system-repos.sh
- name: Setup epirepo on clients
shell: /tmp/{{ ansible_os_family }}/setup-epirepo-client-rh.sh {{ groups['kubernetes_master'][0] }}
when:
- not groups['kubernetes_master'][0] == inventory_hostname
- not groups['kubernetes_master'][0] == inventory_hostname
- offline_mode == false
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
---

- name: Enable system repositories
shell: /tmp/{{ ansible_os_family }}/enable-system-repos.sh
- name: Enable system repositories and disable epirepo for offline mode
block:
- name: Enable system repositories
shell: /tmp/{{ ansible_os_family }}/enable-system-repos.sh
- name: Disable epirepo on clients
shell: /tmp/{{ ansible_os_family }}/disable-epirepo-client-rh.sh
when:
- not groups['kubernetes_master'][0] == inventory_hostname
- offline_mode == true

- name: Disable epirepo on clients
shell: /tmp/{{ ansible_os_family }}/disable-epirepo-client-rh.sh
- name: Disable system repositories and setup epirepo for online mode
block:
- name: Enable system repositories
shell: /tmp/{{ ansible_os_family }}/enable-system-repos.sh
- name: Disable epirepo on clients
shell: /tmp/{{ ansible_os_family }}/disable-epirepo-client-rh.sh
when:
- not groups['kubernetes_master'][0] == inventory_hostname
- not groups['kubernetes_master'][0] == inventory_hostname
- offline_mode == false

0 comments on commit cc00b03

Please sign in to comment.