Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download of nexus archive not working if nexus_download_retries set to higher than 0 #410

Open
haxorof opened this issue Mar 9, 2024 · 0 comments · May be fixed by #411
Open

Download of nexus archive not working if nexus_download_retries set to higher than 0 #410

haxorof opened this issue Mar 9, 2024 · 0 comments · May be fixed by #411

Comments

@haxorof
Copy link

haxorof commented Mar 9, 2024

I have just tested that current download is defined in nexus_install.yml does not work when you set nexus_download_retries to higher than 0. This because the HTTP status 304 "Not Modified" will be returned if file already been downloaded once at least when you download via proxy.
https://github.com/ansible-ThoTeam/nexus3-oss/blob/main/tasks/nexus_install.yml#L69-L84

Problem here is until is only waiting for 200 but it must also wait for 304 when file has already been downloaded once.

I extracted just the download task (removed config that does not affect the result) to separate playbook using ansible-core 2.13 and 2.15 which behaves the same.

First run

sh-5.1# ansible-playbook -c local -vv test_get_url.yml
ansible-playbook [core 2.15.9]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.9.18 (main, Jan  4 2024, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] (/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True
No config file found; using defaults
 
PLAYBOOK: test_get_url.yml ***************************************************************************************************************************************
1 plays in test_get_url.yml

PLAY [localhost] *************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************
task path: /mnt/test_get_url.yml:2
ok: [localhost]

TASK [Download nexus_package] ************************************************************************************************************************************
task path: /mnt/test_get_url.yml:4
changed: [localhost] => {"attempts": 1, "changed": true, "checksum_dest": null, "checksum_src": "fb30323e993b9bad5657a08dd51ad2fab7e9f828", "dest": "/var/tmp/nexus.tar.gz", "elapsed": 2, "gid": 0, "group": "root", "md5sum": "346237816c3f5f1e0a7091f32c01fa8b", "mode": "0644", "msg": "OK (231860503 bytes)", "owner": "root", "size": 231860503, "src": "/root/.ansible/tmp/ansible-tmp-1709979800.67586-97-75013314796521/tmp3iw00p7q", "state": "file", "status_code": 200, "uid": 0, "url": https://download.sonatype.com/nexus/3/nexus-3.65.0-02-unix.tar.gz}

PLAY RECAP *******************************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Show file has been downloaded correctly:

sh-5.1# ls -lahr /var/tmp/nexus.tar.gz
-rw-r--r--. 1 root root 222M Mar  9 10:23 /var/tmp/nexus.tar.gz

Second run:

sh-5.1# ansible-playbook -c local -vv test_get_url.yml
ansible-playbook [core 2.15.9]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.9.18 (main, Jan  4 2024, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] (/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True
No config file found; using defaults

PLAYBOOK: test_get_url.yml ***************************************************************************************************************************************
1 plays in test_get_url.yml

PLAY [localhost] *************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************
task path: /mnt/test_get_url.yml:2
ok: [localhost]

TASK [Download nexus_package] ************************************************************************************************************************************
task path: /mnt/test_get_url.yml:4
FAILED - RETRYING: [localhost]: Download nexus_package (1 retries left).
fatal: [localhost]: FAILED! => {"attempts": 1, "changed": false, "dest": "/var/tmp/nexus.tar.gz", "elapsed": 0, "gid": 0, "group": "root", "mode": "0644", "msg": "HTTP Error 304: Not Modified", "owner": "root", "size": 231860503, "state": "file", "status_code": 304, "uid": 0, "url": https://download.sonatype.com/nexus/3/nexus-3.65.0-02-unix.tar.gz}

PLAY RECAP *******************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

To fix this then until needs to look like this:

until: download_status.status_code == 200 or download_status.status_code == 304
haxorof added a commit to haxorof/nexus3-oss that referenced this issue Mar 9, 2024
@haxorof haxorof linked a pull request Mar 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant