From e4f8e104ddeaa4d5137348edd3076adfe81b7906 Mon Sep 17 00:00:00 2001 From: lukurde <47138492+lukurde@users.noreply.github.com> Date: Thu, 17 Oct 2019 10:13:01 +0200 Subject: [PATCH] hotfixes for ubuntu offline installation in air-gap mode (#613) * hotfixes for ubuntu offline installation in air-gap mode * agh * changelog updated * changelog updated * changelog updated --- CHANGELOG-0.4.md | 6 ++++ .../ubuntu-18.04/common.sh | 7 ++--- .../files/server/Debian/create-repository.sh | 30 +++++++++++++------ .../roles/repository/tasks/Debian/setup.yml | 10 ++++++- .../roles/repository/tasks/RedHat/setup.yml | 1 - .../roles/repository/tasks/teardown.yml | 3 +- 6 files changed, 40 insertions(+), 17 deletions(-) diff --git a/CHANGELOG-0.4.md b/CHANGELOG-0.4.md index 6bfb41f44d..a47bb73b1f 100644 --- a/CHANGELOG-0.4.md +++ b/CHANGELOG-0.4.md @@ -1,5 +1,11 @@ # Changelog 0.4 +## [0.4.1] 2019-10-17 + +### Fixed + +- [#613](https://github.com/epiphany-platform/epiphany/pull/613) - Hotfixes for Ubuntu offline installation in air-gap mode + ## [0.4.0] 2019-10-11 ### Added diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/ubuntu-18.04/common.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/ubuntu-18.04/common.sh index f115e98eae..6089107000 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/ubuntu-18.04/common.sh +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/ubuntu-18.04/common.sh @@ -46,7 +46,7 @@ download_image() { else local tmp_file=$(mktemp) echo "Downloading image: $1" - echo "Skopeo command is: ./skopeo_linux --insecure-policy copy docker://{$image_name} docker-archive:${dst_image}:${repository}:${tag}" + echo "Skopeo command is: ./skopeo_linux --insecure-policy copy docker://${image_name} docker-archive:${dst_image}:${repository}:${tag}" # use temporary file for downloading to be safe from sudden interruptions (network, ctrl+c) ./skopeo_linux --insecure-policy copy docker://${image_name} docker-archive:${tmp_file}:${repository}:${tag} && chmod 644 ${tmp_file} && mv ${tmp_file} ${dst_image} fi @@ -74,8 +74,5 @@ download_file() { # --no-use-server-timestamps - we don't use --timestamping and we need to expire files somehow # --continue - don't download the same file multiple times, gracefully skip if file is fully downloaded - wget --no-use-server-timestamps --continue --show-progress --directory-prefix="${dest_dir}" "${file_url}" - - #wget --no-verbose --directory-prefix="$dest_dir" "$file_url" || - #exit_with_error "Command failed: wget --no-verbose --directory-prefix=\"$dest_dir\" \"$file_url\"" + wget --no-use-server-timestamps --continue --show-progress --prefer-family=IPv4 --directory-prefix="${dest_dir}" "${file_url}" } diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/server/Debian/create-repository.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/server/Debian/create-repository.sh index ea5db3debf..1d4c874627 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/server/Debian/create-repository.sh +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/server/Debian/create-repository.sh @@ -2,26 +2,38 @@ EPI_REPO_SERVER_PATH=$1 # /var/www/html/epirepo is the default IS_OFFLINE_MODE=$2 +script_path="$( cd "$(dirname "$0")" ; pwd -P )" if $IS_OFFLINE_MODE = true; then # bootstrap apache and dpkg-dev installation in air-gap mode + if [[ -f /etc/apt/sources.list ]]; then + echo "disabling default repositories..." + mv /etc/apt/sources.list /etc/apt/sources.list.bak + fi if ! dpkg -l | grep -q libdpkg-perl; then echo libdpkg-perl not found, installing... - dpkg -i ${EPI_REPO_SERVER_PATH}/packages/libdpkg-perl*.deb + dpkg -i "${EPI_REPO_SERVER_PATH}"/packages/libdpkg-perl*.deb fi - cd ${EPI_REPO_SERVER_PATH}/packages && /tmp/epi-repository-setup-scripts/dpkg-scanpackages -m . | gzip -9c > Packages.gz && cd - + echo "generating repository metadata..." + cd "${EPI_REPO_SERVER_PATH}"/packages && /tmp/epi-repository-setup-scripts/dpkg-scanpackages -m . | gzip -9c > Packages.gz && cd "${script_path}" echo "deb [trusted=yes] file:${EPI_REPO_SERVER_PATH}/packages ./" > /etc/apt/sources.list.d/epilocal.list - apt update --assume-no # workaround for botched docker repository https://github.com/docker/for-linux/issues/812 + #apt update --assume-no # workaround for botched docker repository https://github.com/docker/for-linux/issues/812 + echo "updating apt and installing apache..." + apt -y update apt -y install apache2 dpkg-dev + echo "removing temporary repo definition: /etc/apt/sources.list.d/epilocal.list..." rm -f /etc/apt/sources.list.d/epilocal.list - rm -f ${EPI_REPO_SERVER_PATH}/packages/Packages.gz - apt update --assume-no + #rm -f ${EPI_REPO_SERVER_PATH}/packages/Packages.gz + echo "updating apt..." + apt -y update else + # for online mode just install apache apt -y install apache2 dpkg-dev + + # -m is important because it allow same packages with different versions + # 'cd' is needed here becuase 'dpkg-scanpackages' prepends path to "Filename" field in Packages.gz + # otherwise it would break package URL for apt + cd /var/www/html/epirepo/packages && dpkg-scanpackages -m . | gzip -9c > Packages.gz && cd "${script_path}" fi systemctl start apache2 - -# -m is important because it allow same packages with different versions -# 'cd' is needed here becuase 'dpkg-scanpackages' prepends path to "Filename" field in Packages.gz, otherwise it would break package URL for apt -cd /var/www/html/epirepo/packages && dpkg-scanpackages -m . | gzip -9c > Packages.gz diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/Debian/setup.yml b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/Debian/setup.yml index 121ca9a49f..e57afe6b4e 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/Debian/setup.yml +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/Debian/setup.yml @@ -1,7 +1,7 @@ --- - name: Create epirepo repository shell: >- - /tmp/epi-repository-setup-scripts/create-repository.sh /var/www/html/epirepo {{ offline_mode | lower }} |& + set -o pipefail && /tmp/epi-repository-setup-scripts/create-repository.sh /var/www/html/epirepo {{ offline_mode | lower }} |& tee /tmp/epi-repository-setup-scripts/create-repository.log args: executable: /bin/bash @@ -9,6 +9,14 @@ - not custom_repository_url - inventory_hostname in groups['repository'] +- name: Ensure apache is running + service: + name: apache2 + state: started + when: + - not custom_repository_url + - inventory_hostname in groups['repository'] + - name: Disable system repositories and set up epirepo block: - name: Create list of enabled repositories diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/RedHat/setup.yml b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/RedHat/setup.yml index 99596e6591..7ec97b7764 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/RedHat/setup.yml +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/RedHat/setup.yml @@ -17,7 +17,6 @@ name: httpd state: started when: - - ansible_os_family == "RedHat" - not custom_repository_url - inventory_hostname in groups['repository'] diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown.yml b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown.yml index ee00250ec5..a2544bf63e 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown.yml +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown.yml @@ -8,4 +8,5 @@ loop: - /tmp/epi-download-requirements - /tmp/epi-repository-setup-scripts - - /var/tmp/enabled-system-repos.txt \ No newline at end of file + - /var/tmp/enabled-system-repos.txt + - /var/tmp/enabled-system-repos.tar \ No newline at end of file