diff options
-rwxr-xr-x | ansible/group_vars/all.yml | 5 | ||||
-rw-r--r-- | ansible/infrastructure.yml | 22 | ||||
-rw-r--r-- | ansible/roles/package-repository/defaults/main.yml | 2 | ||||
-rw-r--r-- | ansible/roles/package-repository/tasks/main.yml | 19 | ||||
-rw-r--r-- | ansible/roles/setup/defaults/main.yml | 3 | ||||
-rw-r--r-- | ansible/roles/setup/tasks/main.yml | 30 | ||||
-rw-r--r-- | ansible/setup.yml | 28 | ||||
-rwxr-xr-x | build/creating_data/create-rhel-repo.sh | 4 | ||||
-rwxr-xr-x | build/creating_data/download-git-repos.sh | 2 | ||||
-rwxr-xr-x | build/creating_data/save-docker-images.sh | 11 | ||||
-rw-r--r-- | build/data_lists/infra_docker_images.list | 3 | ||||
-rw-r--r-- | build/data_lists/onap_3.0.0-docker_images.list | 1 | ||||
-rw-r--r-- | build/data_lists/onap_3.0.1-docker_images.list | 1 | ||||
-rwxr-xr-x | build/download_offline_data_by_lists.sh | 13 | ||||
-rwxr-xr-x | build/fetch_and_patch_charts.sh | 2 | ||||
-rw-r--r-- | docs/BuildGuide.rst | 2 | ||||
-rw-r--r-- | patches/casablanca.patch (renamed from patches/casablanca_3.0.0.patch) | 0 | ||||
-rw-r--r-- | patches/onap-casablanca-patch-role/tasks/main.yml | 36 |
18 files changed, 109 insertions, 75 deletions
diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index cd8c7f58..8e81d7f0 100755 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -59,9 +59,8 @@ certificates: # Default value is to allow redeploy redeploy_k8s_env: yes -# Distribute offline rpm repository -# Default value is to distribute rpm -deploy_rpm_repository: yes +# Distribute offline software package (rpm,apt) repository +deploy_package_repository: yes # Offline solution is deploying app specific rpm repository and requires some name # also for k8s cluster diff --git a/ansible/infrastructure.yml b/ansible/infrastructure.yml index a0bc7011..7d75dc77 100644 --- a/ansible/infrastructure.yml +++ b/ansible/infrastructure.yml @@ -1,28 +1,8 @@ --- - name: Perform common environment setup for nodes hosts: infrastructure, kubernetes - tasks: - - name: Setup resolv.conf - lineinfile: - line: "nameserver {{ hostvars[groups.infrastructure[0]].cluster_ip }}" - path: /etc/resolv.conf - state: present - insertbefore: BOF - become: yes - - name: Add application offline rpm repository - yum_repository: - name: "{{ app_name }}" - file: "{{ app_name | lower }}" - description: "{{ app_name }} offline repository" - baseurl: "{{ 'http://repo.infra-server/rhel' if 'infrastructure' not in group_names else 'file://' + app_data_path + '/pkg/rhel' }}" - gpgcheck: no - enabled: yes - when: deploy_rpm_repository - become: yes - -- name: Setup firewall - hosts: infrastructure, kubernetes roles: + - package-repository - role: firewall - name: Setup infrastructure servers diff --git a/ansible/roles/package-repository/defaults/main.yml b/ansible/roles/package-repository/defaults/main.yml new file mode 100644 index 00000000..ea5796df --- /dev/null +++ b/ansible/roles/package-repository/defaults/main.yml @@ -0,0 +1,2 @@ +--- +deploy_package_repository: true diff --git a/ansible/roles/package-repository/tasks/main.yml b/ansible/roles/package-repository/tasks/main.yml new file mode 100644 index 00000000..686310e4 --- /dev/null +++ b/ansible/roles/package-repository/tasks/main.yml @@ -0,0 +1,19 @@ +--- +- name: Setup resolv.conf for node to find package repository by name from infra + lineinfile: + line: "nameserver {{ hostvars[groups.infrastructure[0]].cluster_ip }}" + path: /etc/resolv.conf + state: present + insertbefore: BOF + become: true + +- name: Add application offline package repository + yum_repository: + name: "{{ app_name }}" + file: "{{ app_name | lower }}" + description: "{{ app_name | upper }} offline repository" + baseurl: "{{ 'http://repo.infra-server/rhel' if 'infrastructure' not in group_names else 'file://' + app_data_path + '/pkg/rhel' }}" + gpgcheck: false + enabled: true + when: deploy_package_repository + become: true diff --git a/ansible/roles/setup/defaults/main.yml b/ansible/roles/setup/defaults/main.yml new file mode 100644 index 00000000..e7e89721 --- /dev/null +++ b/ansible/roles/setup/defaults/main.yml @@ -0,0 +1,3 @@ +--- +ssh_dir: ~/.ssh +offline_ssh_key_file_name: offline_ssh_key
\ No newline at end of file diff --git a/ansible/roles/setup/tasks/main.yml b/ansible/roles/setup/tasks/main.yml new file mode 100644 index 00000000..5ffcbab9 --- /dev/null +++ b/ansible/roles/setup/tasks/main.yml @@ -0,0 +1,30 @@ +--- +- name: "Check and generate key if needed" + block: + - name: ssh dir + file: + path: "{{ ssh_dir }}" + state: directory + mode: 0700 + + - name: check ssh pub key exists + stat: + path: '{{ private_key }}.pub' + register: p + + - name: generate ssh keys + command: ssh-keygen -f {{ private_key }} -t rsa -N '' + when: not p.stat.exists + vars: + private_key: "{{ ssh_dir }}/{{ offline_ssh_key_file_name }}" + delegate_to: localhost + run_once: true + +- name: Setup authorized_keys file + authorized_key: + user: root + state: present + key: "{{ lookup('file', public_key) }}" + become: true + vars: + public_key: "{{ ssh_dir }}/{{ offline_ssh_key_file_name }}.pub" diff --git a/ansible/setup.yml b/ansible/setup.yml index ec572973..9e4f051d 100644 --- a/ansible/setup.yml +++ b/ansible/setup.yml @@ -1,26 +1,6 @@ --- -- hosts: localhost +- name: Setup nodes for installer + hosts: all gather_facts: false - tasks: - - name: "Check and generate key if needed" - block: - - stat: - path: '{{ private_key }}.pub' - register: p - - - command: ssh-keygen -f {{ private_key }} -t rsa -N '' - when: not p.stat.exists - vars: - private_key: /root/.ssh/offline_ssh_key - -- hosts: all - gather_facts: false - tasks: - - name: Setup authorized_keys file - authorized_key: - user: root - state: present - key: "{{ lookup('file', public_key) }}" - become: true - vars: - public_key: /root/.ssh/offline_ssh_key.pub + roles: + - setup diff --git a/build/creating_data/create-rhel-repo.sh b/build/creating_data/create-rhel-repo.sh index 9859dc93..0a2a897e 100755 --- a/build/creating_data/create-rhel-repo.sh +++ b/build/creating_data/create-rhel-repo.sh @@ -38,6 +38,10 @@ fi # it should be available in centos docker repo yumdownloader --resolve --destdir="${OUTDIR}" docker-ce-17.03.2.ce libtool-ltdl docker-ce-selinux nfs-utils +wget https://cbs.centos.org/kojifiles/packages/python-docker/2.5.1/2.el7/noarch/python2-docker-2.5.1-2.el7.noarch.rpm -P "${OUTDIR}" + +yum install --downloadonly --downloaddir="${OUTDIR}" "${OUTDIR}/python2-docker-2.5.1-2.el7.noarch.rpm" + createrepo "${OUTDIR}" exit 0 diff --git a/build/creating_data/download-git-repos.sh b/build/creating_data/download-git-repos.sh index bb4a79f1..0219eb6f 100755 --- a/build/creating_data/download-git-repos.sh +++ b/build/creating_data/download-git-repos.sh @@ -24,7 +24,7 @@ usage () { echo "Usage:" echo -e "./$(basename $0) <repository list> [destination directory]\n" echo "Examples:" - echo " ./$(basename $0) onap_3.0.0 ./git-repo" + echo " ./$(basename $0) onap_3.0.0-git_repos.list ./git-repo" } LIST="${1}" diff --git a/build/creating_data/save-docker-images.sh b/build/creating_data/save-docker-images.sh index f4a5d3c7..4c764556 100755 --- a/build/creating_data/save-docker-images.sh +++ b/build/creating_data/save-docker-images.sh @@ -27,7 +27,8 @@ if [ "$IS_COMMON_FUNCTIONS_SOURCED" != YES ] ; then . "${LOCAL_PATH}"/"${RELATIVE_PATH}"/common-functions.sh fi -IMG_DIR="$1" +LIST="${1}" +IMG_DIR="${2}" if [[ -z "$IMG_DIR" ]]; then IMG_DIR="./images" @@ -55,13 +56,11 @@ save_image() { echo "Save all images" line=1 -lines=$(docker images|grep -v 'IMAGE ID'|wc -l) +lines=$(wc -l ${LIST}) while read -r image; do echo "== pkg #$line of $lines ==" - name=$(echo $image|awk '{print $1}') - tag=$(echo $image|awk '{print $2}') - save_image "$name:$tag" + save_image "${image}" line=$((line+1)) -done <<< "$(docker images|grep -v 'IMAGE ID'|awk '{printf("%s %s\n", $1, $2)}'|column -t)" +done < "${LIST}" diff --git a/build/data_lists/infra_docker_images.list b/build/data_lists/infra_docker_images.list new file mode 100644 index 00000000..af156cfc --- /dev/null +++ b/build/data_lists/infra_docker_images.list @@ -0,0 +1,3 @@ +andyshinn/dnsmasq:2.76 +consol/centos-icewm-vnc:latest +sonatype/nexus3:3.15.2 diff --git a/build/data_lists/onap_3.0.0-docker_images.list b/build/data_lists/onap_3.0.0-docker_images.list index 2bb8245d..589c6a51 100644 --- a/build/data_lists/onap_3.0.0-docker_images.list +++ b/build/data_lists/onap_3.0.0-docker_images.list @@ -2,7 +2,6 @@ aaionap/haproxy:1.2.4 library/alpine:3.6 library/busybox:latest library/cassandra:2.1 -consol/centos-icewm-vnc:latest library/consul:1.0.6 crunchydata/crunchy-pgpool:centos7-10.4-2.0.0 crunchydata/crunchy-postgres:centos7-10.3-1.8.2 diff --git a/build/data_lists/onap_3.0.1-docker_images.list b/build/data_lists/onap_3.0.1-docker_images.list index cf8b11c6..ec98a3ed 100644 --- a/build/data_lists/onap_3.0.1-docker_images.list +++ b/build/data_lists/onap_3.0.1-docker_images.list @@ -3,7 +3,6 @@ library/alpine:3.6 library/busybox:latest library/cassandra:2.1 cdposs/zookeeper:3.4.9 -consol/centos-icewm-vnc:latest library/consul:1.0.6 crunchydata/crunchy-pgpool:centos7-10.4-2.0.0 crunchydata/crunchy-postgres:centos7-10.3-1.8.2 diff --git a/build/download_offline_data_by_lists.sh b/build/download_offline_data_by_lists.sh index aede41dc..741c2046 100755 --- a/build/download_offline_data_by_lists.sh +++ b/build/download_offline_data_by_lists.sh @@ -47,7 +47,7 @@ fi CTOOLS="${LOCAL_PATH}/creating_data" LISTS_DIR="${LOCAL_PATH}/data_lists" DATA_DIR="${LOCAL_PATH}/../../resources" -TOTAL=11 +TOTAL=12 CURR=1 message info "Downloading started: $(date)" @@ -55,19 +55,22 @@ message info "Downloading started: $(date)" echo "[Step $((CURR++))/$TOTAL Download collected docker images]" $CTOOLS/download-docker-images.sh "${LISTS_DIR}/${TAG}-docker_images.list" +echo "[Step $((CURR++))/$TOTAL Download docker images for infra-server]" +$CTOOLS/download-docker-images.sh "${LISTS_DIR}/infra_docker_images.list" + echo "[Step $((CURR++))/$TOTAL Build own nginx image]" $CTOOLS/create_nginx_image/01create-image.sh echo "[Step $((CURR++))/$TOTAL Save docker images from docker cache to tarfiles]" -$CTOOLS/save-docker-images.sh "${DATA_DIR}/offline_data/docker_images_for_nexus" +$CTOOLS/save-docker-images.sh "${LISTS_DIR}/${TAG}-docker_images.list" "${DATA_DIR}/offline_data/docker_images_for_nexus" -echo "[Step $((CURR++))/$TOTAL move infra related images to infra folder]" +echo "[Step $((CURR++))/$TOTAL Prepare infra related images to infra folder]" mkdir -p "${DATA_DIR}/offline_data/docker_images_infra" mv "${DATA_DIR}/offline_data/docker_images_for_nexus/own_nginx_latest.tar" "${DATA_DIR}/offline_data/docker_images_infra" -mv "${DATA_DIR}/offline_data/docker_images_for_nexus/sonatype_nexus3_latest.tar" "${DATA_DIR}/offline_data/docker_images_infra" +$CTOOLS/save-docker-images.sh "${LISTS_DIR}/infra_docker_images.list" "${DATA_DIR}/offline_data/docker_images_infra" echo "[Step $((CURR++))/$TOTAL Download git repos]" -$CTOOLS/download-git-repos.sh "${LISTS_DIR}/${TAG}" "${DATA_DIR}/git-repo" +$CTOOLS/download-git-repos.sh "${LISTS_DIR}/${TAG}-git_repos.list" "${DATA_DIR}/git-repo" echo "[Step $((CURR++))/$TOTAL Download http files]" $CTOOLS/download-http-files.sh "${LISTS_DIR}/${TAG}-http_files.list" "${DATA_DIR}/http" diff --git a/build/fetch_and_patch_charts.sh b/build/fetch_and_patch_charts.sh index cde42656..2c1312e0 100755 --- a/build/fetch_and_patch_charts.sh +++ b/build/fetch_and_patch_charts.sh @@ -37,7 +37,7 @@ C_='\033[0m' #Color off usage () { echo "Usage:" echo -e "./$(basename $0) <helm charts repo> <commit/tag/branch> <patchfile> <target_dir>\n" - echo "Example: ./$(basename $0) https://gerrit.onap.org/r/oom 3.0.0-ONAP /root/offline-installer/patches/casablanca_3.0.0.patch /root/offline-installer/ansible/application/helm_charts" + echo "Example: ./$(basename $0) https://gerrit.onap.org/r/oom 3.0.0-ONAP /root/offline-installer/patches/casablanca.patch /root/offline-installer/ansible/application/helm_charts" } if [ "$#" -ne 4 ]; then diff --git a/docs/BuildGuide.rst b/docs/BuildGuide.rst index 4cf8d97c..96c1fbf2 100644 --- a/docs/BuildGuide.rst +++ b/docs/BuildGuide.rst @@ -296,7 +296,7 @@ offline. Use the following command: For example: -``$ ./build/fetch_and_patch_charts.sh https://gerrit.onap.org/r/oom 3.0.0-ONAP /tmp/offline-installer/patches/casablanca_3.0.0.patch /tmp/oom-clone`` +``$ ./build/fetch_and_patch_charts.sh https://gerrit.onap.org/r/oom 3.0.0-ONAP /tmp/offline-installer/patches/casablanca.patch /tmp/oom-clone`` Part 5. Creating offline installation package --------------------------------------------- diff --git a/patches/casablanca_3.0.0.patch b/patches/casablanca.patch index e0ea0ec5..e0ea0ec5 100644 --- a/patches/casablanca_3.0.0.patch +++ b/patches/casablanca.patch diff --git a/patches/onap-casablanca-patch-role/tasks/main.yml b/patches/onap-casablanca-patch-role/tasks/main.yml index d3b92e5b..00ee4577 100644 --- a/patches/onap-casablanca-patch-role/tasks/main.yml +++ b/patches/onap-casablanca-patch-role/tasks/main.yml @@ -1,34 +1,48 @@ --- # This role contains patching logic for OOM charts # and is valid until OOM-1610 is implemented +- name: Check presence of files for NPM patching + stat: + path: "{{ app_helm_charts_infra_directory }}/{{ item }}" + with_items: + - common/dgbuilder/templates/deployment.yaml + - sdnc/charts/sdnc-portal/templates/deployment.yaml + register: npm_files_check + +- name: Check presence of dcae cloudify deployment chart file + stat: + path: "{{ app_helm_charts_infra_directory }}/{{ item }}" + with_items: + - dcaegen2/charts/dcae-cloudify-manager/templates/deployment.yaml + register: dcae_files_check + - name: Patch OOM - nexus domain resolving lineinfile: - path: "{{ app_helm_charts_infra_directory }}/{{ item }}" + path: "{{ item.stat.path }}" regexp: '^(.*)HOSTS_FILE_RECORD' line: '\g<1>{{ cluster_ip }} {{ simulated_hosts.nexus | join(" ") }} >> /etc/hosts;' backrefs: yes state: present - with_items: - - common/dgbuilder/templates/deployment.yaml - - sdnc/charts/sdnc-portal/templates/deployment.yaml + with_items: "{{ npm_files_check.results }}" + when: item.stat.exists - name: Patch OOM - set npm registry lineinfile: - path: "{{ app_helm_charts_infra_directory }}/{{ item }}" + path: "{{ item.stat.path }}" regexp: '^(.*)NPM_REGISTRY_RECORD' line: '\g<1>npm set registry "http://nexus.{{ ansible_nodename }}/repository/npm-private/";' backrefs: yes state: present - with_items: - - common/dgbuilder/templates/deployment.yaml - - sdnc/charts/sdnc-portal/templates/deployment.yaml + with_items: "{{ npm_files_check.results }}" + when: item.stat.exists - name: Patch OOM - set cert path for cloudify lineinfile: - path: "{{ app_helm_charts_infra_directory }}/{{ item }}" + path: "{{ item.stat.path }}" regexp: '^(.*)CERT_PATH' line: '\g<1>/etc/pki/ca-trust/source/anchors' backrefs: yes state: present - with_items: - - dcaegen2/charts/dcae-cloudify-manager/templates/deployment.yaml + with_items: "{{ dcae_files_check.results }}" + when: item.stat.exists + |