diff options
12 files changed, 149 insertions, 24 deletions
diff --git a/ansible/roles/package-repository/defaults/main.yml b/ansible/roles/package-repository/defaults/main.yml index 0557eda3..97b89bae 100644 --- a/ansible/roles/package-repository/defaults/main.yml +++ b/ansible/roles/package-repository/defaults/main.yml @@ -1,8 +1,17 @@ --- +package_type: + RedHat: rpm + Debian: deb +repo_patern: + RedHat: "*.repo" + Debian: "*.list" +repo_path: + RedHat: /etc/yum.repos.d/ + Debian: /etc/apt/ package_repositories: - name: "{{ app_name }}" file: "{{ app_name | lower }}" description: "{{ app_name | upper }} offline repository" - baseurl: "{{ 'http://repo.infra-server/rpm' if 'infrastructure' not in group_names else 'file://' + app_data_path + '/pkg/rpm' }}" + baseurl: "{{ 'http://repo.infra-server/' + package_type[ansible_os_family] if 'infrastructure' not in group_names else 'file://' + app_data_path + '/pkg/' + package_type[ansible_os_family] }}" gpgcheck: false enabled: true diff --git a/ansible/roles/package-repository/molecule/default/Dockerfile.j2 b/ansible/roles/package-repository/molecule/default/Dockerfile.j2 index 0a605536..b76a6dd7 100644 --- a/ansible/roles/package-repository/molecule/default/Dockerfile.j2 +++ b/ansible/roles/package-repository/molecule/default/Dockerfile.j2 @@ -6,9 +6,12 @@ FROM {{ item.registry.url }}/{{ item.image }} FROM {{ item.image }} {% endif %} -RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y sudo bash ca-certificates python3-apt && apt-get clean; \ elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \ elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \ elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi + +# Create symlink python3 -> python +RUN if [ $(command -v apt-get) ]; then ln -s /usr/bin/python3 /usr/bin/python; fi diff --git a/ansible/roles/package-repository/molecule/default/molecule.yml b/ansible/roles/package-repository/molecule/default/molecule.yml index df2024d7..7abb08d4 100644 --- a/ansible/roles/package-repository/molecule/default/molecule.yml +++ b/ansible/roles/package-repository/molecule/default/molecule.yml @@ -36,8 +36,6 @@ provisioner: all: app_name: moleculetestapp app_data_path: "/opt/{{ app_name }}" -scenario: - name: default verifier: name: testinfra options: diff --git a/ansible/roles/package-repository/molecule/default/tests/test_infrastructure-server.py b/ansible/roles/package-repository/molecule/default/tests/test_infrastructure-server.py index 9fb1a4f9..5b3fce4d 100644 --- a/ansible/roles/package-repository/molecule/default/tests/test_infrastructure-server.py +++ b/ansible/roles/package-repository/molecule/default/tests/test_infrastructure-server.py @@ -7,10 +7,17 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( def test_onap_repo(host): - fc = host.file('/etc/yum.repos.d/moleculetestapp.repo').content_string - expected_content = """[moleculetestapp] + os = host.system_info.distribution + if os == "centos": + fc = host.file('/etc/yum.repos.d/moleculetestapp.repo').content_string + expected_content = """[moleculetestapp] baseurl = file:///opt/moleculetestapp/pkg/rpm enabled = 1 gpgcheck = 0 name = MOLECULETESTAPP offline repository""" - assert fc == expected_content + assert fc == expected_content + elif os == "ubuntu": + fc = host.file('/etc/apt/sources.list.d/moleculetestapp.list') + fc = fc.content_string + ec = "deb [trusted=yes] file:///opt/moleculetestapp/pkg/deb ./" + assert fc == ec diff --git a/ansible/roles/package-repository/molecule/default/tests/test_kubernetes-node-1.py b/ansible/roles/package-repository/molecule/default/tests/test_kubernetes-node-1.py index fda85e8d..c1831f70 100644 --- a/ansible/roles/package-repository/molecule/default/tests/test_kubernetes-node-1.py +++ b/ansible/roles/package-repository/molecule/default/tests/test_kubernetes-node-1.py @@ -7,10 +7,17 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( def test_onap_repo(host): - fc = host.file('/etc/yum.repos.d/moleculetestapp.repo').content_string - expected_content = """[moleculetestapp] + os = host.system_info.distribution + if os == "centos": + fc = host.file('/etc/yum.repos.d/moleculetestapp.repo').content_string + expected_content = """[moleculetestapp] baseurl = http://repo.infra-server/rpm enabled = 1 gpgcheck = 0 name = MOLECULETESTAPP offline repository""" - assert fc == expected_content + assert fc == expected_content + elif os == "ubuntu": + fc = host.file('/etc/apt/sources.list.d/moleculetestapp.list') + fc = fc.content_string + ec = "deb [trusted=yes] http://repo.infra-server/deb ./" + assert fc == ec diff --git a/ansible/roles/package-repository/molecule/ubuntu/molecule.yml b/ansible/roles/package-repository/molecule/ubuntu/molecule.yml new file mode 100644 index 00000000..07c2d888 --- /dev/null +++ b/ansible/roles/package-repository/molecule/ubuntu/molecule.yml @@ -0,0 +1,51 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint +platforms: + - name: infrastructure-server + image: ${PLATFORM_DISTRO:-ubuntu}:${ISTRO_VERSION:-18.04} + dockerfile: ../default/Dockerfile.j2 + groups: + - infrastructure + # By design certain file like /etc/resolv.conf cannot be edited in docker + # container. To enable role to "edit" /etc/resolv.conf define value already to same. + dns_servers: + - 6.5.4.3 + + - name: kubernetes-node-1 + image: ${PLATFORM_DISTRO:-ubuntu}:${ISTRO_VERSION:-18.04} + dockerfile: ../default/Dockerfile.j2 + groups: + - kubernetes + # By design certain file like /etc/resolv.conf cannot be edited in docker + # container. To enable role to "edit" /etc/resolv.conf define value already to same. + dns_servers: + - 6.5.4.3 + +provisioner: + name: ansible + lint: + name: ansible-lint + playbooks: + converge: ../default/playbook.yml + inventory: + host_vars: + infrastructure-server: + cluster_ip: 6.5.4.3 + group_vars: + all: + app_name: moleculetestapp + app_data_path: "/opt/{{ app_name }}" +scenario: + name: ubuntu +verifier: + name: testinfra + options: + verbose: true + lint: + name: flake8 + directory: ../default/tests diff --git a/ansible/roles/package-repository/tasks/Debian.yml b/ansible/roles/package-repository/tasks/Debian.yml new file mode 100644 index 00000000..76323eb4 --- /dev/null +++ b/ansible/roles/package-repository/tasks/Debian.yml @@ -0,0 +1,8 @@ +--- +- name: Add application offline package repository + apt_repository: + repo: "deb [trusted=yes] {{ item.baseurl | default('') }} ./" + state: "{{ item.state | default('present') }}" + filename: "{{ item.file }}" + update_cache: false + loop: "{{ package_repositories }}" diff --git a/ansible/roles/package-repository/tasks/RedHat.yml b/ansible/roles/package-repository/tasks/RedHat.yml new file mode 100644 index 00000000..49b29718 --- /dev/null +++ b/ansible/roles/package-repository/tasks/RedHat.yml @@ -0,0 +1,11 @@ +--- +- name: Add application offline package repository + yum_repository: + name: "{{ item.name }}" + file: "{{ item.file }}" + description: "{{ item.description | default('') }}" + baseurl: "{{ item.baseurl | default('') }}" + gpgcheck: "{{ item.gpgcheck | default(true) }}" + enabled: "{{ item.enabled | default(false) }}" + state: "{{ item.state | default('present') }}" + loop: "{{ package_repositories }}" diff --git a/ansible/roles/package-repository/tasks/main.yml b/ansible/roles/package-repository/tasks/main.yml index e2a5fd46..763ee659 100644 --- a/ansible/roles/package-repository/tasks/main.yml +++ b/ansible/roles/package-repository/tasks/main.yml @@ -23,12 +23,12 @@ insertbefore: BOF unsafe_writes: true -- name: Disable all OS default repositories +- name: Disable all default repositories block: - name: Find repo files names find: - paths: /etc/yum.repos.d - pattern: '*.repo' + paths: "{{ repo_path[ansible_os_family] }}" + pattern: "{{ repo_patern[ansible_os_family] }}" register: repo_files - name: Get all defined offline repo names @@ -49,13 +49,4 @@ loop: "{{ repo_files.files }}" when: "(item.path | basename | splitext)[0] not in package_repositories_names" -- name: Add application offline package repository - yum_repository: - name: "{{ item.name }}" - file: "{{ item.file }}" - description: "{{ item.description | default('') }}" - baseurl: "{{ item.baseurl | default('') }}" - gpgcheck: "{{ item.gpgcheck | default(true) }}" - enabled: "{{ item.enabled | default(false) }}" - state: "{{ item.state | default('present') }}" - loop: "{{ package_repositories }}" +- include_tasks: "{{ ansible_os_family }}.yml" diff --git a/ansible/roles/vncserver/molecule/ubuntu/molecule.yml b/ansible/roles/vncserver/molecule/ubuntu/molecule.yml new file mode 100644 index 00000000..d821cd73 --- /dev/null +++ b/ansible/roles/vncserver/molecule/ubuntu/molecule.yml @@ -0,0 +1,39 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint +platforms: + - name: infrastructure-server + image: molecule-${PREBUILD_PLATFORM_DISTRO:-ubuntu}:${PREBUILD_DISTRO_VERSION:-18.04} + pre_build_image: True + privileged: true + volumes: + - /var/lib/docker + override_command: False + groups: + - infrastructure +provisioner: + name: ansible + lint: + name: ansible-lint + playbooks: + prepare: ../default/prepare.yml + converge: ../default/playbook.yml + cleanup: ../default/cleanup.yml + env: + ANSIBLE_ROLES_PATH: ../../../../test/roles + inventory: + links: + group_vars: ../../../../group_vars +scenario: + name: ubuntu +verifier: + name: testinfra + lint: + name: flake8 + options: + v: 1 + directory: ../default/tests/ diff --git a/ansible/test/roles/prepare-vncserver/tasks/main.yml b/ansible/test/roles/prepare-vncserver/tasks/main.yml index cb7a5f8a..bb5a43ef 100644 --- a/ansible/test/roles/prepare-vncserver/tasks/main.yml +++ b/ansible/test/roles/prepare-vncserver/tasks/main.yml @@ -14,6 +14,7 @@ name: "{{ vnc_server_image }}" state: present archive_path: /tmp/vncserver.tar + timeout: 240 - name: Copy vnc server image to node copy: diff --git a/build/creating_data/docker-images-collector.sh b/build/creating_data/docker-images-collector.sh index 76ee9016..8789350c 100755 --- a/build/creating_data/docker-images-collector.sh +++ b/build/creating_data/docker-images-collector.sh @@ -60,7 +60,7 @@ create_list() { else >&2 echo -e \n" !!! ${1} sybsystem does not exist !!!"\n fi - helm template "${SUBSYS_DIR}" | grep 'image:\ \|tag_version:\ \|h._image' | + helm template --set global.masterPassword=TemplatePassword -f ${PROJECT_DIR}/values.yaml "${SUBSYS_DIR}" | grep 'image:\ \|tag_version:\ \|h._image' | sed -e 's/^.*\"h._image\"\ :\ //; s/^.*\"\(.*\)\".*$/\1/' \ -e 's/\x27\|,//g; s/^.*\(image\|tag_version\):\ //' | tr -d '\r' } |