-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #517 from erzetpe/feature/offline-mode
Add scripts and repository role for setup and teardown
- Loading branch information
Showing
17 changed files
with
269 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
core/src/epicli/data/common/ansible/playbooks/repository-setup.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
# Ansible playbook for disabling/enabling repositories before/after Epiphany installation | ||
|
||
- hosts: all | ||
pre_tasks: | ||
- name: Set mode to setup | ||
set_fact: | ||
repository_mode: setup | ||
become: true | ||
become_method: sudo | ||
roles: | ||
- repository |
12 changes: 12 additions & 0 deletions
12
core/src/epicli/data/common/ansible/playbooks/repository-teardown.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
# Ansible playbook for disabling/enabling repositories before/after Epiphany installation | ||
|
||
- hosts: all | ||
pre_tasks: | ||
- name: Set mode to teardown | ||
set_fact: | ||
repository_mode: teardown | ||
become: true | ||
become_method: sudo | ||
roles: | ||
- repository |
36 changes: 36 additions & 0 deletions
36
...a/common/ansible/playbooks/roles/repository/files/Debian/scripts/create-repository-deb.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
PACKAGE_LIST=$(cat /root/deb-package-list.txt) | ||
DOWNLOAD_DIRECTORY=/root/packages | ||
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; | ||
|
||
apt install -y apache2 reprepro; | ||
systemctl start apache2 | ||
apt clean; | ||
|
||
|
||
mkdir -p $REPOSITORY_PATH; | ||
mkdir -p $REPOSITORY_PATH/conf; | ||
|
||
cat << EOF > $REPOSITORY_PATH/conf/distributions | ||
Origin: epiphany.offline.repo | ||
Label: epiphany.offline.repo | ||
Codename: bionic | ||
Architectures: i386 amd64 | ||
Components: main restricted universe multiverse | ||
Description: Epiphany Offline Repository | ||
EOF | ||
|
||
for package in $PACKAGE_LIST ; do | ||
echo "$package:" | tee $LOG_FILE; | ||
apt-get install -y --download-only $package | tee $LOG_FILE ; | ||
done | ||
|
||
reprepro --basedir $REPOSITORY_PATH includedeb bionic /var/cache/apt/archives/*.deb; | ||
|
14 changes: 14 additions & 0 deletions
14
...a/common/ansible/playbooks/roles/repository/files/Debian/scripts/setup-repo-client-deb.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
SERVER_IP=$1; | ||
DATE=`date +%Y.%m.%d-%H.%M.%S`; | ||
|
||
curl -I -L $SERVER_IP/repos | grep "HTTP/1.1 200 OK"; | ||
|
||
cp /etc/apt/sources.list /etc/apt/sources.list.bak_$DATE; | ||
echo "deb [trusted=yes] http://$SERVER_IP/repos/ bionic main" > /etc/apt/sources.list; | ||
|
||
apt-cache policy; | ||
|
||
apt update; | ||
|
22 changes: 22 additions & 0 deletions
22
...rc/epicli/data/common/ansible/playbooks/roles/repository/files/RedHat/rh-package-list.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
libselinux-python | ||
libsemanage-python | ||
firewalld | ||
bash-completion | ||
ca-certificates | ||
net-tools | ||
tar | ||
nmap-ncat | ||
curl | ||
tmux | ||
fping | ||
iftop | ||
htop | ||
vim-enhanced | ||
sysstat | ||
python-setuptools | ||
openssl | ||
yum-plugin-versionlock | ||
logrotate | ||
ebtables | ||
ethtool | ||
telnet |
33 changes: 33 additions & 0 deletions
33
...ta/common/ansible/playbooks/roles/repository/files/RedHat/scripts/create-repository-rh.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
PACKAGE_LIST=$(cat $1) | ||
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; | ||
|
||
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 | ||
|
||
setenforce 0; | ||
systemctl start httpd; | ||
|
||
createrepo $REPOSITORY_PATH; | ||
|
||
|
6 changes: 6 additions & 0 deletions
6
...mmon/ansible/playbooks/roles/repository/files/RedHat/scripts/disable-epirepo-client-rh.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
yum-config-manager --disable epirepo*; | ||
yum makecache; | ||
yum repolist; | ||
|
4 changes: 4 additions & 0 deletions
4
...a/common/ansible/playbooks/roles/repository/files/RedHat/scripts/disable-repository-rh.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
systemctl stop httpd; | ||
systemctl disable httpd; |
9 changes: 9 additions & 0 deletions
9
...ta/common/ansible/playbooks/roles/repository/files/RedHat/scripts/disable-system-repos.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
REPOS_LIST_FILE=/tmp/enabled-system-repos.txt | ||
|
||
cat $REPOS_LIST_FILE | while read line | ||
do | ||
echo $line; | ||
yum-config-manager --disable $line; | ||
done | ||
|
9 changes: 9 additions & 0 deletions
9
...ata/common/ansible/playbooks/roles/repository/files/RedHat/scripts/enable-system-repos.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
REPOS_LIST_FILE=/tmp/enabled-system-repos.txt | ||
|
||
cat $REPOS_LIST_FILE | while read line | ||
do | ||
echo $line; | ||
yum-config-manager --enable $line; | ||
done | ||
|
4 changes: 4 additions & 0 deletions
4
...laybooks/roles/repository/files/RedHat/scripts/generate-enabled-system-repository-list.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ENABLED_REPOS_FILE=/tmp/enabled-system-repos.txt | ||
if [ test ! -f "$ENABLED_REPOS_FILE" ]; then | ||
yum repolist -v enabled | grep -i Repo-id | awk -F ":" '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | awk -F "/" '{print $1}' > $ENABLED_REPOS_FILE; | ||
fi |
20 changes: 20 additions & 0 deletions
20
...common/ansible/playbooks/roles/repository/files/RedHat/scripts/setup-epirepo-client-rh.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
SERVER_IP=$1; | ||
|
||
curl -I -L $SERVER_IP/repos | grep "HTTP/1.1 200 OK"; | ||
|
||
sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/*.repo; | ||
|
||
cat << EOF > /etc/yum.repos.d/epirepo.repo | ||
[epirepo] | ||
name=epirepo | ||
baseurl=http://$SERVER_IP/repos/ | ||
enabled=1 | ||
gpgcheck=0 | ||
EOF | ||
|
||
yum-config-manager --enable epirepo*; | ||
yum makecache; | ||
yum repolist; | ||
|
15 changes: 15 additions & 0 deletions
15
core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
|
||
- name: Copy data files | ||
copy: | ||
src: "{{ ansible_os_family }}/" | ||
dest: "/tmp/{{ ansible_os_family }}" | ||
|
||
- name: Copy repository configuration scripts | ||
copy: | ||
src: "{{ ansible_os_family }}/scripts/" | ||
dest: "/tmp/{{ ansible_os_family }}" | ||
mode: a+x | ||
|
||
- name: Configure repository and clients RedHat | ||
include_tasks: "{{ repository_mode }}-{{ ansible_os_family }}.yml" |
32 changes: 32 additions & 0 deletions
32
core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/setup-RedHat.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
|
||
- name: Copy data files | ||
copy: | ||
src: "{{ ansible_os_family }}/" | ||
dest: "/tmp/{{ ansible_os_family }}" | ||
|
||
- name: Copy repository configuration scripts | ||
copy: | ||
src: "{{ ansible_os_family }}/scripts/" | ||
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 | ||
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 | ||
when: | ||
- not groups['kubernetes_master'][0] == inventory_hostname | ||
|
||
- 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 |
11 changes: 11 additions & 0 deletions
11
core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown-RedHat.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
|
||
- name: Enable system repositories | ||
shell: /tmp/{{ ansible_os_family }}/enable-system-repos.sh | ||
when: | ||
- not groups['kubernetes_master'][0] == inventory_hostname | ||
|
||
- name: Disable epirepo on clients | ||
shell: /tmp/{{ ansible_os_family }}/disable-epirepo-client-rh.sh | ||
when: | ||
- not groups['kubernetes_master'][0] == inventory_hostname |