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

Space in prom_tarball not supported #23

Open
mulbc opened this issue Nov 21, 2023 · 0 comments
Open

Space in prom_tarball not supported #23

mulbc opened this issue Nov 21, 2023 · 0 comments

Comments

@mulbc
Copy link
Contributor

mulbc commented Nov 21, 2023

When we have a space in the prom_tarball variable, the playbook run fails.

What I have tried:

  1. ansible-playbook deploy-local.yml -e prom_tarball=/home/cblum/Downloads/prometheus\ (1).tar.gz
  2. ansible-playbook deploy-local.yml -e prom_tarball='/home/cblum/Downloads/prometheus (1).tar.gz'
  3. ansible-playbook deploy-local.yml -e prom_tarball='"/home/cblum/Downloads/prometheus (1).tar.gz"'

1 and 2 fail at this location, complaining that the file does not exist:

https://github.com/pcuzner/odf-grafana/blob/e1a96187d4866f45c230ba2c4c00f840d7593b2b/roles/prepare/tasks/extract_tarball.yml#L18

[...]
TASK [prepare : Check prom_tarball variable is set] **********************************************************************************
skipping: [localhost]

TASK [prepare : Try to stat /home/cblum/Downloads/prometheus] ************************************************************************
ok: [localhost]

TASK [prepare : Fail of /home/cblum/Downloads/prometheus is not found] ***************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unable to find /home/cblum/Downloads/prometheus"}

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

Important to note is that somewhere the variable content is split at the space character, so that it checks if /home/cblum/Downloads/prometheus exists, which it really does not.

3 fails later in the run

The variable content this time is not split at first and it continues until https://github.com/pcuzner/odf-grafana/blob/e1a96187d4866f45c230ba2c4c00f840d7593b2b/roles/prepare/tasks/extract_tarball.yml#L27

[...]
TASK [prepare : Check prom_tarball variable is set] **********************************************************************************
skipping: [localhost]

TASK [prepare : Try to stat /home/cblum/Downloads/prometheus (1).tar.gz] *************************************************************
ok: [localhost]

TASK [prepare : Fail of /home/cblum/Downloads/prometheus (1).tar.gz is not found] ****************************************************
skipping: [localhost]

TASK [prepare : Ensure /home/cblum/.prometheus exists] *******************************************************************************
changed: [localhost]

TASK [prepare : Get size of Prometheus backup] ***************************************************************************************
fatal: [localhost]: FAILED! => {"changed": true, "cmd": "gzip -l /home/cblum/Downloads/prometheus (1).tar.gz | tail -n 1 | awk '{print $2}'", "delta": "0:00:00.002649", "end": "2023-11-21 10:43:21.686566", "msg": "non-zero return code", "rc": 2, "start": "2023-11-21 10:43:21.683917", "stderr": "/bin/sh: -c: line 1: syntax error near unexpected token `('\n/bin/sh: -c: line 1: `gzip -l /home/cblum/Downloads/prometheus (1).tar.gz | tail -n 1 | awk '{print $2}''", "stderr_lines": ["/bin/sh: -c: line 1: syntax error near unexpected token `('", "/bin/sh: -c: line 1: `gzip -l /home/cblum/Downloads/prometheus (1).tar.gz | tail -n 1 | awk '{print $2}''"], "stdout": "", "stdout_lines": []}

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

I have found no easy and immediate way to fix this in the code, but wanted to leave this here so it can eventually be fixed.

Obvious workaround is to rename the file so that we don't have a space in it:

$ mv  '/home/cblum/Downloads/prometheus (1).tar.gz' /home/cblum/Downloads/prometheus-1.tar.gz  
$ ansible-playbook deploy-local.yml -e prom_tarball='/home/cblum/Downloads/prometheus-1.tar.gz' 
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

No branches or pull requests

1 participant