diff options
-rw-r--r-- | INFO.yaml | 18 | ||||
-rw-r--r-- | ansible/ansible.cfg | 2 | ||||
-rw-r--r-- | ansible/roles/application/tasks/install.yml | 2 | ||||
-rw-r--r-- | ansible/roles/package-repository/handlers/main.yml | 6 | ||||
-rw-r--r-- | ansible/roles/package-repository/tasks/main.yml | 16 | ||||
-rw-r--r-- | ansible/test/images/docker/ubuntu/Dockerfile | 7 | ||||
-rw-r--r-- | ansible/test/roles/prepare-docker-dind/tasks/main.yml | 26 | ||||
-rw-r--r-- | ansible/test/roles/prepare-docker-dind/tasks/rhel.yml | 24 | ||||
-rw-r--r-- | ansible/test/roles/prepare-docker-dind/tasks/ubuntu.yml | 33 | ||||
-rwxr-xr-x | build/package.py | 49 | ||||
-rw-r--r-- | build/requirements.txt | 2 | ||||
-rw-r--r-- | docs/BuildGuide.rst | 4 | ||||
-rw-r--r-- | tools/cicdansible/heat/config.yaml | 2 | ||||
-rw-r--r-- | tools/cicdansible/roles/install/tasks/install.yml | 2 | ||||
-rw-r--r-- | tools/cicdansible/roles/install/templates/inventory.yml.j2 | 3 | ||||
-rw-r--r-- | tools/cicdansible/roles/setup_openstack_infrastructure/tasks/configure/volume.yml | 2 |
16 files changed, 162 insertions, 36 deletions
@@ -66,9 +66,27 @@ committers: company: 'Samsung' id: 'm.zegan' timezone: 'Europe/Warsaw' + - name: 'Sylvain Desbureaux' + email: "sulvain.desbureaux@orange.com" + id: "sdesbure" + company: "Orange" + timezone: 'Europe/Paris' + - name: 'Krzysztof Opasiak' + email: 'k.opasiak@samsung.com' + company: 'Samsung' + id: 'kopasiak' + timezone: 'Europe/Warsaw' tsc: approval: 'https://lists.onap.org/pipermail/onap-tsc' changes: - type: 'Addition' name: 'Bartlomiej Grzybowski' link: 'https://lists.onap.org/g/onap-tsc/topic/32429690' + - type: 'Addition' + name: 'Sylvain Desbureaux' + # yamllint disable-line rule:line-length + link: 'https://lists.onap.org/g/onap-tsc/message/5177?p=,,,20,0,0,0::relevance,,committer+sylvain,20,2,0,32230994' + - type: 'Addition' + name: 'Krzysztof Opasiak' + # yamllint disable-line rule:line-length + link: 'https://lists.onap.org/g/onap-tsc/topic/committer_promotion_request/70242499?p=,,,20,0,0,0::recentpostdate%2Fsticky,,,20,2,0,70242499' diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg index 0978b814..b92f885f 100644 --- a/ansible/ansible.cfg +++ b/ansible/ansible.cfg @@ -1,9 +1,9 @@ [defaults] - # Define any custom roles used by applications installed by installer # this parameter is telling ansible what additional folder it should # browse while looking up for roles code # relative path ./application is mapped into ansible container under # /ansible/application where application roles should be found roles_path = /ansible/application +# Set log file log_path = /ansible/log/ansible.log diff --git a/ansible/roles/application/tasks/install.yml b/ansible/roles/application/tasks/install.yml index bee01e17..5cffdd07 100644 --- a/ansible/roles/application/tasks/install.yml +++ b/ansible/roles/application/tasks/install.yml @@ -49,6 +49,8 @@ - name: Build local helm repository make: chdir: "{{ app_helm_charts_infra_directory }}" + params: + SKIP_LINT: "TRUE" target: "{{ item }}" loop: "{{ app_helm_build_targets }}" environment: diff --git a/ansible/roles/package-repository/handlers/main.yml b/ansible/roles/package-repository/handlers/main.yml new file mode 100644 index 00000000..304cc873 --- /dev/null +++ b/ansible/roles/package-repository/handlers/main.yml @@ -0,0 +1,6 @@ +--- +- name: Restart NetworkManager + systemd: + name: NetworkManager + state: restarted + when: ansible_connection != 'docker' diff --git a/ansible/roles/package-repository/tasks/main.yml b/ansible/roles/package-repository/tasks/main.yml index 7dc2e76f..e2a5fd46 100644 --- a/ansible/roles/package-repository/tasks/main.yml +++ b/ansible/roles/package-repository/tasks/main.yml @@ -1,4 +1,20 @@ --- +- name: Disable DNS management in Network Manager + ini_file: + path: /etc/NetworkManager/NetworkManager.conf + state: present + no_extra_spaces: true + section: main + option: dns + value: none + owner: root + group: root + mode: 0644 + backup: false + when: ansible_os_family == 'RedHat' + notify: + - Restart NetworkManager + - name: Setup resolv.conf for node to find package repository by name from infra lineinfile: line: "nameserver {{ hostvars[groups.infrastructure[0]].cluster_ip }}" diff --git a/ansible/test/images/docker/ubuntu/Dockerfile b/ansible/test/images/docker/ubuntu/Dockerfile index 54416374..6dd079ad 100644 --- a/ansible/test/images/docker/ubuntu/Dockerfile +++ b/ansible/test/images/docker/ubuntu/Dockerfile @@ -4,8 +4,11 @@ FROM ubuntu:${RELEASE} # Systemd requires this env for ConditionVirtualization setting in unit files ENV container docker -# Python2.7 required by ansible -RUN apt-get update && apt-get -y install dbus systemd python openssh-server +# Install necessary packages +RUN apt-get update && apt-get -y install dbus systemd openssh-server iproute2 python3-docker + +# Create symlink python3 -> python +RUN ln -s /usr/bin/python3 /usr/bin/python EXPOSE 22 diff --git a/ansible/test/roles/prepare-docker-dind/tasks/main.yml b/ansible/test/roles/prepare-docker-dind/tasks/main.yml index c0bf1543..50efe143 100644 --- a/ansible/test/roles/prepare-docker-dind/tasks/main.yml +++ b/ansible/test/roles/prepare-docker-dind/tasks/main.yml @@ -1,24 +1,6 @@ --- -# Needed because host system has all mounts by default to shared, and -# some things may depend on mounts being shared if we run docker inside -# test env. -- name: "Make all mounts shared" - command: "mount --make-rshared /" - args: - warn: false +- include: rhel.yml + when: ansible_distribution in ["CentOS","Red Hat Enterprise Linux"] -- name: "Enable docker repository" - yum_repository: - name: "Docker" - description: Docker-ce repository - enabled: yes - baseurl: "https://download.docker.com/linux/centos/7/$basearch/stable" - gpgcheck: yes - gpgkey: https://download.docker.com/linux/centos/gpg - -- name: "Install docker" - package: - name: "docker-ce-{{ docker_version }}" - state: present - allow_downgrade: true - notify: Restart docker +- include: ubuntu.yml + when: ansible_distribution in ["Ubuntu","Debian"]
\ No newline at end of file diff --git a/ansible/test/roles/prepare-docker-dind/tasks/rhel.yml b/ansible/test/roles/prepare-docker-dind/tasks/rhel.yml new file mode 100644 index 00000000..4184ef05 --- /dev/null +++ b/ansible/test/roles/prepare-docker-dind/tasks/rhel.yml @@ -0,0 +1,24 @@ +--- +# Needed because host system has all mounts by default to shared, and +# some things may depend on mounts being shared if we run docker inside +# test env. +- name: "Make all mounts shared" + command: "mount --make-rshared /" + args: + warn: false + +- name: "Enable docker repository - yum" + yum_repository: + name: "Docker" + description: Docker-ce repository + enabled: yes + baseurl: "https://download.docker.com/linux/centos/7/$basearch/stable" + gpgcheck: yes + gpgkey: https://download.docker.com/linux/centos/gpg + +- name: "Install docker" + package: + name: "docker-ce-{{ docker_version }}" + state: present + allow_downgrade: true + notify: Restart docker diff --git a/ansible/test/roles/prepare-docker-dind/tasks/ubuntu.yml b/ansible/test/roles/prepare-docker-dind/tasks/ubuntu.yml new file mode 100644 index 00000000..a41c4c20 --- /dev/null +++ b/ansible/test/roles/prepare-docker-dind/tasks/ubuntu.yml @@ -0,0 +1,33 @@ +--- +# Needed because host system has all mounts by default to shared, and +# some things may depend on mounts being shared if we run docker inside +# test env. +- name: "Make all mounts shared" + command: "mount --make-rshared /" + args: + warn: false + +- name: "Install GNUPG for apt-key" + package: + name: "gnupg" + state: present + +- name: "Add an apt key" + apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 + state: present + +- name: "Enable docker repository - apt" + apt_repository: + repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" + state: present + validate_certs: true + filename: "Docker" + +- name: "Install docker - apt" + apt: + name: "docker-ce" + state: present + update_cache: true + notify: Restart docker diff --git a/build/package.py b/build/package.py index c0ca47a5..9e37d4bf 100755 --- a/build/package.py +++ b/build/package.py @@ -28,6 +28,7 @@ import glob import json import sys import os +import hashlib import tarfile import git @@ -82,20 +83,43 @@ def create_package_info_file(output_file, repository_list, tag, metadata): build_info = { 'Build_info': { 'build_date': datetime.now().strftime('%Y-%m-%d_%H-%M'), - 'Version': tag + 'Version': tag, + 'Packages': {} } } for repository in repository_list: build_info['Build_info'][ repository.config_reader().get_value('remote "origin"', 'url')] = repository.head.commit.hexsha - if len(metadata) != 0: - build_info['Build_info'][metadata[0]] = metadata[1] + if metadata: + for meta in metadata: + build_info['Build_info'].update(meta) with open(output_file, 'w') as outfile: json.dump(build_info, outfile, indent=4) +def add_checksum_info(output_dir): + """ + Add checksum information into package.info file + :param output_dir: directory where are packages + """ + tar_files = ['resources_package.tar', 'aux_package.tar', 'sw_package.tar'] + for tar_file in tar_files: + try: + checksum = hashlib.md5() + with open(os.path.join(output_dir, tar_file), 'rb') as f: + for chunk in iter(lambda: f.read(4096), b""): + checksum.update(chunk) + with open(os.path.join(output_dir, 'package.info'), 'r') as f: + json_data = json.load(f) + json_data['Build_info']['Packages'].update({tar_file: checksum.hexdigest()}) + with open(os.path.join(output_dir, 'package.info'), 'w') as f: + json.dump(json_data, f, indent=4) + except FileNotFoundError: + pass + + def create_package(tar_content, file_name): """ Creates packages @@ -109,6 +133,20 @@ def create_package(tar_content, file_name): output_tar_file.add(src, dst) +def metadata_validation(param): + """ + Validation of metadata parameters + :param param: parameter to be checked needs to be in format key=value + """ + try: + key, value = param.split('=') + assert (key and value) + return {key: value} + except (ValueError, AssertionError): + msg = "%r is not a valid parameter. Needs to be in format key=value" % param + raise argparse.ArgumentTypeError(msg) + + def build_offline_deliverables(build_version, application_repository_url, application_repository_reference, @@ -224,6 +262,7 @@ def build_offline_deliverables(build_version, aux_package_tar_path = os.path.join(output_dir, 'aux_package.tar') create_package(aux_content, aux_package_tar_path) + add_checksum_info(output_dir) shutil.rmtree(application_dir) @@ -265,8 +304,8 @@ def run_cli(): help='overwrite files in output directory') parser.add_argument('--debug', action='store_true', default=False, help='Turn on debug output') - parser.add_argument('--add-metadata', nargs=2, - help='additional metadata added into package.info, format: key value', default=[]) + parser.add_argument('--add-metadata', nargs="+", type=metadata_validation, + help='additional metadata added into package.info, format: key=value') args = parser.parse_args() if args.debug: diff --git a/build/requirements.txt b/build/requirements.txt index 39544458..441b3fcb 100644 --- a/build/requirements.txt +++ b/build/requirements.txt @@ -1,2 +1,2 @@ docker>=3.7.2 -gitpython==2.1.11 +gitpython==3.1.0 diff --git a/docs/BuildGuide.rst b/docs/BuildGuide.rst index 5b2e2486..6317760c 100644 --- a/docs/BuildGuide.rst +++ b/docs/BuildGuide.rst @@ -61,9 +61,9 @@ Subsequent steps are the same on both platforms: :: # install following packages - yum install -y docker-ce-18.09.5 python-pip git createrepo expect nodejs npm jq + yum install -y docker-ce-18.09.5 git createrepo expect nodejs npm jq - # install Python 3 (download scripts don't support Python 2 anymore) + # install Python 3 yum install -y python36 python36-pip # docker daemon must be running on host diff --git a/tools/cicdansible/heat/config.yaml b/tools/cicdansible/heat/config.yaml index e1f0309f..0521d72e 100644 --- a/tools/cicdansible/heat/config.yaml +++ b/tools/cicdansible/heat/config.yaml @@ -6,5 +6,5 @@ output: { all: "/dev/console" } #Initialization. runcmd: - | - set -efxu -o pipefail + set -efxu %{NOTIFY_COMMAND} --data-binary '{"status": "SUCCESS", "reason": "instance started successfully"}' diff --git a/tools/cicdansible/roles/install/tasks/install.yml b/tools/cicdansible/roles/install/tasks/install.yml index 529e2acf..5c4bcd81 100644 --- a/tools/cicdansible/roles/install/tasks/install.yml +++ b/tools/cicdansible/roles/install/tasks/install.yml @@ -14,7 +14,7 @@ unarchive: src: "resources/{{ hostvars[groups['resources'][0]].resources_sw_filename }}" dest: "{{ installer_deploy_path }}" -#Generate ansible inventory and extra vars. +#Generate ansible inventory and extra vars - name: "Generate ansible inventory for installer" template: src: inventory.yml.j2 diff --git a/tools/cicdansible/roles/install/templates/inventory.yml.j2 b/tools/cicdansible/roles/install/templates/inventory.yml.j2 index faec5903..9f7e08f8 100644 --- a/tools/cicdansible/roles/install/templates/inventory.yml.j2 +++ b/tools/cicdansible/roles/install/templates/inventory.yml.j2 @@ -1,5 +1,8 @@ all: vars: +{% if hostvars['infra'].ansible_distribution in ["Debian","Ubuntu"] %} + ansible_python_interpreter: "/usr/bin/python3" +{% endif %} ansible_ssh_private_key_file: /root/.ssh/id_rsa ansible_ssh_common_args: "-o StrictHostKeyChecking=no" children: diff --git a/tools/cicdansible/roles/setup_openstack_infrastructure/tasks/configure/volume.yml b/tools/cicdansible/roles/setup_openstack_infrastructure/tasks/configure/volume.yml index 8c553850..568b7202 100644 --- a/tools/cicdansible/roles/setup_openstack_infrastructure/tasks/configure/volume.yml +++ b/tools/cicdansible/roles/setup_openstack_infrastructure/tasks/configure/volume.yml @@ -7,7 +7,7 @@ partition_path: "{{ volume_path }}-part1" - name: "Wait for volume" #We do not do it normally, because we want to trigger udev (workaround for some bugs). - shell: "udevadm trigger && udevadm settle && [[ -b {{ volume_path }} ]]" + shell: "udevadm trigger && udevadm settle && [ -b {{ volume_path }} ]" register: result retries: 30 delay: 10 |