Reputation: 2722
i am using following code in ansible tasks
- name: Check the status of application server {{ server }}
command: /opt/serverStatus.sh {{ server }}
register: url
- debug: msg="{{ url.stdout }}"
- name: start the application server
command: /opt/startServer.sh {{ server }}
when: msg | match("It appears to be stopped.")
getting following error :
fatal: server: FAILED! => {"failed": true, "msg": "The conditional check 'msg | match(\"It appears to be stopped.\")' failed. The error was: Unexpected templating type error occurred on ({% if msg | match(\"It appears to be stopped.\") %} True {% else %} False {% endif %}): expected string or buffer\n\nThe error appears to have been in '/home/abc/xyz/roles/was/tasks/main.yml': line 28, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: start the application server\n ^ here\n"}
please help where i am doing wrong. any quotes missing ?
Upvotes: 0
Views: 523
Reputation: 68229
This happens because msg
is undefined. You want to use:
- name: start the application server
command: /opt/startServer.sh {{ server }}
when: url.stdout | match("It appears to be stopped.")
Upvotes: 1