From a5cb7525887738a7620a4725c4f682e5c7f673f7 Mon Sep 17 00:00:00 2001 From: Olivier Clavel Date: Wed, 13 Dec 2023 03:22:38 +0100 Subject: [PATCH] Fix various deprecation on CI to restart maintenance (#393) Major work on CI to fix many deprecation and problems preventing it from running. Current PRs will be rebased so they can be checked. This work includes (see PR commit details for more information * Upgrade travis configuration * Fix and refactor for molecule lint being deprecated - Run linting directly from travis - Remove now useless default scenario - Add flake8 as pre-commit (and update hooks versions) - Update ansible lint hook option --write > --fix - Fix new ansible lint rule regarding reserved var names (args > call_args for call_script) * Move molecule docker driver to molecule-plugins * Manage testinfra tests in scenarios with symlinks to DRY * Fix several regressions on apt test * Upgrade CI platforms: - Totally deprecate centos - Welcome to rockylinux as a close friend to RHEL platforms - Add debian bookwork, deprecate buster - Run CI on rockylinux9 and Debian Bookworm --- .pre-commit-config.yaml | 15 ++- .travis.yml | 26 +++-- README.md | 27 +++-- .../converge.yml | 0 .../molecule.yml | 14 +-- .../tests/test_apt_repo.py | 1 + .../tests/test_default.py | 0 .../tests/test_apt_repo.py | 107 ----------------- .../tests/test_default.py | 23 ---- molecule/default-debian_buster/molecule.yml | 6 - .../converge.yml | 0 .../molecule.yml | 13 +-- .../tests/test_default.py | 0 .../converge.yml | 0 .../molecule.yml | 15 +-- .../tests/test_default.py | 0 molecule/default-ubuntu_20.04/molecule.yml | 6 - .../tests/test_apt_repo.py | 108 +----------------- .../tests/test_default.py | 24 +--- molecule/default-ubuntu_22.04/molecule.yml | 6 - .../tests/test_apt_repo.py | 108 +----------------- .../tests/test_default.py | 24 +--- molecule/default/converge.yml | 3 - molecule/default/molecule.yml | 63 ---------- molecule/nexus_common_test_vars.yml | 8 +- molecule/test_apt_repo.py | 41 ++++--- requirements.txt | 2 +- tasks/call_script.yml | 2 +- tasks/create_task_each.yml | 2 +- tasks/delete_blobstore_each.yml | 2 +- tasks/delete_repo_each.yml | 2 +- tasks/main.yml | 32 +++--- tasks/nexus_install.yml | 2 +- tasks/setup_ldap_each.yml | 2 +- 34 files changed, 110 insertions(+), 574 deletions(-) rename molecule/{default-centos7 => default-debian_bookworm}/converge.yml (100%) rename molecule/{default-debian_bullseye => default-debian_bookworm}/molecule.yml (83%) create mode 120000 molecule/default-debian_bookworm/tests/test_apt_repo.py rename molecule/{default-centos7 => default-debian_bookworm}/tests/test_default.py (100%) delete mode 100644 molecule/default-debian_bullseye/tests/test_apt_repo.py delete mode 100644 molecule/default-debian_bullseye/tests/test_default.py rename molecule/{default-centos8 => default-rockylinux8}/converge.yml (100%) rename molecule/{default-centos7 => default-rockylinux8}/molecule.yml (86%) rename molecule/{default-centos8 => default-rockylinux8}/tests/test_default.py (100%) rename molecule/{default-debian_bullseye => default-rockylinux9}/converge.yml (100%) rename molecule/{default-centos8 => default-rockylinux9}/molecule.yml (83%) rename molecule/{default => default-rockylinux9}/tests/test_default.py (100%) mode change 100644 => 120000 molecule/default-ubuntu_20.04/tests/test_apt_repo.py mode change 100644 => 120000 molecule/default-ubuntu_20.04/tests/test_default.py mode change 100644 => 120000 molecule/default-ubuntu_22.04/tests/test_apt_repo.py mode change 100644 => 120000 molecule/default-ubuntu_22.04/tests/test_default.py delete mode 100644 molecule/default/converge.yml delete mode 100644 molecule/default/molecule.yml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c61a4a00..bfdfcb57 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ fail_fast: true repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-merge-conflict - id: check-added-large-files @@ -17,22 +17,27 @@ repos: - id: requirements-txt-fixer - repo: https://github.com/adrienverge/yamllint.git - rev: v1.30.0 + rev: v1.33.0 hooks: - id: yamllint args: [--format, parsable, --strict] - repo: https://github.com/ansible-community/ansible-lint - rev: v6.14.3 + rev: v6.22.1 hooks: - id: ansible-lint - args: [--write] + args: [--fix] additional_dependencies: - keyring - jmespath - ansible - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 23.11.0 hooks: - id: black + + - repo: https://github.com/PyCQA/flake8 + rev: 6.1.0 + hooks: + - id: flake8 diff --git a/.travis.yml b/.travis.yml index cee6daa6..ccbef7fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,12 @@ --- -branches: - only: - - main - +dist: jammy sudo: required - language: python +python: "3.10" -python: 3.9 +branches: + only: + - main cache: pip: true @@ -16,7 +15,7 @@ cache: env: global: - TRAVIS_BUILD_DIR: /home/travis/build/ansible-thoteam.nexus3-oss + - TRAVIS_BUILD_DIR=/home/travis/build/ansible-thoteam.nexus3-oss services: - docker @@ -29,6 +28,7 @@ before_install: - cd $TRAVIS_BUILD_DIR install: + - pip install --upgrade pip - pip install --upgrade --upgrade-strategy eager -r requirements.txt stages: @@ -41,15 +41,17 @@ jobs: name: Checking overall syntax (groovy, yaml, python) script: |- ./tests/test_groovySyntax.sh - molecule test + yamllint . + ansible-lint + flake8 - stage: test - name: Test on centos7 + name: Test on rockylinux9 script: |- - molecule test -s default-centos7 + molecule test -s default-rockylinux9 - stage: test - name: Test on Debian Bullseye + name: Test on Debian Bookworm script: |- - molecule test -s default-debian_bullseye + molecule test -s default-debian_bookworm notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/README.md b/README.md index aa719590..ebf0ffb2 100644 --- a/README.md +++ b/README.md @@ -1093,15 +1093,15 @@ This role includes tests and CI integration through travis. At time being, we te * groovy scripts syntax * yaml syntax and coding standard (yamllint) * ansible good practices (ansible lint) -* a set of basic deployments on 3 different linux platforms - * Centos 8 - * Debian buster - * Ubuntu bionic (18.04) +* a set of basic deployments on 2 different linux platforms + * Rockylinux 9 (as a close parent of RHEL products since centos is deprecated) + * Debian 12 Bookworm -Other tests are available for older platforms but not played on CI for performance reasons: -* Centos 7 -* Debian stretch -* Ubuntu xenial (16.04) +Other tests are available for older/different platforms but not played on CI for performance reasons: +* Rockylinux 8 +* Debian 11 bullseye +* Ubuntu 20.04 Focal +* Ubuntu 22.04 Jammy #### Groovy syntax @@ -1129,11 +1129,14 @@ deactivate ``` Please have a look at molecule documentation (a good start is `molecule --help`) for further usage. -The current proposed scenarii refer to the tested platforms (see `molecule/` directory). If you launch a scenario ans leave the container running (i.e. using `converge` for a simple deploy), you can access the running instance from your browser at https://localhost:. See the `molecule//molecule.yml` file for detail. As a convenience, here is the correspondence between scenarii and configured ports: -* default-centos7 => https://localhost:8090 -* default-centos8 => https://localhost:8091 +The current proposed scenarii refer to the tested platforms (see `molecule/` directory). If you launch a scenario +and leave the container running (i.e. using `converge` for a simple deploy), you can access the running instance +from your browser at https://localhost:. See the `molecule//molecule.yml` file for detail. +As a convenience, here is the correspondence between scenarii and configured ports: +* default-rockylinux8 => https://localhost:8090 +* default-rockylinux9 => https://localhost:8091 * efault-debian_bullseye => https://localhost:8092 -* default-debian_buster => https://localhost:8093 +* default-debian_bookworm => https://localhost:8093 * default-ubuntu_20.04 => https://localhost:8094 * default-ubuntu_22.04 => https://localhost:8095 diff --git a/molecule/default-centos7/converge.yml b/molecule/default-debian_bookworm/converge.yml similarity index 100% rename from molecule/default-centos7/converge.yml rename to molecule/default-debian_bookworm/converge.yml diff --git a/molecule/default-debian_bullseye/molecule.yml b/molecule/default-debian_bookworm/molecule.yml similarity index 83% rename from molecule/default-debian_bullseye/molecule.yml rename to molecule/default-debian_bookworm/molecule.yml index aedaa2d8..5074ffdf 100644 --- a/molecule/default-debian_bullseye/molecule.yml +++ b/molecule/default-debian_bookworm/molecule.yml @@ -8,22 +8,16 @@ driver: safe_files: - nexus-downloads -lint: | - set -e - yamllint . - ansible-lint - flake8 - platforms: - - name: nexus3-oss-debian-bullseye - hostname: nexus3-oss-debian-bullseye - image: thoteam/molecule_apache_openjdk8:debian_bullseye + - name: nexus3-oss-debian-bookworm + hostname: nexus3-oss-debian-bookworm + image: thoteam/molecule_apache_openjdk8:debian_bookworm command: lib/systemd/systemd pull: true pre_build_image: true privileged: true published_ports: - - 8092:443 + - 8093:443 groups: - nexus networks: &nexus_networks diff --git a/molecule/default-debian_bookworm/tests/test_apt_repo.py b/molecule/default-debian_bookworm/tests/test_apt_repo.py new file mode 120000 index 00000000..43ab9ab4 --- /dev/null +++ b/molecule/default-debian_bookworm/tests/test_apt_repo.py @@ -0,0 +1 @@ +../../test_apt_repo.py \ No newline at end of file diff --git a/molecule/default-centos7/tests/test_default.py b/molecule/default-debian_bookworm/tests/test_default.py similarity index 100% rename from molecule/default-centos7/tests/test_default.py rename to molecule/default-debian_bookworm/tests/test_default.py diff --git a/molecule/default-debian_bullseye/tests/test_apt_repo.py b/molecule/default-debian_bullseye/tests/test_apt_repo.py deleted file mode 100644 index f7ad6f0b..00000000 --- a/molecule/default-debian_bullseye/tests/test_apt_repo.py +++ /dev/null @@ -1,107 +0,0 @@ -"""testinfra file for apt specific tests.""" - -import os -import testinfra.utils.ansible_runner - -""" -These test should only run on debian based destributions -""" - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ["MOLECULE_INVENTORY_FILE"] -).get_hosts("nexus") - -apt_pub_key = """ ------BEGIN PGP PUBLIC KEY BLOCK----- - -mQGNBGNSbLEBDADGJXWoQwhjjgmGbMdnhfneYU2qjfMlgdoTH2oqkir6aaqHdS6l -88YUt/4mBAzaQhcETm7sIlrlAvXyfH4/i3ATwI4SUYUCl1fIZ9beRD3WWBwCiYMZ -XT0ZByrDL+aGpRO6xl0LCPr1loqHbvt2ZesoSn77Zv4tGHVLPiryG1KTxQPRCU4d -Ydg9wCwlrGseExA4O8ujgOeyo/ObxXrCilxJzvNf/21/KGSa54FzMyGiWvN7tOMT -Z9kau/bToIjwi4ME4nLx4T5c5qtYAoqlnbRR12pHBlx7RckncS1M/r+E1nX6GzeJ -cx4qAgd0HD226Kro3bahfM8ZWktbtJ7cytbPBwZ64Fu7kTzS0tfMPu0VBNK+EfrK -woDOoqg1i92r8VgTL6BQ+ouQy7BwWLKc6AEk/+M2f/L1ifDWay/uQdjNa27OKn0R -3cBBS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+6n06XYJhghSWkYr0SyVR7ejxQBsrdQU -69d9mOouL7QJGPmhPLtGG+yX/dw85qT45AXri0hsAy5bfKIMhGplvZTbIsSLEmIt -VDnil3wwAXDD/czbsg39MdA2r7bgtixjtaP9t4S4jkrZqS9yl6sCGhcLMr6TiSdf -ibKs9f2MxYZRV3Js439WjppGTLgwTICcdW+qna1bmqc1oGewrr1laOER3q3+C221 -cVjr8Puac0aBZuGPcBIGsd9L8MwzNAu1t8zHKc3jlfs7B0++NSKTAJNyJRhw9CKU -qL9xenUazaqpe5n60i//cB1aOF0qb8vCEocAEQEAAYkBtgQYAQoAIBYhBAeS2LTO -P1QCZyBX3QPyCQyBuqATBQJjUmyxAhsMAAoJEAPyCQyBuqAT6qsMAI9tFK4C4I01 -o6sD5MI6lnXHGFXfsN6/QJV6AOHC64g+s3K6+XM+8dOy4KcnfDdouEQYs5X1n2zx -nOV760YmnqCA7yk4p32LsW4zRp9Hs4rNPU0K4MnLLkEs24S99ohNQQhKauMxmFAZ -yH767j1oN2vFTdwANKswpkszfzEnGo0rFN+uIok1ENsB0cQWoyF/BSpOX2/MvCap -Lvf8yzAWqdQiF1zgcShKrpXny+rbI3owrDBSJ4VTAsKWbiXgbEh7gx7kZQOj4Ilu -bEKDmCbp2KH1RTlYGxR36x4B2i6oC+wJ1KYqbX/ZOsyXajH6s35fR551Ttlkz1HH -kUFDmTnFRhIhaiG8aytyHrQpNdXQz9pUcLZEtttBcAvelj5iWiWg86nkPGR/fFzs -KETG0Jx8lydvuBtPlK+MgTRsPDr3sntDrkdmE5CWvk75VekDO5zTuLFS2QTkhWSI -ztL8V2T47uABUGCunyFxhVRM7q9VQIRC+i7bEO3v0J6R2RZlI2A7tQ== -=Oq1K ------END PGP PUBLIC KEY BLOCK----- -""" - - -def test_apt_package_upload(host: testinfra.host.Host): - """Test we can upload an apt package to repository.""" - # Copy debian test package - host.ansible( - "get_url", - "url=https://github.com/ansible-ThoTeam/nexushello-apt-package/releases" - "/download/v1.0.1/nexushello_1.0.1_all.deb dest=/tmp", - check=False, - ) - - upload = host.run( - 'curl -X POST "https://localhost/service/rest/v1/components?repository=private_ubuntu_18.04" -k ' - "-u admin:changeme " - '-H "accept: application/json" ' - '-H "Content-Type: multipart/form-data" ' - '-F "apt.asset=@/tmp/nexushello_1.0.1_all.deb;type=application/vnd.debian.binary-package"' - ) - assert upload.exit_status == 0 - - # Install hello-world package on host from uploaded file - host.run( - "echo deb https://localhost/repository/private_ubuntu_18.04 bionic main " - "> /etc/apt/sources.list.d/nexushello.list" - ) - - # Disable ssl verification as we use a self signed cert for tests - host.run( - """cat > /etc/apt/apt.conf.d/no-verify-ssl << EOF -Acquire::https { - Verify-Peer \"false\"; - Verify-Host \"false\"; -} -EOF""" - ) - - # Import gpg key of our repo - host.run(f'echo "{apt_pub_key}" > /tmp/pub.key') - host.run("apt-key add /tmp/pub.key") - - # Install package - host.ansible( - "apt", - "name=nexushello state=present update-cache=true", - check=False, - become=True, - ) - - assert host.run("nexushello").stdout == "Hello nexus !\n" diff --git a/molecule/default-debian_bullseye/tests/test_default.py b/molecule/default-debian_bullseye/tests/test_default.py deleted file mode 100644 index 5d718528..00000000 --- a/molecule/default-debian_bullseye/tests/test_default.py +++ /dev/null @@ -1,23 +0,0 @@ -"""Default testinfra file for the role.""" - -import os - -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ["MOLECULE_INVENTORY_FILE"] -).get_hosts("nexus") - - -def test_npm_scoped_package_download(host): - """Test if we can download npm scoped packages.""" - test_package_url = "https://localhost/repository/npm-public/@angular%2fcore" - - get_url_options = ( - f"url='{test_package_url}' dest='/tmp/testfile' force='yes' validate_certs='no'" - ) - - download = host.ansible("get_url", get_url_options, check=False) - - assert download["status_code"] == 200 - assert download["state"] == "file" diff --git a/molecule/default-debian_buster/molecule.yml b/molecule/default-debian_buster/molecule.yml index b98dba34..1c35b07b 100644 --- a/molecule/default-debian_buster/molecule.yml +++ b/molecule/default-debian_buster/molecule.yml @@ -8,12 +8,6 @@ driver: safe_files: - nexus-downloads -lint: | - set -e - yamllint . - ansible-lint - flake8 - platforms: - name: nexus3-oss-debian-buster hostname: nexus3-oss-debian-buster diff --git a/molecule/default-centos8/converge.yml b/molecule/default-rockylinux8/converge.yml similarity index 100% rename from molecule/default-centos8/converge.yml rename to molecule/default-rockylinux8/converge.yml diff --git a/molecule/default-centos7/molecule.yml b/molecule/default-rockylinux8/molecule.yml similarity index 86% rename from molecule/default-centos7/molecule.yml rename to molecule/default-rockylinux8/molecule.yml index 6acc50f9..95965bba 100644 --- a/molecule/default-centos7/molecule.yml +++ b/molecule/default-rockylinux8/molecule.yml @@ -8,16 +8,10 @@ driver: safe_files: - nexus-downloads -lint: | - set -e - yamllint . - ansible-lint - flake8 - platforms: - - name: nexus3-oss-centos-7 - hostname: nexus3-oss-centos7 - image: thoteam/molecule_apache_openjdk8:centos7 + - name: nexus3-oss-rockylinux8 + hostname: nexus3-oss-rockylinux8 + image: thoteam/molecule_apache_openjdk8:rockylinux8 pull: true pre_build_image: true privileged: true @@ -29,6 +23,7 @@ platforms: networks: &nexus_networks - name: nexus-default volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:rw - ${MOLECULE_PROJECT_DIRECTORY}/molecule/.nexus-downloads:/nexus-downloads - name: slapd-server-mock diff --git a/molecule/default-centos8/tests/test_default.py b/molecule/default-rockylinux8/tests/test_default.py similarity index 100% rename from molecule/default-centos8/tests/test_default.py rename to molecule/default-rockylinux8/tests/test_default.py diff --git a/molecule/default-debian_bullseye/converge.yml b/molecule/default-rockylinux9/converge.yml similarity index 100% rename from molecule/default-debian_bullseye/converge.yml rename to molecule/default-rockylinux9/converge.yml diff --git a/molecule/default-centos8/molecule.yml b/molecule/default-rockylinux9/molecule.yml similarity index 83% rename from molecule/default-centos8/molecule.yml rename to molecule/default-rockylinux9/molecule.yml index f8d5268f..577127eb 100644 --- a/molecule/default-centos8/molecule.yml +++ b/molecule/default-rockylinux9/molecule.yml @@ -8,16 +8,10 @@ driver: safe_files: - nexus-downloads -lint: | - set -e - yamllint . - ansible-lint - flake8 - platforms: - - name: nexus3-oss-centos-8 - hostname: nexus3-oss-centos8 - image: thoteam/molecule_apache_openjdk8:centos8 + - name: nexus3-oss-rockylinux9 + hostname: nexus3-oss-rockylinux9 + image: thoteam/molecule_apache_openjdk8:rockylinux9 pull: true pre_build_image: true privileged: true @@ -25,8 +19,9 @@ platforms: - 8091:443 override_command: false volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro + - /sys/fs/cgroup:/sys/fs/cgroup:rw - ${MOLECULE_PROJECT_DIRECTORY}/molecule/.nexus-downloads:/nexus-downloads + cgroupns_mode: host groups: - nexus networks: &nexus_networks diff --git a/molecule/default/tests/test_default.py b/molecule/default-rockylinux9/tests/test_default.py similarity index 100% rename from molecule/default/tests/test_default.py rename to molecule/default-rockylinux9/tests/test_default.py diff --git a/molecule/default-ubuntu_20.04/molecule.yml b/molecule/default-ubuntu_20.04/molecule.yml index 7bc6324d..5e83677c 100644 --- a/molecule/default-ubuntu_20.04/molecule.yml +++ b/molecule/default-ubuntu_20.04/molecule.yml @@ -8,12 +8,6 @@ driver: safe_files: - nexus-downloads -lint: | - set -e - yamllint . - ansible-lint - flake8 - platforms: - name: nexus3-oss-ubuntu-20.04 hostname: nexus3-oss-ubuntu-20.04 diff --git a/molecule/default-ubuntu_20.04/tests/test_apt_repo.py b/molecule/default-ubuntu_20.04/tests/test_apt_repo.py deleted file mode 100644 index 1a8643be..00000000 --- a/molecule/default-ubuntu_20.04/tests/test_apt_repo.py +++ /dev/null @@ -1,107 +0,0 @@ -"""testinfra file for apt specific tests.""" - -import os -import testinfra.utils.ansible_runner - -""" -These test should only run on debian based destributions -""" - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ["MOLECULE_INVENTORY_FILE"] -).get_hosts("nexus") - -apt_pub_key = """ ------BEGIN PGP PUBLIC KEY BLOCK----- - -mQGNBGNSbLEBDADGJ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Xny+rbI3owrDBSJ4VTAsKWbiXgbEh7gx7kZQOj4Ilu -bEKDmCbp2KH1RTlYGxR36x4B2i6oC+wJ1KYqbX/ZOsyXajH6s35fR551Ttlkz1HH -kUFDmTnFRhIhaiG8aytyHrQpNdXQz9pUcLZEtttBcAvelj5iWiWg86nkPGR/fFzs -KETG0Jx8lydvuBtPlK+MgTRsPDr3sntDrkdmE5CWvk75VekDO5zTuLFS2QTkhWSI -ztL8V2T47uABUGCunyFxhVRM7q9VQIRC+i7bEO3v0J6R2RZlI2A7tQ== -=Oq1K ------END PGP PUBLIC KEY BLOCK----- -""" - - -def test_apt_package_upload(host: testinfra.host.Host): - """Test we can upload an apt package to repository.""" - # Copy debian test package - host.ansible( - "get_url", - "url=https://github.com/ansible-ThoTeam/nexushello-apt-package/releases" - "/download/v1.0.1/nexushello_1.0.1_all.deb dest=/tmp", - check=False, - ) - - upload = host.run( - 'curl -X POST "https://localhost/service/rest/v1/components?repository=private_ubuntu_18.04" -k ' - "-u admin:changeme " - '-H "accept: application/json" ' - '-H "Content-Type: multipart/form-data" ' - '-F "apt.asset=@/tmp/nexushello_1.0.1_all.deb;type=application/vnd.debian.binary-package"' - ) - assert upload.exit_status == 0 - - # Install hello-world package on host from uploaded file - host.run( - "echo deb https://localhost/repository/private_ubuntu_18.04 bionic main " - "> /etc/apt/sources.list.d/nexushello.list" - ) - - # Disable ssl verification as we use a self signed cert for tests - host.run( - """cat > /etc/apt/apt.conf.d/no-verify-ssl << EOF -Acquire::https { - Verify-Peer \"false\"; - Verify-Host \"false\"; -} -EOF""" - ) - - # Import gpg key of our repo - host.run(f'echo "{apt_pub_key}" > /tmp/pub.key') - host.run("apt-key add /tmp/pub.key") - - # Install package - host.ansible( - "apt", - "name=nexushello state=present update-cache=true", - check=False, - become=True, - ) - - assert host.run("nexushello").stdout == "Hello nexus !\n" diff --git a/molecule/default-ubuntu_20.04/tests/test_apt_repo.py b/molecule/default-ubuntu_20.04/tests/test_apt_repo.py new file mode 120000 index 00000000..43ab9ab4 --- /dev/null +++ b/molecule/default-ubuntu_20.04/tests/test_apt_repo.py @@ -0,0 +1 @@ +../../test_apt_repo.py \ No newline at end of file diff --git a/molecule/default-ubuntu_20.04/tests/test_default.py b/molecule/default-ubuntu_20.04/tests/test_default.py deleted file mode 100644 index 5d718528..00000000 --- a/molecule/default-ubuntu_20.04/tests/test_default.py +++ /dev/null @@ -1,23 +0,0 @@ -"""Default testinfra file for the role.""" - -import os - -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ["MOLECULE_INVENTORY_FILE"] -).get_hosts("nexus") - - -def test_npm_scoped_package_download(host): - """Test if we can download npm scoped packages.""" - test_package_url = "https://localhost/repository/npm-public/@angular%2fcore" - - get_url_options = ( - f"url='{test_package_url}' dest='/tmp/testfile' force='yes' validate_certs='no'" - ) - - download = host.ansible("get_url", get_url_options, check=False) - - assert download["status_code"] == 200 - assert download["state"] == "file" diff --git a/molecule/default-ubuntu_20.04/tests/test_default.py b/molecule/default-ubuntu_20.04/tests/test_default.py new file mode 120000 index 00000000..7889e2fe --- /dev/null +++ b/molecule/default-ubuntu_20.04/tests/test_default.py @@ -0,0 +1 @@ +../../test_default.py \ No newline at end of file diff --git a/molecule/default-ubuntu_22.04/molecule.yml b/molecule/default-ubuntu_22.04/molecule.yml index 3529c939..d2f371e1 100644 --- a/molecule/default-ubuntu_22.04/molecule.yml +++ b/molecule/default-ubuntu_22.04/molecule.yml @@ -8,12 +8,6 @@ driver: safe_files: - nexus-downloads -lint: | - set -e - yamllint . - ansible-lint - flake8 - platforms: - name: nexus3-oss-ubuntu-22.04 hostname: nexus3-oss-ubuntu-22.04 diff --git a/molecule/default-ubuntu_22.04/tests/test_apt_repo.py b/molecule/default-ubuntu_22.04/tests/test_apt_repo.py deleted file mode 100644 index 1a8643be..00000000 --- a/molecule/default-ubuntu_22.04/tests/test_apt_repo.py +++ /dev/null @@ -1,107 +0,0 @@ -"""testinfra file for apt specific tests.""" - -import os -import testinfra.utils.ansible_runner - -""" -These test should only run on debian based destributions -""" - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ["MOLECULE_INVENTORY_FILE"] -).get_hosts("nexus") - -apt_pub_key = """ ------BEGIN PGP PUBLIC KEY BLOCK----- - -mQGNBGNSbLEBDADGJXWoQwhjjgmGbMdnhfneYU2qjfMlgdoTH2oqkir6aaqHdS6l -88YUt/4mBAzaQhcETm7sIlrlAvXyfH4/i3ATwI4SUYUCl1fIZ9beRD3WWBwCiYMZ -XT0ZByrDL+aGpRO6xl0LCPr1loqHbvt2ZesoSn77Zv4tGHVLPiryG1KTxQPRCU4d -Ydg9wCwlrGseExA4O8ujgOeyo/ObxXrCilxJzvNf/21/KGSa54FzMyGiWvN7tOMT -Z9kau/bToIjwi4ME4nLx4T5c5qtYAoqlnbRR12pHBlx7RckncS1M/r+E1nX6GzeJ -cx4qAgd0HD226Kro3bahfM8ZWktbtJ7cytbPBwZ64Fu7kTzS0tfMPu0VBNK+EfrK -woDOoqg1i92r8VgTL6BQ+ouQy7BwWLKc6AEk/+M2f/L1ifDWay/uQdjNa27OKn0R -3cBBSYhmu7swnQqJ5Xl/M6qSFZXd0O6qiddZ/wynAsw7AHmi/BLWrd867hRHYLaS -a29lQPgU8+WRVzUAEQEAAbRsVGhvVGVhbSBOZXh1czMgQ0kgKEtleSBmb3IgYXB0 -IGNpIHRlc3Qgb24gaHR0cHM6Ly9naXRodWIuY29tL2Fuc2libGUtVGhvVGVhbS9u -ZXh1czMtb3NzKSA8dGhvdGVhbUBuZXh1czMuY2k+iQHOBBMBCgA4FiEEB5LYtM4/ -VAJnIFfdA/IJDIG6oBMFAmNSbLECGwMFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AA -CgkQA/IJDIG6oBO0AwwAsC/mtjOi/SAsDeDVNoaOOT9iGI02Ddjpz+FzucSL384V -rBwQVrIEYRJ0OYCTdKVeArAer7CAe34vtPMAm3tTWwQg4hTYeTR659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+s3K6+XM+8dOy4KcnfDdouEQYs5X1n2zx -nOV760YmnqCA7yk4p32LsW4zRp9Hs4rNPU0K4MnLLkEs24S99ohNQQhKauMxmFAZ -yH767j1oN2vFTdwANKswpkszfzEnGo0rFN+uIok1ENsB0cQWoyF/BSpOX2/MvCap -Lvf8yzAWqdQiF1zgcShKrpXny+rbI3owrDBSJ4VTAsKWbiXgbEh7gx7kZQOj4Ilu -bEKDmCbp2KH1RTlYGxR36x4B2i6oC+wJ1KYqbX/ZOsyXajH6s35fR551Ttlkz1HH -kUFDmTnFRhIhaiG8aytyHrQpNdXQz9pUcLZEtttBcAvelj5iWiWg86nkPGR/fFzs -KETG0Jx8lydvuBtPlK+MgTRsPDr3sntDrkdmE5CWvk75VekDO5zTuLFS2QTkhWSI -ztL8V2T47uABUGCunyFxhVRM7q9VQIRC+i7bEO3v0J6R2RZlI2A7tQ== -=Oq1K ------END PGP PUBLIC KEY BLOCK----- -""" - - -def test_apt_package_upload(host: testinfra.host.Host): - """Test we can upload an apt package to repository.""" - # Copy debian test package - host.ansible( - "get_url", - "url=https://github.com/ansible-ThoTeam/nexushello-apt-package/releases" - "/download/v1.0.1/nexushello_1.0.1_all.deb dest=/tmp", - check=False, - ) - - upload = host.run( - 'curl -X POST "https://localhost/service/rest/v1/components?repository=private_ubuntu_18.04" -k ' - "-u admin:changeme " - '-H "accept: application/json" ' - '-H "Content-Type: multipart/form-data" ' - '-F "apt.asset=@/tmp/nexushello_1.0.1_all.deb;type=application/vnd.debian.binary-package"' - ) - assert upload.exit_status == 0 - - # Install hello-world package on host from uploaded file - host.run( - "echo deb https://localhost/repository/private_ubuntu_18.04 bionic main " - "> /etc/apt/sources.list.d/nexushello.list" - ) - - # Disable ssl verification as we use a self signed cert for tests - host.run( - """cat > /etc/apt/apt.conf.d/no-verify-ssl << EOF -Acquire::https { - Verify-Peer \"false\"; - Verify-Host \"false\"; -} -EOF""" - ) - - # Import gpg key of our repo - host.run(f'echo "{apt_pub_key}" > /tmp/pub.key') - host.run("apt-key add /tmp/pub.key") - - # Install package - host.ansible( - "apt", - "name=nexushello state=present update-cache=true", - check=False, - become=True, - ) - - assert host.run("nexushello").stdout == "Hello nexus !\n" diff --git a/molecule/default-ubuntu_22.04/tests/test_apt_repo.py b/molecule/default-ubuntu_22.04/tests/test_apt_repo.py new file mode 120000 index 00000000..43ab9ab4 --- /dev/null +++ b/molecule/default-ubuntu_22.04/tests/test_apt_repo.py @@ -0,0 +1 @@ +../../test_apt_repo.py \ No newline at end of file diff --git a/molecule/default-ubuntu_22.04/tests/test_default.py b/molecule/default-ubuntu_22.04/tests/test_default.py deleted file mode 100644 index 5d718528..00000000 --- a/molecule/default-ubuntu_22.04/tests/test_default.py +++ /dev/null @@ -1,23 +0,0 @@ -"""Default testinfra file for the role.""" - -import os - -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ["MOLECULE_INVENTORY_FILE"] -).get_hosts("nexus") - - -def test_npm_scoped_package_download(host): - """Test if we can download npm scoped packages.""" - test_package_url = "https://localhost/repository/npm-public/@angular%2fcore" - - get_url_options = ( - f"url='{test_package_url}' dest='/tmp/testfile' force='yes' validate_certs='no'" - ) - - download = host.ansible("get_url", get_url_options, check=False) - - assert download["status_code"] == 200 - assert download["state"] == "file" diff --git a/molecule/default-ubuntu_22.04/tests/test_default.py b/molecule/default-ubuntu_22.04/tests/test_default.py new file mode 120000 index 00000000..7889e2fe --- /dev/null +++ b/molecule/default-ubuntu_22.04/tests/test_default.py @@ -0,0 +1 @@ +../../test_default.py \ No newline at end of file diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml deleted file mode 100644 index 7dc9a7bd..00000000 --- a/molecule/default/converge.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: Import default converge playbook - import_playbook: ../default-converge.yml diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml deleted file mode 100644 index 27846751..00000000 --- a/molecule/default/molecule.yml +++ /dev/null @@ -1,63 +0,0 @@ ---- -dependency: - name: galaxy - enabled: false - -driver: - name: docker - safe_files: - - nexus-downloads - -lint: | - set -e - yamllint . - ansible-lint - flake8 - -platforms: - - name: nexus3-oss-default - hostname: nexus3-oss-default - image: thoteam/molecule_apache_openjdk8:centos7 - command: /usr/sbin/init - pull: true - pre_build_image: true - privileged: true - groups: - - nexus - networks: &nexus_networks - - name: nexus-default - volumes: - - ${MOLECULE_PROJECT_DIRECTORY}/molecule/.nexus-downloads:/nexus-downloads - - - name: slapd-server-mock - hostname: slapd-server-mock - image: thoteam/slapd-server-mock:latest - override_command: false - pull: true - pre_build_image: true - env: - LDAP_DOMAIN: slapd-server-mock - groups: - - mockldap - networks: *nexus_networks - -provisioner: - name: ansible - -scenario: - check_sequence: - - destroy - - create - - converge - - check - - destroy - converge_sequence: - - create - - converge - test_sequence: - - lint - -verifier: - name: testinfra - -role_name_check: 2 diff --git a/molecule/nexus_common_test_vars.yml b/molecule/nexus_common_test_vars.yml index 549a726c..c8e5f3f5 100644 --- a/molecule/nexus_common_test_vars.yml +++ b/molecule/nexus_common_test_vars.yml @@ -115,8 +115,8 @@ nexus_repos_docker_hosted: nexus_repos_docker_proxy: [] nexus_repos_apt_hosted: - - name: private_ubuntu_18.04 - distribution: bionic + - name: private_apt + distribution: all keypair: |- -----BEGIN PGP PRIVATE KEY BLOCK----- @@ -205,7 +205,7 @@ nexus_repos_apt_hosted: -----END PGP PRIVATE KEY BLOCK----- passphrase: password # Allow redeploy to allow repeated failing tests when debugging - # !! Don't do this for a release repo on produciton + # !! Don't do this for a release repo on production write_policy: allow nexus_repos_apt_proxy: @@ -332,7 +332,7 @@ nexus_privileges: nexus_roles: - name: c-ro-private_yum_centos_7 id: c-ro-private_yum_centos_7 - description: Custrom read-only role for private_yum_centos_7 hosted repository + description: Custom read-only role for private_yum_centos_7 hosted repository privileges: - nx-repository-view-yum-private_yum_centos_7-read - nx-repository-view-yum-private_yum_centos_7-browse diff --git a/molecule/test_apt_repo.py b/molecule/test_apt_repo.py index 1a8643be..ac16eecc 100644 --- a/molecule/test_apt_repo.py +++ b/molecule/test_apt_repo.py @@ -4,7 +4,7 @@ import testinfra.utils.ansible_runner """ -These test should only run on debian based destributions +These test should only run on debian based distributions """ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( @@ -55,6 +55,12 @@ =Oq1K -----END PGP PUBLIC KEY BLOCK----- """ +apt_gpg_target = "/etc/apt/keyrings/private_nexus.asc" +apt_private_repo = "private_apt" + +nexushello_version = "1.0.4" +nexushello_deb_build = "1" +nexushello_distribution = "all" def test_apt_package_upload(host: testinfra.host.Host): @@ -63,23 +69,32 @@ def test_apt_package_upload(host: testinfra.host.Host): host.ansible( "get_url", "url=https://github.com/ansible-ThoTeam/nexushello-apt-package/releases" - "/download/v1.0.1/nexushello_1.0.1_all.deb dest=/tmp", + f"/download/v{nexushello_version}/nexushello_{nexushello_version}-{nexushello_deb_build}_all.deb dest=/tmp", check=False, ) upload = host.run( - 'curl -X POST "https://localhost/service/rest/v1/components?repository=private_ubuntu_18.04" -k ' - "-u admin:changeme " - '-H "accept: application/json" ' - '-H "Content-Type: multipart/form-data" ' - '-F "apt.asset=@/tmp/nexushello_1.0.1_all.deb;type=application/vnd.debian.binary-package"' + 'curl -k -u "admin:changeme" -H "Content-Type: multipart/form-data" ' + '--data-binary "@/tmp/nexushello_%s-%s_all.deb" ' + '"https://localhost/repository/%s/"', + nexushello_version, + nexushello_deb_build, + apt_private_repo, ) assert upload.exit_status == 0 - # Install hello-world package on host from uploaded file + # Import gpg key of our repo + host.run("mkdir -p $(dirname %s)", apt_gpg_target) + host.run("echo %s > %s", apt_pub_key, apt_gpg_target) + + # Configure our private repo for apt host.run( - "echo deb https://localhost/repository/private_ubuntu_18.04 bionic main " - "> /etc/apt/sources.list.d/nexushello.list" + "echo 'deb [arch=all signed-by=%s] " + "https://localhost/repository/%s %s main' " + "> /etc/apt/sources.list.d/nexushello.list", + apt_gpg_target, + apt_private_repo, + nexushello_distribution, ) # Disable ssl verification as we use a self signed cert for tests @@ -92,10 +107,6 @@ def test_apt_package_upload(host: testinfra.host.Host): EOF""" ) - # Import gpg key of our repo - host.run(f'echo "{apt_pub_key}" > /tmp/pub.key') - host.run("apt-key add /tmp/pub.key") - # Install package host.ansible( "apt", @@ -104,4 +115,4 @@ def test_apt_package_upload(host: testinfra.host.Host): become=True, ) - assert host.run("nexushello").stdout == "Hello nexus !\n" + assert host.run("nexushello").stdout == "Hello nexus!\n" diff --git a/requirements.txt b/requirements.txt index d718867c..7d3f05bf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,6 +20,6 @@ flake8 flake8-docstrings jmespath molecule -molecule-docker +molecule-plugins[docker] pytest-testinfra yamllint diff --git a/tasks/call_script.yml b/tasks/call_script.yml index b780334d..e3ca0fda 100644 --- a/tasks/call_script.yml +++ b/tasks/call_script.yml @@ -15,7 +15,7 @@ method: POST force_basic_auth: true validate_certs: "{{ nexus_api_validate_certs }}" - body: "{{ args | to_json }}" + body: "{{ call_args | to_json }}" register: script_run failed_when: script_run | nexus_groovy_error | bool changed_when: script_run | nexus_groovy_changed | bool diff --git a/tasks/create_task_each.yml b/tasks/create_task_each.yml index e5b000d3..89db1f1a 100644 --- a/tasks/create_task_each.yml +++ b/tasks/create_task_each.yml @@ -3,4 +3,4 @@ ansible.builtin.include_tasks: call_script.yml vars: script_name: create_task - args: "{{ item }}" + call_args: "{{ item }}" diff --git a/tasks/delete_blobstore_each.yml b/tasks/delete_blobstore_each.yml index 3c7d6131..373c0cb7 100644 --- a/tasks/delete_blobstore_each.yml +++ b/tasks/delete_blobstore_each.yml @@ -3,4 +3,4 @@ ansible.builtin.include_tasks: call_script.yml vars: script_name: delete_blobstore - args: "{{ item }}" + call_args: "{{ item }}" diff --git a/tasks/delete_repo_each.yml b/tasks/delete_repo_each.yml index f2bed597..85467f1d 100644 --- a/tasks/delete_repo_each.yml +++ b/tasks/delete_repo_each.yml @@ -3,5 +3,5 @@ ansible.builtin.include_tasks: call_script.yml vars: script_name: delete_repo - args: + call_args: name: "{{ item }}" diff --git a/tasks/main.yml b/tasks/main.yml index 502d73bb..f2a52de7 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -38,7 +38,7 @@ ansible.builtin.include_tasks: call_script.yml vars: script_name: setup_http_proxy - args: + call_args: with_http_proxy: "{{ nexus_with_http_proxy }}" http_proxy_host: "{{ nexus_http_proxy_host }}" http_proxy_port: "{{ nexus_http_proxy_port }}" @@ -87,7 +87,7 @@ ansible.builtin.include_tasks: call_script.yml vars: script_name: create_content_selectors_from_list - args: "{{ nexus_content_selectors }}" + call_args: "{{ nexus_content_selectors }}" when: nexus_content_selectors | length > 0 - name: Apply defaults to privileges @@ -120,7 +120,7 @@ ansible.builtin.include_tasks: call_script.yml vars: script_name: create_blobstores_from_list - args: "{{ nexus_blobstores }}" + call_args: "{{ nexus_blobstores }}" when: nexus_blobstores | length > 0 - name: Restore nexus backup @@ -134,7 +134,7 @@ ansible.builtin.include_tasks: call_script.yml vars: script_name: create_cleanup_policies_from_list - args: "{{ nexus_repos_cleanup_policies }}" + call_args: "{{ nexus_repos_cleanup_policies }}" when: nexus_repos_cleanup_policies | length > 0 - name: Apply defaults to repositories configurations and process a single list @@ -144,55 +144,55 @@ ansible.builtin.include_tasks: call_script.yml vars: script_name: create_repos_from_list - args: "{{ _nexus_repos_global_list | d([]) }}" + call_args: "{{ _nexus_repos_global_list | d([]) }}" - name: Create/check privileges ansible.builtin.include_tasks: call_script.yml vars: script_name: setup_privileges_from_list - args: "{{ nexus_privileges }}" + call_args: "{{ nexus_privileges }}" when: nexus_privileges | length > 0 - name: Create/check roles ansible.builtin.include_tasks: call_script.yml vars: script_name: setup_roles_from_list - args: "{{ nexus_roles }}" + call_args: "{{ nexus_roles }}" when: nexus_roles | length > 0 - name: Create/check local users ansible.builtin.include_tasks: call_script.yml vars: script_name: setup_users_from_list - args: "{{ nexus_local_users }}" + call_args: "{{ nexus_local_users }}" when: nexus_local_users | length > 0 - name: Create/check ldap users ansible.builtin.include_tasks: call_script.yml vars: script_name: setup_ldap_users_from_list - args: "{{ nexus_ldap_users }}" + call_args: "{{ nexus_ldap_users }}" when: nexus_ldap_users | length > 0 - name: Configure anonymous access ansible.builtin.include_tasks: call_script.yml vars: script_name: setup_anonymous_access - args: + call_args: anonymous_access: "{{ nexus_anonymous_access }}" - name: Configure base url ansible.builtin.include_tasks: call_script.yml vars: script_name: setup_base_url - args: + call_args: base_url: "{{ nexus_public_scheme }}://{{ nexus_public_hostname }}/" - name: Configure realms ansible.builtin.include_tasks: call_script.yml vars: script_name: setup_realms - args: + call_args: nuget_api_key_realm: "{{ nexus_nuget_api_key_realm }}" npm_bearer_token_realm: "{{ nexus_npm_bearer_token_realm }}" rut_auth_realm: "{{ nexus_rut_auth_realm }}" @@ -203,7 +203,7 @@ ansible.builtin.include_tasks: call_script.yml vars: script_name: setup_capability - args: + call_args: capability_typeId: rutauth capability_enabled: true capability_properties: @@ -214,7 +214,7 @@ ansible.builtin.include_tasks: call_script.yml vars: script_name: setup_email - args: + call_args: email_server_enabled: "{{ nexus_email_server_enabled }}" email_server_host: "{{ nexus_email_server_host }}" email_server_port: "{{ nexus_email_server_port }}" @@ -232,7 +232,7 @@ ansible.builtin.include_tasks: call_script.yml vars: script_name: setup_capability - args: + call_args: capability_typeId: rapture.branding capability_enabled: "{{ (nexus_branding_footer | length > 0) and (nexus_branding_header | length > 0) }}" capability_properties: @@ -245,7 +245,7 @@ ansible.builtin.include_tasks: call_script.yml vars: script_name: setup_capability - args: + call_args: capability_typeId: audit capability_enabled: "{{ nexus_audit_enabled | bool }}" capability_properties: {} diff --git a/tasks/nexus_install.yml b/tasks/nexus_install.yml index 802428d2..9f950fa6 100644 --- a/tasks/nexus_install.yml +++ b/tasks/nexus_install.yml @@ -608,7 +608,7 @@ ansible.builtin.include_tasks: call_script.yml vars: script_name: update_admin_password - args: + call_args: new_password: "{{ nexus_admin_password }}" - name: Admin password changed diff --git a/tasks/setup_ldap_each.yml b/tasks/setup_ldap_each.yml index bcb08744..5b6bbb31 100644 --- a/tasks/setup_ldap_each.yml +++ b/tasks/setup_ldap_each.yml @@ -3,7 +3,7 @@ ansible.builtin.include_tasks: call_script.yml vars: script_name: setup_ldap - args: + call_args: name: "{{ item.ldap_name }}" protocol: "{{ item.ldap_protocol }}" hostname: "{{ item.ldap_hostname }}"