diff --git a/core/src/epicli/cli/engine/PrepareEngine.py b/core/src/epicli/cli/engine/PrepareEngine.py index b867b61217..a9c55f173a 100644 --- a/core/src/epicli/cli/engine/PrepareEngine.py +++ b/core/src/epicli/cli/engine/PrepareEngine.py @@ -11,7 +11,7 @@ class PrepareEngine(Step): - PREPARE_PATH = DATA_FOLDER_PATH + '/common/ansible/playbooks/roles/repository/files/prepare' + PREPARE_PATH = DATA_FOLDER_PATH + '/common/ansible/playbooks/roles/repository/files/download-requirements' def __init__(self, input_data): super().__init__(__name__) diff --git a/core/src/epicli/cli/engine/ansible/AnsibleRunner.py b/core/src/epicli/cli/engine/ansible/AnsibleRunner.py index b64720bc1b..555db8b2db 100644 --- a/core/src/epicli/cli/engine/ansible/AnsibleRunner.py +++ b/core/src/epicli/cli/engine/ansible/AnsibleRunner.py @@ -61,7 +61,7 @@ def run(self): self.logger.info('Setting up repository for cluster provisioning. This will take a while...') repository_setup_play_result = self.ansible_command.run_playbook_with_retries( inventory=inventory_path, - playbook_path=self.playbook_path('repository-setup'), + playbook_path=self.playbook_path('repository_setup'), retries=5) if repository_setup_play_result != 0: @@ -84,7 +84,7 @@ def run(self): repository_teardown_play_result = self.ansible_command.run_playbook_with_retries( inventory=inventory_path, - playbook_path=self.playbook_path('repository-teardown'), + playbook_path=self.playbook_path('repository_teardown'), retries=1) if repository_teardown_play_result != 0: diff --git a/core/src/epicli/data/common/ansible/playbooks/repository-setup.yml b/core/src/epicli/data/common/ansible/playbooks/repository_setup.yml similarity index 100% rename from core/src/epicli/data/common/ansible/playbooks/repository-setup.yml rename to core/src/epicli/data/common/ansible/playbooks/repository_setup.yml diff --git a/core/src/epicli/data/common/ansible/playbooks/repository-teardown.yml b/core/src/epicli/data/common/ansible/playbooks/repository_teardown.yml similarity index 100% rename from core/src/epicli/data/common/ansible/playbooks/repository-teardown.yml rename to core/src/epicli/data/common/ansible/playbooks/repository_teardown.yml diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/Debian/create-repository.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/Debian/add-epirepo-client.sh similarity index 100% rename from core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/Debian/create-repository.sh rename to core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/Debian/add-epirepo-client.sh diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/setup-epirepo-client.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/add-epirepo-client.sh similarity index 71% rename from core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/setup-epirepo-client.sh rename to core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/add-epirepo-client.sh index 275598531d..fd7781d5cf 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/setup-epirepo-client.sh +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/add-epirepo-client.sh @@ -1,12 +1,9 @@ -#!/bin/bash +#!/bin/bash -eu REPOSITORY_URL=$1 curl -I -L $REPOSITORY_URL | grep "HTTP/1.1 200 OK" -# Todo: remove if unnecessary -#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 diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/create-enabled-system-repos-list.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/create-enabled-system-repos-list.sh new file mode 100644 index 0000000000..e3703950b1 --- /dev/null +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/create-enabled-system-repos-list.sh @@ -0,0 +1,7 @@ +#!/bin/bash -eu + +ENABLED_REPOS_FILE=/tmp/enabled-system-repos.txt + +if [ ! -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 diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/disable-epirepo-client.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/disable-epirepo-client.sh new file mode 100644 index 0000000000..612e019d5e --- /dev/null +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/disable-epirepo-client.sh @@ -0,0 +1,5 @@ +#!/bin/bash -eu + +yum-config-manager --disable epirepo +yum makecache +yum repolist diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/disable-system-repos.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/disable-system-repos.sh new file mode 100644 index 0000000000..51a4f0deee --- /dev/null +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/disable-system-repos.sh @@ -0,0 +1,10 @@ +#!/bin/bash -eu + +REPOS_LIST_FILE=/tmp/enabled-system-repos.txt + +cat $REPOS_LIST_FILE | while read repository +do + echo "Disabling repository: $repository" + yum-config-manager --disable $repository +done + diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/enable-system-repos.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/enable-system-repos.sh new file mode 100644 index 0000000000..77768c2bae --- /dev/null +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/client/RedHat/enable-system-repos.sh @@ -0,0 +1,9 @@ +#!/bin/bash -eu + +REPOS_LIST_FILE=/tmp/enabled-system-repos.txt + +cat $REPOS_LIST_FILE | while read repository +do + echo "Enabling repository: $repository" + yum-config-manager --enable $repository +done diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/centos-7/download-requirements.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/centos-7/download-requirements.sh similarity index 100% rename from core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/centos-7/download-requirements.sh rename to core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/centos-7/download-requirements.sh diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/centos-7/requirements.txt b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/centos-7/requirements.txt similarity index 99% rename from core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/centos-7/requirements.txt rename to core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/centos-7/requirements.txt index 280e374880..7998ed7a88 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/centos-7/requirements.txt +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/centos-7/requirements.txt @@ -87,6 +87,7 @@ tmux urw-base35-fonts # for grafana vim-common # for vim vim-enhanced +wget xorg-x11-font-utils # for grafana xorg-x11-server-utils # for grafana yum-plugin-versionlock diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/redhat-7/download-requirements.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/redhat-7/download-requirements.sh similarity index 100% rename from core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/redhat-7/download-requirements.sh rename to core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/redhat-7/download-requirements.sh diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/redhat-7/requirements.txt b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/redhat-7/requirements.txt similarity index 99% rename from core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/redhat-7/requirements.txt rename to core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/redhat-7/requirements.txt index 280e374880..7998ed7a88 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/redhat-7/requirements.txt +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/redhat-7/requirements.txt @@ -87,6 +87,7 @@ tmux urw-base35-fonts # for grafana vim-common # for vim vim-enhanced +wget xorg-x11-font-utils # for grafana xorg-x11-server-utils # for grafana yum-plugin-versionlock diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/ubuntu-18.04/add-repositories.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/ubuntu-18.04/add-repositories.sh similarity index 100% rename from core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/ubuntu-18.04/add-repositories.sh rename to core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/ubuntu-18.04/add-repositories.sh diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/ubuntu-18.04/download-requirements.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/ubuntu-18.04/download-requirements.sh similarity index 100% rename from core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/ubuntu-18.04/download-requirements.sh rename to core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/ubuntu-18.04/download-requirements.sh diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/ubuntu-18.04/requirements.txt b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/ubuntu-18.04/requirements.txt similarity index 100% rename from core/src/epicli/data/common/ansible/playbooks/roles/repository/files/prepare/ubuntu-18.04/requirements.txt rename to core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/ubuntu-18.04/requirements.txt diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/create-enabled-system-repositories-list.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/create-enabled-system-repositories-list.sh deleted file mode 100644 index 973c76f263..0000000000 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/create-enabled-system-repositories-list.sh +++ /dev/null @@ -1,4 +0,0 @@ -ENABLED_REPOS_FILE=/tmp/enabled-system-repos.txt -if [ ! -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 diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/create-repository.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/create-repository.sh deleted file mode 100644 index e47a67820e..0000000000 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/create-repository.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -EPI_REPO_SERVER_PATH=$1 # /var/www/html/epirepo is the default -IS_OFFLINE_MODE=$2 - -if $IS_OFFLINE_MODE = true -then - yum install -y $(ls $EPI_REPO_SERVER_PATH/packages/offline_prereqs/*.rpm) -else - yum install -y httpd createrepo yum-utils -fi - -setenforce 0 -systemctl start httpd - -createrepo $EPI_REPO_SERVER_PATH/packages diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/disable-epirepo-client.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/disable-epirepo-client.sh deleted file mode 100644 index bf82cab2ef..0000000000 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/disable-epirepo-client.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -yum-config-manager --disable epirepo*; -yum makecache; -yum repolist; - diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/disable-repository.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/disable-repository.sh deleted file mode 100644 index d3924891a7..0000000000 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/disable-repository.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -systemctl stop httpd; -systemctl disable httpd; \ No newline at end of file diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/disable-system-repos.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/disable-system-repos.sh deleted file mode 100644 index a5391f3909..0000000000 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/disable-system-repos.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/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 - diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/enable-system-repos.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/enable-system-repos.sh deleted file mode 100644 index d030de8278..0000000000 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/RedHat/enable-system-repos.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/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 - diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/Debian/create-offline-repo.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/server/Debian/create-repository.sh similarity index 100% rename from core/src/epicli/data/common/ansible/playbooks/roles/repository/files/repository/Debian/create-offline-repo.sh rename to core/src/epicli/data/common/ansible/playbooks/roles/repository/files/server/Debian/create-repository.sh diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/server/RedHat/create-repository.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/server/RedHat/create-repository.sh new file mode 100644 index 0000000000..243841ceb0 --- /dev/null +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/server/RedHat/create-repository.sh @@ -0,0 +1,15 @@ +#!/bin/bash -eu + +EPI_REPO_SERVER_PATH=$1 # /var/www/html/epirepo is the default +IS_OFFLINE_MODE=$2 + +if $IS_OFFLINE_MODE = true; then + yum install -y $(ls $EPI_REPO_SERVER_PATH/packages/offline_prereqs/*.rpm) #TODO: to test +else + yum install -y httpd createrepo yum-utils +fi + +setenforce 0 +systemctl start httpd + +createrepo $EPI_REPO_SERVER_PATH/packages \ No newline at end of file diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/server/RedHat/disable-repository-server.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/server/RedHat/disable-repository-server.sh new file mode 100644 index 0000000000..7e21186e90 --- /dev/null +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/server/RedHat/disable-repository-server.sh @@ -0,0 +1,4 @@ +#!/bin/bash -eu + +systemctl stop httpd +systemctl disable httpd \ No newline at end of file diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/setup-Debian.yml b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/Debian/setup.yml similarity index 100% rename from core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/setup-Debian.yml rename to core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/Debian/setup.yml diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown-Debian.yml b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/Debian/teardown.yml similarity index 96% rename from core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown-Debian.yml rename to core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/Debian/teardown.yml index fde79592bb..daa3895377 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown-Debian.yml +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/Debian/teardown.yml @@ -1,5 +1,4 @@ --- - - name: Enable system repositories and disable epirepo for offline mode block: - name: Enable system repositories @@ -17,4 +16,4 @@ shell: /tmp/{{ ansible_os_family }}/disable-epirepo-client-rh.sh when: - not groups['kubernetes_master'][0] == inventory_hostname - - offline_mode == false + - offline_mode == false \ No newline at end of file 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 new file mode 100644 index 0000000000..0e83cf9548 --- /dev/null +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/RedHat/setup.yml @@ -0,0 +1,19 @@ +--- +- name: Create epirepo repository + shell: >- + /tmp/epi-repository-setup-scripts/create-repository.sh /var/www/html/epirepo {{ offline_mode }} |& + tee /tmp/epi-repository-setup-scripts/create-repository.log + 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 + shell: /tmp/epi-repository-setup-scripts/create-enabled-system-repos-list.sh + - name: Disable system repositories + shell: /tmp/epi-repository-setup-scripts/disable-system-repos.sh + - name: Add and enable epirepo + shell: >- + /tmp/epi-repository-setup-scripts/add-epirepo-client.sh {{ repository_url }} |& + tee /tmp/epi-repository-setup-scripts/add-epirepo-client.log diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/RedHat/teardown.yml b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/RedHat/teardown.yml new file mode 100644 index 0000000000..4bfaa9b101 --- /dev/null +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/RedHat/teardown.yml @@ -0,0 +1,12 @@ +--- +- name: Re-enable system repositories + shell: /tmp/epi-repository-setup-scripts/enable-system-repos.sh + +- name: Disable epirepo + shell: /tmp/epi-repository-setup-scripts/disable-epirepo-client.sh + +- name: Disable epirepo server + shell: /tmp/epi-repository-setup-scripts/disable-repository-server.sh + when: + - not custom_repository_url + - inventory_hostname in groups['repository'] \ No newline at end of file diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/download-requirements.yml b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/download-requirements.yml index ada38652d2..0c2bd2c531 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/download-requirements.yml +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/download-requirements.yml @@ -1,4 +1,20 @@ --- +# download-requirements-done.flag file is used to avoid re-downloading requirements (to save time) +# this is to be optimized in the future + +- name: Check if flag file exists + stat: + path: /tmp/epi-download-requirements/download-requirements-done.flag + register: stat_result + +- name: Remove download-requirements-done.flag file if expired + file: + path: /tmp/epi-download-requirements/download-requirements-done.flag + state: absent + when: + - stat_result.stat.exists + - (ansible_date_time.epoch|int - stat_result.stat.mtime) > 3600 # older than 1h + - name: Check whether to run download script stat: path: /tmp/epi-download-requirements/download-requirements-done.flag @@ -6,10 +22,10 @@ - name: Run download-requirements script, it can take a long time shell: /tmp/epi-download-requirements/download-requirements.sh /var/www/html/epirepo - when: stat_result.stat.exists == False + when: not stat_result.stat.exists - name: Create flag file to not re-download requirements next time file: path: /tmp/epi-download-requirements/download-requirements-done.flag state: touch - when: stat_result.stat.exists == False \ No newline at end of file + when: not stat_result.stat.exists \ No newline at end of file diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/setup-RedHat.yml b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/setup-RedHat.yml deleted file mode 100644 index f4e156a7b2..0000000000 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/setup-RedHat.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- name: Create epirepo repository - shell: >- - /tmp/epi-repository-setup-scripts/create-repository.sh /var/www/html/epirepo {{ offline_mode }} |& - tee /tmp/epi-repository-setup-scripts/create-repository.log - when: - - groups['kubernetes_master'][0] == inventory_hostname - - not custom_repository_url - -- name: Disable system repositories and setup epirepo - block: - - name: Create active repositories list - shell: /tmp/epi-repository-setup-scripts/create-enabled-system-repositories-list.sh - - name: Disable active system repositories - shell: /tmp/epi-repository-setup-scripts/disable-system-repos.sh - - name: Setup epirepo on clients - shell: >- - /tmp/epi-repository-setup-scripts/setup-epirepo-client.sh {{ repository_url }} |& - tee /tmp/epi-repository-setup-scripts/setup-epirepo-client.log diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/setup.yml b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/setup.yml index 22392d1973..5093db5ccd 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/setup.yml +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/setup.yml @@ -1,7 +1,7 @@ --- - name: Set mode set_fact: - offline_mode: "{{ offline_requirements | length | bool }}" + offline_mode: "{{ offline_requirements | length > 0 }}" - name: Print mode debug: @@ -23,7 +23,7 @@ - name: Copy files for downloading requirements to repository host copy: - src: "prepare/{{ download_script_subdir }}/" + src: "download-requirements/{{ download_script_subdir }}/" dest: /tmp/epi-download-requirements - name: Copy skopeo binary to repository host @@ -42,23 +42,33 @@ when: - not offline_mode - - groups['kubernetes_master'][0] == inventory_hostname #TODO: dedicated host for repository in Ansible inventory - not custom_repository_url + - inventory_hostname in groups['repository'] -- name: Copy repository configuration scripts +- name: Copy repository client configuration scripts copy: - src: "repository/{{ ansible_os_family }}/" + src: "client/{{ ansible_os_family }}/" dest: "/tmp/epi-repository-setup-scripts" mode: a+x -- name: Copy requirements for offline installation (epi-repo) to repository host +- name: Copy repository server configuration scripts copy: - src: /shared/epi-repo/ #TODO: This needs to be configurable - dest: /var/www/html/epi-repo + src: "server/{{ ansible_os_family }}/" + dest: "/tmp/epi-repository-setup-scripts" + mode: a+x + when: + - not offline_mode + - not custom_repository_url + - inventory_hostname in groups['repository'] + +- name: Copy requirements for offline installation to repository host + copy: + src: "{{ offline_requirements }}/" #TODO: handle case with double slash + dest: /var/www/html/epirepo when: - offline_mode - - groups['kubernetes_master'][0] == inventory_hostname - not custom_repository_url + - inventory_hostname in groups['repository'] -- name: Configure repository and clients - include_tasks: "setup-{{ ansible_os_family }}.yml" \ No newline at end of file +- name: Set up repositories + include_tasks: "{{ ansible_os_family }}/setup.yml" \ No newline at end of file diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown-RedHat.yml b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown-RedHat.yml deleted file mode 100644 index fde79592bb..0000000000 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown-RedHat.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -- 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: - - offline_mode == true - -- 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 - - offline_mode == false 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 2f5e146a4c..397176776a 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 @@ -1,2 +1,2 @@ -- name: Configure repository and clients - include_tasks: "teardown-{{ ansible_os_family }}.yml" \ No newline at end of file +- name: Re-enable system repositories and disable epirepo + include_tasks: "{{ ansible_os_family }}/teardown.yml" \ No newline at end of file diff --git a/core/src/epicli/data/common/defaults/configuration/feature-mapping.yml b/core/src/epicli/data/common/defaults/configuration/feature-mapping.yml index 83ad2d8f13..436bfb070a 100644 --- a/core/src/epicli/data/common/defaults/configuration/feature-mapping.yml +++ b/core/src/epicli/data/common/defaults/configuration/feature-mapping.yml @@ -4,6 +4,8 @@ title: "Feature mapping to roles" name: default specification: available_roles: + - name: repository + enabled: yes - name: kubernetes-master enabled: yes - name: kubernetes-node @@ -72,6 +74,7 @@ specification: - node-exporter - filebeat custom: + - repository - kubernetes-master - node-exporter - filebeat @@ -84,12 +87,14 @@ specification: - elasticsearch - elasticsearch-curator single_machine: + - repository - kubernetes-master - applications - rabbitmql - postgresql kubernetes_master: - kubernetes-master + - repository - applications - node-exporter - filebeat diff --git a/core/src/epicli/data/common/defaults/configuration/repository.yml b/core/src/epicli/data/common/defaults/configuration/repository.yml new file mode 100644 index 0000000000..f69d916fcf --- /dev/null +++ b/core/src/epicli/data/common/defaults/configuration/repository.yml @@ -0,0 +1,6 @@ +kind: configuration/repository +version: 0.4.0 +title: "Epiphany requirements repository" +name: default +specification: + description: "Local repository of binaries required to install Epiphany" \ No newline at end of file diff --git a/core/src/epicli/data/common/validation/configuration/repository.yml b/core/src/epicli/data/common/validation/configuration/repository.yml new file mode 100644 index 0000000000..89807aa970 --- /dev/null +++ b/core/src/epicli/data/common/validation/configuration/repository.yml @@ -0,0 +1 @@ +$ref: '#/definitions/unvalidated_specification' \ No newline at end of file