-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
echo: command doesn't support condition #240
Comments
* add condition support to echo, see #240 * format tests * clarify condition limitation
@dstull the change on master. Please give it a try and see if it resolves the issue. I have covered the change with decent tests but have not tried it manually. I think it will work the way you expect it to work. in case if you have troubles building it - let me know if you need binary (pls specify for what platform in this case) and i will attach |
@umputun awesome! It will probably be quicker if you had a minute to build it than for me right now as I'd have to figure a few things out. So if you have the time linux amd64 is the type/build I've been using |
sure: spot.master.zip |
@umputun tested locally with config of user: ubuntu
ssh_key: /home/ubuntu/.ssh/id_rsa
ssh_shell: /bin/bash
local_shell: /bin/bash
inventory: inventory.yml
tasks:
- name: Check known rails issue 366450
targets: ["gitlab_rails"]
commands:
- name: Condition check
script: |
rm -f /tmp/366450
version=${GITLAB_VERSION//./}
if [[ $version -gt 1500 && $version -lt 1630 ]]; then
touch /tmp/366450
fi
- name: Checking for known issue
script: |
if grep -s 'OmniAuth::Strategies::SAML' /etc/gitlab/gitlab.rb | grep strategy_class; then
touch /tmp/366450_warning
fi
on_exit: "rm -fv /tmp/366450"
options: {ignore_errors: true, sudo: true}
cond: "test -f /tmp/366450"
- name: Display warning message
echo: "If you're using SAML for OmniAuth you might be running into known issue https://gitlab.com/gitlab-org/gitlab/-/issues/366450"
cond: "test -f /tmp/366450_warning"
- name: Cleanup temp files
script: |
rm -fv /tmp/366450_warning
options: {ignore_errors: true, sudo: true}
- name: Fake issue that will fail
targets: ["gitlab_rails"]
commands:
- name: Condition check
script: |
rm -f /tmp/fake
version=${GITLAB_VERSION//./}
if [[ $version -gt 1500 && $version -lt 1700 ]]; then
touch /tmp/fake
fi
- name: Checking condition for known fake issue
script: |
if grep -s "gitlab_backup_cli\['dir'\]" /etc/gitlab/gitlab.rb | grep '/var/opt/gitlab/backups'; then
touch /tmp/fake_warning
fi
on_exit: "rm -fv /tmp/fake"
options: {ignore_errors: true, sudo: true}
cond: "test -f /tmp/fake"
- name: Display warning message
echo: "If this is set to backups, that is wrong. Make sure you fix that."
cond: "test -f /tmp/fake_warning"
- name: Cleanup temp files
script: |
rm -fv /tmp/fake_warning
options: {sudo: true}
ubuntu@sr-env-049aca04-omnibus:~$ ./spot -p rails_known_issues.yml --env GITLAB_VERSION:1600
spot dev-master
[omnibus localhost:22] run task "Check known rails issue 366450", commands: 4
[omnibus localhost:22] completed command "Condition check" {script: /bin/sh -c [multiline script]} (806ms)
[omnibus localhost:22] completed command "Checking for known issue" {script: /bin/sh -c [multiline script]} (108ms)
[omnibus localhost:22] completed command "Display warning message" {skip: Display warning message} (8ms)
[omnibus localhost:22] completed command "Cleanup temp files" {script: /bin/sh -c [multiline script]} (45ms)
[omnibus localhost:22] completed task "Check known rails issue 366450", commands: 4 (1.021s)
[omnibus localhost:22] run task "Fake issue that will fail", commands: 4
[omnibus localhost:22] completed command "Condition check" {script: /bin/sh -c [multiline script]} (229ms)
[omnibus localhost:22] completed command "Checking condition for known fake issue" {script: /bin/sh -c [multiline script]} (55ms)
[omnibus localhost:22] completed command "Display warning message" {echo: If this is set to backups, that is wrong. Make sure you fix that.} (9ms)
[omnibus localhost:22] completed command "Cleanup temp files" {script: /bin/sh -c [multiline script]} (35ms)
[omnibus localhost:22] completed task "Fake issue that will fail", commands: 4 (402ms) verified!
|
cool. will release an updated version shortly |
Discussed in #238
Originally posted by dstull December 18, 2024
the echo command, nor using an echo in a script: outputs to the console. Am I doing something wrong?
See below:
echo as a command:
echo
in a script:I expected the echo output would show the actual echo instead this appears as just a statement of the command being issued, not a actual echo to the console.
The text was updated successfully, but these errors were encountered: